directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r640704 - /directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/
Date Tue, 25 Mar 2008 05:22:29 GMT
Author: akarasulu
Date: Mon Mar 24 22:22:25 2008
New Revision: 640704

URL: http://svn.apache.org/viewvc?rev=640704&view=rev
Log:
general cleanups - everything is still in shambles

Added:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
  (contents, props changed)
      - copied, changed from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/Enumerator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionCursorBuilder.java
  (contents, props changed)
      - copied, changed from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEnumerator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
  (contents, props changed)
      - copied, changed from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DisjunctionEnumeration.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeCursorBuilder.java
  (contents, props changed)
      - copied, changed from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEnumerator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursorBuilder.java
  (contents, props changed)
      - copied, changed from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEnumerator.java
Removed:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DisjunctionEnumeration.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/Enumerator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEnumerator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEnumerator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEnumerator.java
Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEvaluator.java

Copied: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
(from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/Enumerator.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/Enumerator.java&r1=640686&r2=640704&rev=640704&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/Enumerator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
Mon Mar 24 22:22:25 2008
@@ -31,7 +31,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public interface Enumerator<E>
+public interface CursorBuilder<V,E>
 {
     /**
      * Creates an enumeration to enumerate through the set of candidates 
@@ -41,5 +41,5 @@
      * @return an enumeration over the 
      * @throws Exception if database access fails
      */
-    Cursor<IndexEntry<Long,E>> enumerate( ExprNode node ) throws Exception;
+    Cursor<IndexEntry<V,E>> enumerate( ExprNode node ) throws Exception;
 }

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Mar 24 22:22:25 2008
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=640704&r1=640703&r2=640704&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
Mon Mar 24 22:22:25 2008
@@ -49,8 +49,8 @@
     private Store<E> db;
     /** Evaluator flyweight used for filter expression assertions */
     private Evaluator<E> evaluator;
-    /** Enumerator flyweight that creates enumerations on filter expressions */
-    private Enumerator<E> enumerator;
+    /** CursorBuilder flyweight that creates enumerations on filter expressions */
+    private CursorBuilder<E> cursorBuilder;
 
 
     // ------------------------------------------------------------------------
@@ -61,15 +61,15 @@
      * Creates a DefaultSearchEngine for searching a Database without setting
      * up the database.
      * @param db the btree based partition
-     * @param enumerator an expression enumerator
+     * @param cursorBuilder an expression cursorBuilder
      * @param evaluator an expression evaluator
      * @param optimizer an optimizer to use during search
      */
-    public DefaultSearchEngine( Store<E> db, Evaluator<E> evaluator, Enumerator<E>
enumerator, Optimizer optimizer )
+    public DefaultSearchEngine( Store<E> db, Evaluator<E> evaluator, CursorBuilder<E>
cursorBuilder, Optimizer optimizer )
     {
         this.db = db;
         this.evaluator = evaluator;
-        this.enumerator = enumerator;
+        this.cursorBuilder = cursorBuilder;
         this.optimizer = optimizer;
     }
 
@@ -124,7 +124,7 @@
 
         // Annotate the node with the optimizer and return search enumeration.
         optimizer.annotate( root );
-        return enumerator.enumerate( root );
+        return cursorBuilder.enumerate( root );
     }
 
 

