directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r659885 - in /directory/apacheds/branches/bigbang: jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
Date Sat, 24 May 2008 23:07:17 GMT
Author: akarasulu
Date: Sat May 24 16:07:17 2008
New Revision: 659885

URL: http://svn.apache.org/viewvc?rev=659885&view=rev
Log:
Fixing issues with subtree scope scan count determination.

 o fixed default optimizer to leverage subtree level index
 o default optimizer checks to make sure if the context entry is the candidate
   for which a scan count is generated it defaults to all entries in db other
   wise it uses the scan count from the index
 o fixed issue where context entry id was not set when filter nodes were created
   using it so we default to 1L but this should be fixed later if we use 
   partition id components in the Long entry identifier


Modified:
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=659885&r1=659884&r2=659885&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
(original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
Sat May 24 16:07:17 2008
@@ -28,7 +28,6 @@
 import org.apache.directory.server.core.entry.DefaultServerAttribute;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.ServerStringValue;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
@@ -183,6 +182,11 @@
     
     public Long getContextEntryId()
     {
+        if ( contextEntryId == null )
+        {
+            return 1L;
+        }
+        
         return contextEntryId;
     }
 
@@ -280,7 +284,7 @@
         // Now, create the entry cache for this partition
         recMan = new CacheRecordManager( base, new MRU( cacheSize ) );
 
-        // Create the master table (the table wcontaining all the entries)
+        // Create the master table (the table containing all the entries)
         master = new JdbmMasterTable<ServerEntry>( recMan, registries );
 
         // -------------------------------------------------------------------
@@ -290,12 +294,8 @@
         setupSystemIndices();
         setupUserIndices();
 
-        contextEntry.getDn().normalize( attributeTypeRegistry.getNormalizerMapping() );
-
         initSuffixEntry3( suffixDn, contextEntry );
         
-        contextEntryId = getEntryId( contextEntry.getDn().getNormName() );
-
         // We are done !
         initialized = true;
     }
@@ -414,7 +414,8 @@
      */
     protected void initSuffixEntry3( String suffix, ServerEntry entry ) throws Exception
     {
-        // add entry for context, if it does not exist
+        // normalize then add entry for context, if it does not exist
+        contextEntry.getDn().normalize( attributeTypeRegistry.getNormalizerMapping() );
         ServerEntry suffixOnDisk = getSuffixEntry();
 
         if ( suffixOnDisk == null )
@@ -423,6 +424,8 @@
             LdapDN normalizedSuffix = LdapDN.normalize( dn, attributeTypeRegistry.getNormalizerMapping()
);
             add( normalizedSuffix, entry );
         }
+        
+        contextEntryId = ndnIdx.forwardLookup( contextEntry.getDn().getNormName() );
     }
 
 
@@ -1195,14 +1198,12 @@
 
     public ServerEntry getSuffixEntry() throws Exception
     {
-        Long id = getEntryId( normSuffix.toNormName() );
-
-        if ( null == id )
+        if ( null == contextEntryId )
         {
             return null;
         }
 
-        return lookup( id );
+        return lookup( contextEntryId );
     }
 
 

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java?rev=659885&r1=659884&r2=659885&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
(original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
Sat May 24 16:07:17 2008
@@ -52,7 +52,9 @@
 public class DefaultOptimizer<E> implements Optimizer
 {
     /** the database this optimizer operates on */
-    private Store<E> db;
+    private final Store<E> db;
+    private final Long contextEntryId;
+    
 
     /**
      * Creates an optimizer on a database.
@@ -62,6 +64,7 @@
     public DefaultOptimizer( Store<E> db )
     {
         this.db = db;
+        this.contextEntryId = db.getContextEntryId();
     }
 
 
@@ -337,17 +340,24 @@
      */
     private long getScopeScan( ScopeNode node ) throws Exception
     {
+        Long id = db.getEntryId( node.getBaseDn() );
         switch ( node.getScope() )
         {
             case OBJECT:
                 return 1L;
             
             case ONELEVEL:
-                Long id = db.getEntryId( node.getBaseDn() );
                 return db.getChildCount( id );
                 
             case SUBTREE:
-                return db.count();
+                if ( id.longValue() == contextEntryId.longValue() )
+                {
+                    return db.count();
+                }
+                else
+                {
+                    return db.getSubLevelIndex().count( id );
+                }
             
             default:
                 throw new IllegalArgumentException( "Unrecognized search scope " + "value
for filter scope node" );



Mime
View raw message