directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1331620 - /directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
Date Fri, 27 Apr 2012 22:54:41 GMT
Author: elecharny
Date: Fri Apr 27 22:54:40 2012
New Revision: 1331620

URL: http://svn.apache.org/viewvc?rev=1331620&view=rev
Log:
Added a prefetched field in the cursor to avoid a double fetch on the master table

Modified:
    directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java?rev=1331620&r1=1331619&r2=1331620&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
Fri Apr 27 22:54:40 2012
@@ -46,6 +46,9 @@ public class PresenceCursor<ID extends C
     private final IndexCursor<String, Entry, ID> uuidCursor;
     private final IndexCursor<String, Entry, ID> presenceCursor;
     private final PresenceEvaluator<ID> presenceEvaluator;
+    
+    /** The prefetched entry, if it's a valid one */
+    private IndexEntry<String, ID> prefetched;
 
 
     public PresenceCursor( Store<Entry, ID> store, PresenceEvaluator<ID> presenceEvaluator
) throws Exception
@@ -248,6 +251,7 @@ public class PresenceCursor<ID extends C
     public boolean next() throws Exception
     {
         checkNotClosed( "next()" );
+        
         if ( presenceCursor != null )
         {
             return presenceCursor.next();
@@ -256,10 +260,12 @@ public class PresenceCursor<ID extends C
         while ( uuidCursor.next() )
         {
             checkNotClosed( "next()" );
-            IndexEntry<?, ID> candidate = uuidCursor.get();
+            IndexEntry<String, ID> candidate = uuidCursor.get();
 
             if ( presenceEvaluator.evaluate( candidate ) )
             {
+                prefetched = candidate;
+                
                 return setAvailable( true );
             }
         }
@@ -284,15 +290,19 @@ public class PresenceCursor<ID extends C
 
         if ( available() )
         {
+            if ( prefetched == null )
+            {
+                prefetched = uuidCursor.get();
+            }
+            
             /*
              * The value of NDN indices is the normalized dn and we want the
              * value to be the value of the attribute in question.  So we will
              * set that accordingly here.
              */
-            IndexEntry<String, ID> indexEntry = uuidCursor.get();
-            indexEntry.setKey( presenceEvaluator.getAttributeType().getOid() );
+            prefetched.setKey( presenceEvaluator.getAttributeType().getOid() );
 
-            return indexEntry;
+            return prefetched;
         }
 
         throw new InvalidCursorPositionException( I18n.err( I18n.ERR_708 ) );



Mime
View raw message