Copied: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionCursorBuilder.java
(from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEnumerator.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionCursorBuilder.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionCursorBuilder.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEnumerator.java&r1=640686&r2=640704&rev=640704&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEnumerator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionCursorBuilder.java
Mon Mar 24 22:22:25 2008
@@ -29,6 +29,7 @@
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.core.partition.impl.btree.IndexAssertion;
 import org.apache.directory.server.core.partition.impl.btree.IndexAssertionEnumeration;
 import org.apache.directory.shared.ldap.NotImplementedException;
@@ -51,21 +52,21 @@
 
 
 /**
- * Enumerates over candidates that satisfy a filter expression.
+ * Builds Cursors over candidates that satisfy a filter expression.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ExpressionEnumerator implements Enumerator
+public class ExpressionCursorBuilder<E> implements CursorBuilder<E>
 {
     /** The database used by this enumerator */
-    private BTreePartition db = null;
-    /** Enumerator flyweight for evaulating filter scope assertions */
-    private ScopeEnumerator scopeEnumerator;
-    /** Enumerator flyweight for evaulating filter substring assertions */
-    private SubstringEnumerator substringEnumerator;
+    private Store<E> db = null;
+    /** CursorBuilder flyweight for evaulating filter scope assertions */
+    private ScopeCursorBuilder<E> scopeEnumerator;
+    /** CursorBuilder flyweight for evaulating filter substring assertions */
+    private SubstringCursorBuilder<E> substringEnumerator;
     /** Evaluator dependency on a ExpressionEvaluator */
-    private ExpressionEvaluator evaluator;
+    private ExpressionEvaluator<E> evaluator;
 
 
     /**
@@ -74,15 +75,15 @@
      * @param db database used by this enumerator
      * @param evaluator
      */
-    public ExpressionEnumerator(BTreePartition db, AttributeTypeRegistry attributeTypeRegistry,
+    public ExpressionCursorBuilder(BTreePartition db, AttributeTypeRegistry attributeTypeRegistry,
         ExpressionEvaluator evaluator)
     {
         this.db = db;
         this.evaluator = evaluator;
 
         LeafEvaluator leafEvaluator = evaluator.getLeafEvaluator();
-        scopeEnumerator = new ScopeEnumerator( db, leafEvaluator.getScopeEvaluator() );
-        substringEnumerator = new SubstringEnumerator( db, attributeTypeRegistry, leafEvaluator.getSubstringEvaluator()
);
+        scopeEnumerator = new ScopeCursorBuilder( db, leafEvaluator.getScopeEvaluator() );
+        substringEnumerator = new SubstringCursorBuilder( db, attributeTypeRegistry, leafEvaluator.getSubstringEvaluator()
);
     }
 
 
@@ -186,7 +187,7 @@
             childEnumerations[ii] = enumerate( children.get( ii ) );
         }
 
-        return new DisjunctionEnumeration( childEnumerations );
+        return new OrCursor( childEnumerations );
     }
 
 

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionCursorBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionCursorBuilder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Mar 24 22:22:25 2008
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
(from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DisjunctionEnumeration.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DisjunctionEnumeration.java&r1=640686&r2=640704&rev=640704&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DisjunctionEnumeration.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
Mon Mar 24 22:22:25 2008
@@ -22,37 +22,36 @@
 
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.core.cursor.Cursor;
 
 import java.util.HashMap;
 import java.util.Map;
 import java.util.NoSuchElementException;
 
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 
 
 /**
  * A Cursor of Cursors performing a union on all underlying Cursors resulting
  * in the disjunction of expressions represented by the constituant child
- * Cursors. This cursor prefetches underlying Cursor values so that it can
- * comply with the defined Cursor semantics.
+ * Cursors.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DisjunctionEnumeration implements NamingEnumeration<IndexEntry>
+public class OrCursor<V,E> implements Cursor<IndexEntry<V,E>>
 {
-    /** The underlying child enumerations */
-    private final NamingEnumeration<IndexRecord>[] children;
+    /** The underlying child Cursors */
+    private final Cursor<IndexEntry<V,E>>[] children;
     
     /** LUT used to avoid returning duplicates */
     private final Map<Object, Object> candidates = new HashMap<Object, Object>();
     /** Index of current cursor used */
     private int index = 0;
     /** Candidate to return */
-    private final ForwardIndexEntry candidate = new ForwardIndexEntry();
+    private final ForwardIndexEntry<V,E> candidate = new ForwardIndexEntry<V,E>();
     /** Prefetched record returned */
-    private final ForwardIndexEntry prefetched = new ForwardIndexEntry();
+    private final ForwardIndexEntry<V,E> prefetched = new ForwardIndexEntry<V,E>();
     /** Used to determine if this enumeration has been exhausted */
     private boolean hasMore = true;
 
@@ -62,14 +61,14 @@
     // ------------------------------------------------------------------------
 
     /**
-     * Creates a DisjunctionEnumeration over a set of child NamingEnumerations.
+     * Creates a OrCursor over a set of child NamingEnumerations.
      * The returned result is the union of all underlying NamingEnumerations 
      * without duplicates.
      *
      * @param children array of child NamingInstances
      * @throws NamingException if something goes wrong
      */
-    public DisjunctionEnumeration( NamingEnumeration<IndexRecord>[] children ) throws
NamingException
+    public OrCursor( Cursor<IndexEntry<V,E>>[] children ) throws NamingException
     {
         this.children = children;
 

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Mar 24 22:22:25 2008
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeCursorBuilder.java
(from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEnumerator.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeCursorBuilder.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeCursorBuilder.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEnumerator.java&r1=640686&r2=640704&rev=640704&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEnumerator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeCursorBuilder.java
Mon Mar 24 22:22:25 2008
@@ -20,35 +20,35 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
 import javax.naming.directory.SearchControls;
 
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
-import org.apache.directory.shared.ldap.util.SingletonEnumeration;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.core.partition.impl.btree.IndexAssertionEnumeration;
 import org.apache.directory.server.core.partition.impl.btree.IndexAssertion;
+import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.cursor.SingletonCursor;
 
 
 /**
- * Enumerates candidates based on scope.
+ * Creates a Cursor which traverses candidates based on scope constraints.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ScopeEnumerator implements Enumerator
+public class ScopeCursorBuilder<E> implements CursorBuilder<String, E>
 {
     /** Database used to enumerate based on scope */
-    private BTreePartition db = null;
+    private Store<E> db = null;
     /** Filter scope expression evaluator */
-    private ScopeEvaluator evaluator = null;
+    private ScopeEvaluator<E> evaluator = null;
 
 
-    public ScopeEnumerator(BTreePartition db, ScopeEvaluator evaluator)
+    public ScopeCursorBuilder( Store<E> db, ScopeEvaluator evaluator)
     {
         this.db = db;
         this.evaluator = evaluator;
@@ -61,10 +61,10 @@
      *
      * @param node the scope node 
      * @return the candidates that are within scope
-     * @throws NamingException if any system indices fail
-     * @see Enumerator#enumerate(ExprNode)
+     * @throws Exception if any system indices fail
+     * @see CursorBuilder#enumerate(ExprNode)
      */
-    public NamingEnumeration<ForwardIndexEntry> enumerate( ExprNode node ) throws NamingException
+    public Cursor<ForwardIndexEntry<String,E>> enumerate( ExprNode node ) throws
Exception
     {
         final ScopeNode snode = ( ScopeNode ) node;
         final Long id = db.getEntryId( snode.getBaseDn() );
@@ -72,10 +72,10 @@
         switch ( snode.getScope() )
         {
             case ( SearchControls.OBJECT_SCOPE  ):
-                final ForwardIndexEntry recordForward = new ForwardIndexEntry();
+                final ForwardIndexEntry<Long,E> recordForward = new ForwardIndexEntry<String,E>();
                 recordForward.setId( id );
                 recordForward.setValue( snode.getBaseDn() );
-                return new SingletonEnumeration<ForwardIndexEntry>( recordForward );
+                return new SingletonCursor<ForwardIndexEntry<Long,E>>( recordForward
);
                 
             case ( SearchControls.ONELEVEL_SCOPE  ):
                 return enumerateChildren( snode.getBaseDn(), snode.getDerefAliases().isDerefInSearching()
);
@@ -84,7 +84,7 @@
                 return enumerateDescendants( snode );
             
             default:
-                throw new NamingException( "Unrecognized search scope!" );
+                throw new IllegalStateException( "Unrecognized search scope!" );
         }
     }
 
@@ -97,21 +97,14 @@
      * @param deref whether or not we dereference while searching
      * @return the enumeration of all entries in direct or alias extended one 
      * level scope to the base
-     * @throws NamingException if any failures occur while accessing system
+     * @throws Exception if any failures occur while accessing system
      * indices.
      */
-    private NamingEnumeration<ForwardIndexEntry> enumerateChildren( String dn, boolean
deref ) throws NamingException
+    private Cursor<IndexEntry<Long,E>> enumerateChildren( String dn, boolean
deref ) throws Exception
     {
-        Index idx = db.getHierarchyIndex();
+        Index<Long,E> idx = db.getHierarchyIndex();
         final Long id = db.getEntryId( dn );
-        try
-        {
-            final NamingEnumeration<ForwardIndexEntry> children = idx.listIndices(
id );
-        }
-        catch ( java.io.IOException e )
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
+        final Cursor<IndexEntry<Long,E>> children = idx.forwardCursor( id );
 
         /*
          * If alias dereferencing is not enabled while searching then we just
@@ -135,22 +128,14 @@
 
         // List all entries brought into one level scope at base by aliases
         idx = db.getOneAliasIndex();
-        try
-        {
-            NamingEnumeration aliasIntroduced = idx.listIndices( id );
-        }
-        catch ( java.io.IOException e )
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
+        Cursor aliasIntroduced = idx.forwardCursor( id );
 
         // Still need to use assertion enum to weed out aliases
-        NamingEnumeration nonAliasChildren = new IndexAssertionEnumeration( children, new
AssertNotAlias() );
+        Cursor nonAliasChildren = new IndexAssertionEnumeration( children, new AssertNotAlias()
);
 
         // Combine both into one enumeration
-        NamingEnumeration[] all =
-            { nonAliasChildren, aliasIntroduced };
-        return new DisjunctionEnumeration( all );
+        Cursor[] all = { nonAliasChildren, aliasIntroduced };
+        return new OrCursor( all );
     }
 
 
@@ -161,12 +146,12 @@
      * @param node the scope node
      * @return the enumeration of all entries in direct or alias extended 
      * subtree scope to the base
-     * @throws NamingException if any failures occur while accessing system
+     * @throws Exception if any failures occur while accessing system
      * indices.
      */
-    private NamingEnumeration<ForwardIndexEntry> enumerateDescendants( final ScopeNode
node ) throws NamingException
+    private Cursor<ForwardIndexEntry> enumerateDescendants( final ScopeNode node )
throws Exception
     {
-        Index idx = null;
+        Index idx;
 
         /*
          * If we do not dereference while searching then we simply return any
@@ -176,21 +161,14 @@
         {
             // Gets a NamingEnumeration over all elements
             idx = db.getNdnIndex();
-            try
-            {
-                NamingEnumeration<ForwardIndexEntry> underlying = idx.listIndices();
-            }
-            catch ( java.io.IOException e )
-            {
-                e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-            }
+            Cursor<ForwardIndexEntry> underlying = idx.forwardCursor();
             return new IndexAssertionEnumeration( underlying, new AssertDescendant( node
) );
         }
 
         // Create an assertion to assert or evaluate an expression
         IndexAssertion assertion = new IndexAssertion()
         {
-            public boolean assertCandidate( IndexEntry rec ) throws NamingException
+            public boolean assertCandidate( IndexEntry rec ) throws Exception
             {
                 return evaluator.evaluate( node, rec );
             }
@@ -198,17 +176,11 @@
 
         // Gets a NamingEnumeration over all elements
         idx = db.getNdnIndex();
-        try
-        {
-            NamingEnumeration<ForwardIndexEntry> underlying = idx.listIndices();
-        }
-        catch ( java.io.IOException e )
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
+        Cursor<ForwardIndexEntry> underlying = idx.forwardCursor();
         return new IndexAssertionEnumeration( underlying, assertion );
     }
 
+
     /**
      * Asserts an entry is a descendant.
      */
@@ -233,15 +205,16 @@
          * Returns true if the candidate with id is a descendant of the base, 
          * false otherwise.
          * 
-         * @see org.apache.directory.server.core.partition.impl.btree.IndexAssertion#assertCandidate(org.apache.directory.server.xdbm.IndexEntry)
+         * @see IndexAssertion#assertCandidate(IndexEntry)
          */
-        public boolean assertCandidate( IndexEntry entry ) throws NamingException
+        public boolean assertCandidate( IndexEntry entry ) throws Exception
         {
-            String dn = db.getEntryDn( (Long) entry.getId() );
+            String dn = db.getEntryDn( entry.getId() );
             return dn.endsWith( scope.getBaseDn() );
         }
     }
 
+
     /**
      * Asserts an entry is NOT an alias.
      */
@@ -252,23 +225,9 @@
          * 
          * @see IndexAssertion#assertCandidate(IndexEntry)
          */
-        public boolean assertCandidate( IndexEntry entry ) throws NamingException
+        public boolean assertCandidate( IndexEntry entry ) throws Exception
         {
-            Index aliasIdx = db.getAliasIndex();
-
-            try
-            {
-                if ( null == aliasIdx.reverseLookup( entry.getId() ) )
-                {
-                    return true;
-                }
-            }
-            catch ( java.io.IOException e )
-            {
-                e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-            }
-
-            return false;
+            return null == db.getAliasIndex().reverseLookup( entry.getId() );
         }
     }
 }

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeCursorBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeCursorBuilder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Mar 24 22:22:25 2008
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEvaluator.java?rev=640704&r1=640703&r2=640704&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ScopeEvaluator.java
Mon Mar 24 22:22:25 2008
@@ -20,7 +20,6 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import javax.naming.NamingException;
 import javax.naming.directory.SearchControls;
 
 import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -28,6 +27,7 @@
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.Store;
 
 
 /**
@@ -36,10 +36,10 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ScopeEvaluator implements Evaluator
+public class ScopeEvaluator<E> implements Evaluator<E>
 {
     /** Database used to evaluate scope with */
-    private BTreePartition db;
+    private Store<E> db;
 
 
     /**
@@ -47,7 +47,7 @@
      *
      * @param db the database used to evaluate scope node
      */
-    public ScopeEvaluator(BTreePartition db)
+    public ScopeEvaluator( Store<E> db )
     {
         this.db = db;
     }
@@ -56,24 +56,24 @@
     /**
      * @see Evaluator#evaluate(ExprNode, org.apache.directory.server.xdbm.IndexEntry)
      */
-    public boolean evaluate( ExprNode node, IndexEntry entry ) throws NamingException
+    public boolean evaluate( ExprNode node, IndexEntry<Long,E> entry ) throws Exception
     {
         ScopeNode snode = ( ScopeNode ) node;
 
         switch ( snode.getScope() )
         {
             case ( SearchControls.OBJECT_SCOPE  ):
-                String dn = db.getEntryDn( (Long) entry.getId() );
+                String dn = db.getEntryDn( entry.getId() );
                 return dn.equals( snode.getBaseDn() );
                 
             case ( SearchControls.ONELEVEL_SCOPE  ):
-                return assertOneLevelScope( snode, (Long) entry.getId() );
+                return assertOneLevelScope( snode, entry.getId() );
             
             case ( SearchControls.SUBTREE_SCOPE  ):
-                return assertSubtreeScope( snode, (Long) entry.getId() );
+                return assertSubtreeScope( snode, entry.getId() );
             
             default:
-                throw new NamingException( "Unrecognized search scope!" );
+                throw new IllegalStateException( "Unrecognized search scope!" );
         }
     }
 
@@ -86,13 +86,13 @@
      * @param id the candidate to assert which can be any db entry's id
      * @return true if the candidate is within one level scope whether or not
      * alias dereferencing is enabled.
-     * @throws NamingException if the index lookups fail.
+     * @throws Exception if the index lookups fail.
      */
-    public boolean assertSubtreeScope( final ScopeNode node, final Long id ) throws NamingException
+    public boolean assertSubtreeScope( final ScopeNode node, final Long id ) throws Exception
     {
         String dn = db.getEntryDn( id );
         AliasDerefMode mode = node.getDerefAliases();
-        Object baseId = db.getEntryId( node.getBaseDn() );
+        Long baseId = db.getEntryId( node.getBaseDn() );
         boolean isDescendant = dn.endsWith( node.getBaseDn() );
 
         /*
@@ -112,16 +112,9 @@
          */
         Index idx = db.getAliasIndex();
 
-        try
+        if ( null != idx.reverseLookup( id ) )
         {
-            if ( null != idx.reverseLookup( id ) )
-            {
-                return false;
-            }
-        }
-        catch ( java.io.IOException e )
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
+            return false;
         }
 
         /*
@@ -146,16 +139,7 @@
          * the lookup returns true accepting the candidate.  Otherwise the 
          * candidate is rejected with a false return because it is not in scope.
          */
-        idx = db.getSubAliasIndex();
-
-        try
-        {
-            return idx.hasValue( baseId, id );
-        }
-        catch ( java.io.IOException e )
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
+        return db.getSubAliasIndex().has( baseId, id );
     }
 
 
@@ -167,21 +151,14 @@
      * @param id the candidate to assert which can be any db entry's id 
      * @return true if the candidate is within one level scope whether or not
      * alias dereferencing is enabled.
-     * @throws NamingException if the index lookups fail.
+     * @throws Exception if the index lookups fail.
      */
-    public boolean assertOneLevelScope( final ScopeNode node, final Long id ) throws NamingException
+    public boolean assertOneLevelScope( final ScopeNode node, final Long id ) throws Exception
     {
         AliasDerefMode mode = node.getDerefAliases();
-        Object baseId = db.getEntryId( node.getBaseDn() );
-        Index idx = db.getHierarchyIndex();
-        try
-        {
-            boolean isChild = idx.hasValue( baseId, id );
-        }
-        catch ( java.io.IOException e )
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
+        Long baseId = db.getEntryId( node.getBaseDn() );
+        Index<Long,E> idx = db.getHierarchyIndex();
+        boolean isChild = idx.has( baseId, id );
 
         /*
          * The candidate id could be any entry in the db.  If search 
@@ -198,18 +175,11 @@
          * candidate id is an alias, if so we reject it since aliases should
          * not be returned.
          */
-        idx = db.getAliasIndex();
+        Index<String,E> aliasIndex= db.getAliasIndex();
 
-        try
+        if ( null != aliasIndex.reverseLookup( id ) )
         {
-            if ( null != idx.reverseLookup( id ) )
-            {
-                return false;
-            }
-        }
-        catch ( java.io.IOException e )
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
+            return false;
         }
 
         /*
@@ -231,15 +201,6 @@
          * the lookup returns true accepting the candidate.  Otherwise the 
          * candidate is rejected with a false return because it is not in scope.
          */
-        idx = db.getOneAliasIndex();
-
-        try
-        {
-            return idx.hasValue( baseId, id );
-        }
-        catch ( java.io.IOException e )
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
+        return db.getOneAliasIndex().has( baseId, id );
     }
 }

