You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/04/27 16:55:45 UTC

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

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;
     }