directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1331451 - /directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
Date Fri, 27 Apr 2012 14:55:45 GMT
Author: elecharny
Date: Fri Apr 27 14:55:45 2012
New Revision: 1331451

URL: http://svn.apache.org/viewvc?rev=1331451&view=rev
Log:
Improved the way the Dn is built from an ID : we don't parse the DN again. It speeds up the
server by 15%

Modified:
    directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1331451&r1=1331450&r2=1331451&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
Fri Apr 27 14:55:45 2012
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -1964,8 +1965,9 @@ public abstract class AbstractBTreeParti
         ID parentId = id;
         ID rootId = getRootId();
 
-        StringBuilder upName = new StringBuilder();
-        boolean isFirst = true;
+        // Create an array of 10 rdns, just in case. We will extend it if needed
+        Rdn[] rdnArray = new Rdn[10];
+        int pos = 0;
 
         do
         {
@@ -1974,23 +1976,22 @@ public abstract class AbstractBTreeParti
 
             for ( Rdn rdn : rdns )
             {
-                if ( isFirst )
-                {
-                    isFirst = false;
-                }
-                else
+                if ( ( pos > 0 ) && (pos % 10 == 0 ) )
                 {
-                    upName.append( ',' );
+                    // extend the array
+                    Rdn[] newRdnArray = new Rdn[pos + 10];
+                    System.arraycopy( rdnArray, 0, newRdnArray, 0, pos );
+                    rdnArray = newRdnArray;
                 }
-
-                upName.append( rdn.getName() );
+                
+                rdnArray[pos++]= rdn;
             }
 
             parentId = cur.getParentId();
         }
         while ( !parentId.equals( rootId ) );
 
-        Dn dn = new Dn( schemaManager, upName.toString() );
+        Dn dn = new Dn( schemaManager, Arrays.copyOf( rdnArray, pos ) );
 
         return dn;
     }



Mime
View raw message