Copied: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursorBuilder.java
(from r640686, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEnumerator.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursorBuilder.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursorBuilder.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEnumerator.java&r1=640686&r2=640704&rev=640704&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEnumerator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursorBuilder.java
Mon Mar 24 22:22:25 2008
@@ -21,35 +21,33 @@
 
 
 import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
 
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.core.partition.impl.btree.IndexAssertion;
 import org.apache.directory.server.core.partition.impl.btree.IndexAssertionEnumeration;
+import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.SubstringNode;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.NotImplementedException;
 
 
 /**
- * Enumerator that creates a NamingEnumeration over the set of candidates that 
+ * CursorBuilder that creates a NamingEnumeration over the set of candidates that
  * satisfy a substring filter expression.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class SubstringEnumerator implements Enumerator
+public class SubstringCursorBuilder<V,E> implements CursorBuilder<V, E>
 {
     /** Database used */
-    private final BTreePartition db;
+    private final Store<E> db;
     
     /** Evaluator used is an Avalon dependent object */
     private final SubstringEvaluator evaluator;
@@ -59,13 +57,15 @@
 
 
     /**
-     * Creates a SubstringEnumerator for a database.
+     * Creates a SubstringCursorBuilder for a database.
      *
      * @param db the database
+     * @param attributeTypeRegistry the attributeType registry
      * @param evaluator a substring evaluator
      */
-    public SubstringEnumerator(BTreePartition db, AttributeTypeRegistry attributeTypeRegistry,
-        SubstringEvaluator evaluator)
+    public SubstringCursorBuilder( Store<E> db,
+                                   AttributeTypeRegistry attributeTypeRegistry,
+                                   SubstringEvaluator evaluator)
     {
         this.db = db;
         this.evaluator = evaluator;
@@ -74,17 +74,17 @@
 
 
     // ------------------------------------------------------------------------
-    // SubstringEnumerator Methods
+    // SubstringCursorBuilder Methods
     // ------------------------------------------------------------------------
 
     /**
-     * @see Enumerator#enumerate(
+     * @see CursorBuilder#enumerate(
      * org.apache.directory.shared.ldap.filter.ExprNode)
      */
-    public NamingEnumeration<ForwardIndexEntry> enumerate( final ExprNode node ) throws
NamingException
+    public Cursor<IndexEntry<V,E>> enumerate( final ExprNode node ) throws Exception
     {
-        Pattern regex = null;
-        Index idx = null;
+        Pattern     regex;
+        Index idx;
         final SubstringNode snode = ( SubstringNode ) node;
         AttributeType type = attributeTypeRegistry.lookup( snode.getAttribute() );
 
@@ -103,16 +103,7 @@
              * Build out regex in this block so we do not do it twice in the
              * evaluator if there is no index on the attribute of the substr ava
              */
-            try
-            {
-                regex = snode.getRegex( normalizer );
-            }
-            catch ( PatternSyntaxException e )
-            {
-                NamingException ne = new NamingException( "SubstringNode '" + node + "' had
incorrect syntax" );
-                ne.setRootCause( e );
-                throw ne;
-            }
+            regex = snode.getRegex( normalizer );
 
             /*
              * Get the user index and return an index enumeration using the the
@@ -122,25 +113,17 @@
             idx = db.getUserIndex( snode.getAttribute() );
             if ( null == snode.getInitial() )
             {
-                try
-                {
-                    return idx.listIndices( regex );
-                }
-                catch ( java.io.IOException e )
-                {
-                    e.printStackTrace();  //To change body of catch statement use File |
Settings | File Templates.
-                }
+                // @TODO NEED REGULAR EXPRESSION CURSOR HERE
+                // return idx.forwardCursor( regex );
+                
+                throw new NotImplementedException( "TODO NEED REGULAR EXPRESSION CURSOR HERE"
);
             }
             else
             {
-                try
-                {
-                    return idx.listIndices( regex, snode.getInitial() );
-                }
-                catch ( java.io.IOException e )
-                {
-                    e.printStackTrace();  //To change body of catch statement use File |
Settings | File Templates.
-                }
+                // @TODO NEED REGULAR EXPRESSION CURSOR HERE
+//                    return idx.forwardCursor( regex, snode.getInitial() );
+
+                throw new NotImplementedException( "TODO NEED REGULAR EXPRESSION CURSOR HERE"
);
             }
         }
 
@@ -153,18 +136,11 @@
          * underlying enumeration.  An evaluator in an assertion is used to 
          * constrain the result set.
          */
-        try
-        {
-            NamingEnumeration<ForwardIndexEntry> underlying = db.getNdnIndex().listIndices();
-        }
-        catch ( java.io.IOException e )
-        {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
+        Cursor<IndexEntry<String,E>> underlying = db.getNdnIndex().forwardCursor();
 
         IndexAssertion assertion = new IndexAssertion()
         {
-            public boolean assertCandidate( final IndexEntry entry ) throws NamingException
+            public boolean assertCandidate( final IndexEntry entry ) throws Exception
             {
                 return evaluator.evaluate( node, entry );
             }

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursorBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursorBuilder.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Mar 24 22:22:25 2008
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id



Mime
View raw message