directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r650006 - in /directory/sandbox/akarasulu/bigbang: apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/ apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ apacheds/jdbm-store/src/tes...
Date Mon, 21 Apr 2008 02:37:58 GMT
Author: akarasulu
Date: Sun Apr 20 19:37:56 2008
New Revision: 650006

URL: http://svn.apache.org/viewvc?rev=650006&view=rev
Log:
changes to Index interface and more test cases ...

 o started using Indices for evaluators when I realized we need to expose both 
   forward and reverse lookups in order to efficiently satisfy certain 
   conditions
 o added more schema constants
 o added tests for LessOrEqEvaluator
 o changed and added interface methods for index for both forward and reverse 
   lookups with greater or less than or equal to tests as well as the has method
   which has been replaced by a pair of forward() and reverse() methods


Added:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
    directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java
Sun Apr 20 19:37:56 2008
@@ -192,13 +192,40 @@
     Cursor<Long> forwardValueCursor( K key ) throws Exception;
 
 
-    boolean has( K attrVal, Long id ) throws Exception;
+    boolean forward( K attrVal ) throws Exception;
 
 
-    boolean hasGreaterOrEqual( K attrVal, Long id ) throws Exception;
+    boolean forward( K attrVal, Long id ) throws Exception;
 
 
-    boolean hasLessOrEqual( K attrVal, Long id ) throws Exception;
+    boolean reverse( Long id ) throws Exception;
+
+
+    boolean reverse( Long id, K attrVal ) throws Exception;
+
+
+    boolean forwardGreaterOrEq( K attrVal ) throws Exception;
+
+
+    boolean forwardGreaterOrEq( K attrVal, Long id ) throws Exception;
+
+
+    boolean reverseGreaterOrEq( Long id ) throws Exception;
+
+
+    boolean reverseGreaterOrEq( Long id, K attrVal ) throws Exception;
+
+
+    boolean forwardLessOrEq( K attrVal ) throws Exception;
+
+
+    boolean forwardLessOrEq( K attrVal, Long id ) throws Exception;
+
+
+    boolean reverseLessOrEq( Long id ) throws Exception;
+
+
+    boolean reverseLessOrEq( Long id, K attrVal ) throws Exception;
 
 
     void close() throws Exception;

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
Sun Apr 20 19:37:56 2008
@@ -508,29 +508,110 @@
 
     
     /**
-     * @see Index#has(Object,Long)
+     * @see Index#forward(Object)
      */
-    public boolean has( K attrVal, Long id ) throws Exception
+    public boolean forward( K attrVal ) throws Exception
+    {
+        return forward.has( getNormalized( attrVal ) );
+    }
+
+
+    /**
+     * @see Index#forward(Object,Long)
+     */
+    public boolean forward( K attrVal, Long id ) throws Exception
+    {
+        return forward.has( getNormalized( attrVal ), id );
+    }
+
+
+    /**
+     * @see Index#reverse(Long)
+     */
+    public boolean reverse( Long id ) throws Exception
+    {
+        return reverse.has( id );
+    }
+
+
+    /**
+     * @see Index#reverse(Long,Object)
+     */
+    public boolean reverse( Long id, K attrVal ) throws Exception
     {
         return forward.has( getNormalized( attrVal ), id );
     }
 
 
     /**
-     * @see org.apache.directory.server.xdbm.Index#hasGreaterOrEqual(Object, Long)
+     * @see org.apache.directory.server.xdbm.Index#forwardGreaterOrEq(Object)
+     */
+    public boolean forwardGreaterOrEq( K attrVal ) throws Exception
+    {
+        return forward.hasGreaterOrEqual( getNormalized( attrVal ) );
+    }
+
+
+    /**
+     * @see org.apache.directory.server.xdbm.Index#forwardGreaterOrEq(Object, Long)
      */
-    public boolean hasGreaterOrEqual( K attrVal, Long id ) throws Exception
+    public boolean forwardGreaterOrEq( K attrVal, Long id ) throws Exception
     {
         return forward.hasGreaterOrEqual( getNormalized( attrVal ), id );
     }
 
 
     /**
-     * @see org.apache.directory.server.xdbm.Index#hasLessOrEqual(Object, Long)
+     * @see org.apache.directory.server.xdbm.Index#forwardLessOrEq(Object)
      */
-    public boolean hasLessOrEqual( K attrVal, Long id ) throws Exception
+    public boolean forwardLessOrEq( K attrVal ) throws Exception
+    {
+        return forward.hasLessOrEqual( getNormalized( attrVal ) );
+    }
+
+
+    /**
+     * @see org.apache.directory.server.xdbm.Index#forwardLessOrEq(Object, Long)
+     */
+    public boolean forwardLessOrEq( K attrVal, Long id ) throws Exception
     {
         return forward.hasLessOrEqual( getNormalized( attrVal ), id );
+    }
+
+
+    /**
+     * @see org.apache.directory.server.xdbm.Index#reverseGreaterOrEq(Long)
+     */
+    public boolean reverseGreaterOrEq( Long id ) throws Exception
+    {
+        return reverse.hasGreaterOrEqual( id );
+    }
+
+
+    /**
+     * @see org.apache.directory.server.xdbm.Index#reverseGreaterOrEq(Long,Object)
+     */
+    public boolean reverseGreaterOrEq( Long id, K attrVal ) throws Exception
+    {
+        return reverse.hasGreaterOrEqual( id, getNormalized( attrVal ) );
+    }
+
+
+    /**
+     * @see org.apache.directory.server.xdbm.Index#reverseLessOrEq(Long)
+     */
+    public boolean reverseLessOrEq( Long id ) throws Exception
+    {
+        return reverse.hasLessOrEqual( id );
+    }
+
+
+    /**
+     * @see org.apache.directory.server.xdbm.Index#reverseLessOrEq(Long,Object)
+     */
+    public boolean reverseLessOrEq( Long id, K attrVal ) throws Exception
+    {
+        return reverse.hasLessOrEqual( id, getNormalized( attrVal ) );
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
Sun Apr 20 19:37:56 2008
@@ -1256,7 +1256,7 @@
             idx.add( ServerEntryUtils.toAttributeImpl( mods ), id );
 
             // If the attr didn't exist for this id add it to existance index
-            if ( !existanceIdx.has( modsOid, id ) )
+            if ( !existanceIdx.forward( modsOid, id ) )
             {
                 existanceIdx.add( modsOid, id );
             }
@@ -1541,7 +1541,7 @@
             idx.add( newRdnValue, id );
 
             // Make sure the altered entry shows the existance of the new attrib
-            if ( !existanceIdx.has( newRdn.getNormType(), id ) )
+            if ( !existanceIdx.forward( newRdn.getNormType(), id ) )
             {
                 existanceIdx.add( newRdn.getNormType(), id );
             }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
Sun Apr 20 19:37:56 2008
@@ -329,57 +329,57 @@
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
         assertNull( idx.reverseLookup( 0L ) );
-        assertFalse( idx.hasGreaterOrEqual( "foo", 0L ) );
-        assertFalse( idx.hasGreaterOrEqual( "foo", -24L ) );
-        assertFalse( idx.hasGreaterOrEqual( "foo", 24L ) );
-        assertFalse( idx.hasLessOrEqual( "foo", 0L ) );
-        assertFalse( idx.hasLessOrEqual( "foo", 24L ) );
-        assertFalse( idx.hasLessOrEqual( "foo", -24L ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", 0L ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", -24L ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", 24L ) );
+        assertFalse( idx.forwardLessOrEq( "foo", 0L ) );
+        assertFalse( idx.forwardLessOrEq( "foo", 24L ) );
+        assertFalse( idx.forwardLessOrEq( "foo", -24L ) );
 
         idx.add( "foo", 0L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
         assertEquals( "foo", idx.reverseLookup( 0L ) );
-        assertTrue( idx.has( "foo", 0L ) );
-        assertTrue( idx.hasGreaterOrEqual( "foo", 0L ) );
-        assertTrue( idx.hasGreaterOrEqual( "foo", -1L ) );
-        assertFalse( idx.hasGreaterOrEqual( "foo", 1L ) );
-        assertTrue( idx.hasLessOrEqual( "foo", 0L ) );
-        assertTrue( idx.hasLessOrEqual( "foo", 1L ) );
-        assertFalse( idx.hasLessOrEqual( "foo", -1L ) );
+        assertTrue( idx.forward( "foo", 0L ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", 1L ) );
+        assertTrue( idx.forwardLessOrEq( "foo", 0L ) );
+        assertTrue( idx.forwardLessOrEq( "foo", 1L ) );
+        assertFalse( idx.forwardLessOrEq( "foo", -1L ) );
 
         idx.add( "foo", 1L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
         assertEquals( "foo", idx.reverseLookup( 0L ) );
         assertEquals( "foo", idx.reverseLookup( 1L ) );
-        assertTrue( idx.has( "foo", 0L ) );
-        assertTrue( idx.has( "foo", 1L ) );
-        assertTrue( idx.hasGreaterOrEqual( "foo", 0L ) );
-        assertTrue( idx.hasGreaterOrEqual( "foo", 1L ) );
-        assertTrue( idx.hasGreaterOrEqual( "foo", -1L ) );
-        assertFalse( idx.hasGreaterOrEqual( "foo", 2L ) );
-        assertTrue( idx.hasLessOrEqual( "foo", 0L ) );
-        assertTrue( idx.hasLessOrEqual( "foo", 1L ) );
-        assertTrue( idx.hasLessOrEqual( "foo", 2L ) );
-        assertFalse( idx.hasLessOrEqual( "foo", -1L ) );
+        assertTrue( idx.forward( "foo", 0L ) );
+        assertTrue( idx.forward( "foo", 1L ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", 1L ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", 2L ) );
+        assertTrue( idx.forwardLessOrEq( "foo", 0L ) );
+        assertTrue( idx.forwardLessOrEq( "foo", 1L ) );
+        assertTrue( idx.forwardLessOrEq( "foo", 2L ) );
+        assertFalse( idx.forwardLessOrEq( "foo", -1L ) );
 
         idx.add( "bar", 0L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
         assertEquals( "bar", idx.reverseLookup( 0L ) );  // reverse lookup returns first
val
-        assertTrue( idx.has( "bar", 0L ) ); 
-        assertTrue( idx.has( "foo", 0L ) );
-        assertTrue( idx.has( "foo", 1L ) );
-        assertTrue( idx.hasGreaterOrEqual( "bar", 0L ) );
-        assertTrue( idx.hasGreaterOrEqual( "foo", 0L ) );
-        assertTrue( idx.hasGreaterOrEqual( "foo", 1L ) );
-        assertTrue( idx.hasGreaterOrEqual( "foo", -1L ) );
-        assertFalse( idx.hasGreaterOrEqual( "foo", 2L ) );
-        assertFalse( idx.hasGreaterOrEqual( "bar", 1L ) );
-        assertTrue( idx.hasLessOrEqual( "bar", 0L ) );
-        assertTrue( idx.hasLessOrEqual( "foo", 0L ) );
-        assertTrue( idx.hasLessOrEqual( "foo", 1L ) );
-        assertTrue( idx.hasLessOrEqual( "foo", 2L ) );
-        assertFalse( idx.hasLessOrEqual( "foo", -1L ) );
-        assertFalse( idx.hasLessOrEqual( "bar", -1L ) );
+        assertTrue( idx.forward( "bar", 0L ) );
+        assertTrue( idx.forward( "foo", 0L ) );
+        assertTrue( idx.forward( "foo", 1L ) );
+        assertTrue( idx.forwardGreaterOrEq( "bar", 0L ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", 1L ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", 2L ) );
+        assertFalse( idx.forwardGreaterOrEq( "bar", 1L ) );
+        assertTrue( idx.forwardLessOrEq( "bar", 0L ) );
+        assertTrue( idx.forwardLessOrEq( "foo", 0L ) );
+        assertTrue( idx.forwardLessOrEq( "foo", 1L ) );
+        assertTrue( idx.forwardLessOrEq( "foo", 2L ) );
+        assertFalse( idx.forwardLessOrEq( "foo", -1L ) );
+        assertFalse( idx.forwardLessOrEq( "bar", -1L ) );
     }
 
 
@@ -412,8 +412,8 @@
 
         idx.drop( 0L );
         assertEquals( "foo", idx.reverseLookup( 1L ) );
-        assertFalse( idx.has( "bar", 0L ) );
-        assertFalse( idx.has( "foo", 0L ) );
+        assertFalse( idx.forward( "bar", 0L ) );
+        assertFalse( idx.forward( "foo", 0L ) );
 
         idx.drop( 1L );
         assertNull( idx.forwardLookup( "foo" ) );
@@ -455,12 +455,12 @@
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
         assertEquals( "foo", idx.reverseLookup( 0L ) );
         assertEquals( "foo", idx.reverseLookup( 1L ) );
-        assertFalse( idx.has( "bar", 0L ) );
+        assertFalse( idx.forward( "bar", 0L ) );
 
         idx.drop( "foo", 0L );
         assertEquals( 1L, ( long ) idx.forwardLookup( "foo" ) );
         assertEquals( "foo", idx.reverseLookup( 1L ) );
-        assertFalse( idx.has( "foo", 0L ) );
+        assertFalse( idx.forward( "foo", 0L ) );
 
         idx.drop( "foo", 1L );
         assertNull( idx.forwardLookup( "foo" ) );

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Sun Apr 20 19:37:56 2008
@@ -500,49 +500,107 @@
                 return null;
             }
 
-            public AttributeType getAttribute()
+
+            public boolean forward( Object attrVal ) throws Exception
             {
-                return null;
+                return false;
             }
 
-            public String getAttributeId()
+
+            public boolean forward( Object attrVal, Long id ) throws Exception
             {
-                return "ou";
+                return false;
             }
 
-            public int getCacheSize()
+
+            public boolean reverse( Long id ) throws Exception
             {
-                return 10;
+                return false;
             }
 
-            public Object getNormalized( Object attrVal ) throws Exception
+
+            public boolean reverse( Long id, Object attrVal ) throws Exception
             {
-                return null;
+                return false;
             }
 
-            public File getWkDirPath()
+
+            public boolean forwardGreaterOrEq( Object attrVal ) throws Exception
             {
-                return new File(".");
+                return false;
             }
 
-            public int greaterThanCount( Object attrVal ) throws Exception
+
+            public boolean forwardGreaterOrEq( Object attrVal, Long id ) throws Exception
             {
-                return 0;
+                return false;
+            }
+
+
+            public boolean reverseGreaterOrEq( Long id ) throws Exception
+            {
+                return false;
             }
 
-            public boolean has( Object attrVal, Long id ) throws Exception
+
+            public boolean reverseGreaterOrEq( Long id, Object attrVal ) throws Exception
             {
                 return false;
             }
 
-            public boolean hasGreaterOrEqual( Object attrVal, Long id ) throws Exception
+
+            public boolean forwardLessOrEq( Object attrVal ) throws Exception
             {
                 return false;
             }
 
-            public boolean hasLessOrEqual( Object attrVal, Long id ) throws Exception
+
+            public boolean forwardLessOrEq( Object attrVal, Long id ) throws Exception
+            {
+                return false;
+            }
+
+
+            public boolean reverseLessOrEq( Long id ) throws Exception
             {
                 return false;
+            }
+
+
+            public boolean reverseLessOrEq( Long id, Object attrVal ) throws Exception
+            {
+                return false;
+            }
+
+
+            public AttributeType getAttribute()
+            {
+                return null;
+            }
+
+            public String getAttributeId()
+            {
+                return "ou";
+            }
+
+            public int getCacheSize()
+            {
+                return 10;
+            }
+
+            public Object getNormalized( Object attrVal ) throws Exception
+            {
+                return null;
+            }
+
+            public File getWkDirPath()
+            {
+                return new File(".");
+            }
+
+            public int greaterThanCount( Object attrVal ) throws Exception
+            {
+                return 0;
             }
 
             public boolean isCountExact()

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
Sun Apr 20 19:37:56 2008
@@ -99,7 +99,7 @@
     {
         if ( idx != null )
         {
-            return idx.has( ( Number ) indexEntry.getValue(), indexEntry.getId() );
+            return idx.forward( ( Number ) indexEntry.getValue(), indexEntry.getId() );
         }
 
         Attributes entry = indexEntry.getObject();

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
Sun Apr 20 19:37:56 2008
@@ -99,7 +99,7 @@
     {
         if ( idx != null )
         {
-            return idx.has( ( Number ) indexEntry.getValue(), indexEntry.getId() );
+            return idx.forward( ( Number ) indexEntry.getValue(), indexEntry.getId() );
         }
 
         Attributes entry = indexEntry.getObject();

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
Sun Apr 20 19:37:56 2008
@@ -125,7 +125,7 @@
     {
         if ( idx != null )
         {
-            return idx.hasGreaterOrEqual( ( Number ) indexEntry.getValue(), indexEntry.getId()
);
+            return idx.forwardGreaterOrEq( ( Number ) indexEntry.getValue(), indexEntry.getId()
);
         }
 
         Attributes entry = indexEntry.getObject();

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
Sun Apr 20 19:37:56 2008
@@ -52,7 +52,7 @@
     private final AttributeType type;
     private final Normalizer normalizer;
     private final Comparator comparator;
-    private final Index<Number,Attributes> idx;
+    private final Index<Object,Attributes> idx;
 
 
     public LessEqEvaluator( LessEqNode node, Store<Attributes> db, Registries registries
)
@@ -125,7 +125,7 @@
     {
         if ( idx != null )
         {
-            return idx.hasLessOrEqual( ( Number ) indexEntry.getValue(), indexEntry.getId()
);
+            return idx.reverseLessOrEq( indexEntry.getId(), node.getValue() );
         }
 
         Attributes entry = indexEntry.getObject();

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
Sun Apr 20 19:37:56 2008
@@ -82,7 +82,7 @@
      */
     public boolean evaluate( IndexEntry<?,E> candidate ) throws Exception
     {
-        boolean isChild = db.getOneLevelIndex().has( baseId, candidate.getId() );
+        boolean isChild = db.getOneLevelIndex().forward( baseId, candidate.getId() );
 
         /*
          * The candidate id could be any entry in the db.  If search
@@ -123,7 +123,7 @@
          * the lookup returns true accepting the candidate.  Otherwise the
          * candidate is rejected with a false return because it is not in scope.
          */
-        return db.getOneAliasIndex().has( baseId, candidate.getId() );
+        return db.getOneAliasIndex().forward( baseId, candidate.getId() );
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
Sun Apr 20 19:37:56 2008
@@ -84,7 +84,7 @@
     {
         if ( idx != null )
         {
-            return idx.has( type.getOid(), indexEntry.getId() );
+            return idx.forward( type.getOid(), indexEntry.getId() );
         }
 
         Attributes entry = indexEntry.getObject();

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
Sun Apr 20 19:37:56 2008
@@ -84,7 +84,7 @@
      */
     public boolean evaluate( IndexEntry<?,E> candidate ) throws Exception
     {
-        boolean isDescendant = db.getSubLevelIndex().has( baseId, candidate.getId() );
+        boolean isDescendant = db.getSubLevelIndex().forward( baseId, candidate.getId() );
 
         /*
          * The candidate id could be any entry in the db.  If search
@@ -128,7 +128,7 @@
          * the lookup returns true accepting the candidate.  Otherwise the
          * candidate is rejected with a false return because it is not in scope.
          */
-        return db.getSubAliasIndex().has( baseId, candidate.getId() );
+        return db.getSubAliasIndex().forward( baseId, candidate.getId() );
     }
 
 

Added: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java?rev=650006&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
(added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
Sun Apr 20 19:37:56 2008
@@ -0,0 +1,159 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.xdbm.search.impl;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.ForwardIndexEntry;
+import org.apache.directory.server.xdbm.tools.StoreUtils;
+import org.apache.directory.server.schema.registries.*;
+import org.apache.directory.server.schema.bootstrap.*;
+import org.apache.directory.server.schema.SerializableComparator;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.filter.LessEqNode;
+import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;import static org.junit.Assert.assertTrue;import static org.junit.Assert.assertFalse;
+
+import javax.naming.directory.Attributes;
+import java.io.File;
+import java.util.Set;
+import java.util.HashSet;
+
+
+/**
+ * Tests the LessEqEvaluator and LessEqCursor classes for correct operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $$Rev$$
+ */
+public class LessEqTest
+{
+    public static final Logger LOG = LoggerFactory.getLogger( OneLevelScopeTest.class );
+
+
+    File wkdir;
+    Store<Attributes> store;
+    Registries registries = null;
+    AttributeTypeRegistry attributeRegistry;
+
+
+    public LessEqTest() throws Exception
+    {
+        // setup the standard registries
+        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
+        OidRegistry oidRegistry = new DefaultOidRegistry();
+        registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
+        SerializableComparator.setRegistry( registries.getComparatorRegistry() );
+
+        // load essential bootstrap schemas
+        Set<Schema> bootstrapSchemas = new HashSet<Schema>();
+        bootstrapSchemas.add( new ApachemetaSchema() );
+        bootstrapSchemas.add( new ApacheSchema() );
+        bootstrapSchemas.add( new CoreSchema() );
+        bootstrapSchemas.add( new SystemSchema() );
+        bootstrapSchemas.add( new CollectiveSchema() );
+        loader.loadWithDependencies( bootstrapSchemas, registries );
+        attributeRegistry = registries.getAttributeTypeRegistry();
+    }
+
+
+    @Before
+    public void createStore() throws Exception
+    {
+        destryStore();
+
+        // setup the working directory for the store
+        wkdir = File.createTempFile( getClass().getSimpleName(), "db" );
+        wkdir.delete();
+        wkdir = new File( wkdir.getParentFile(), getClass().getSimpleName() );
+        wkdir.mkdirs();
+
+        // initialize the store
+        store = new JdbmStore<Attributes>();
+        store.setName( "example" );
+        store.setCacheSize( 10 );
+        store.setWorkingDirectory( wkdir );
+        store.setSyncOnWrite( false );
+
+        store.addIndex( new JdbmIndex( SchemaConstants.OU_AT_OID ) );
+        store.addIndex( new JdbmIndex( SchemaConstants.CN_AT_OID ) );
+        store.addIndex( new JdbmIndex( SchemaConstants.POSTALCODE_AT_OID ) );
+
+        StoreUtils.loadExampleData( store, registries );
+        LOG.debug( "Created new store" );
+    }
+
+
+    @After
+    public void destryStore() throws Exception
+    {
+        if ( store != null )
+        {
+            store.destroy();
+        }
+
+        store = null;
+        if ( wkdir != null )
+        {
+            FileUtils.deleteDirectory( wkdir );
+        }
+
+        wkdir = null;
+    }
+
+
+    @Test
+    public void testEvaluator() throws Exception
+    {
+        LessEqNode node = new LessEqNode( SchemaConstants.POSTALCODE_AT_OID, "3" );
+        LessEqEvaluator evaluator = new LessEqEvaluator( node, store, registries );
+        ForwardIndexEntry<String,Attributes> indexEntry = new ForwardIndexEntry<String,Attributes>();
+
+        indexEntry.setId( 1L );
+        assertTrue( evaluator.evaluate( indexEntry ) );
+
+        indexEntry.setId( 4L );
+        assertTrue( evaluator.evaluate( indexEntry ) );
+
+        indexEntry.setId( 5L );
+        assertTrue( evaluator.evaluate( indexEntry ) );
+
+        indexEntry.setId( 6L );
+        assertFalse( evaluator.evaluate( indexEntry ) );
+
+        indexEntry.setId( 7L );
+        assertFalse( evaluator.evaluate( indexEntry ) );
+
+        indexEntry.setId( 8L );
+        assertFalse( evaluator.evaluate( indexEntry ) );
+
+        indexEntry.setId( 9L );
+        assertFalse( evaluator.evaluate( indexEntry ) );
+
+        indexEntry.setId( 10L );
+        assertFalse( evaluator.evaluate( indexEntry ) );
+    }
+}

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
Sun Apr 20 19:37:56 2008
@@ -67,6 +67,8 @@
         DefaultServerEntry contextEntry = new DefaultServerEntry( registries, new LdapDN(
"o=Good Times Co." ) );
         contextEntry.add( "objectClass", "organization" );
         contextEntry.add( "o", "Good Times Co." );
+        contextEntry.add( "postalCode", "1" );
+        contextEntry.add( "postOfficeBox", "1" );
         store.setContextEntry( contextEntry );
         
         AttributeTypeRegistry attributeRegistry = registries.getAttributeTypeRegistry();
@@ -79,6 +81,8 @@
         DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Sales" );
+        entry.add( "postalCode", "1" );
+        entry.add( "postOfficeBox", "1" );
         store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
 
         // Entry #3
@@ -87,6 +91,8 @@
         entry = new DefaultServerEntry( registries, dn );
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Board of Directors" );
+        entry.add( "postalCode", "1" );
+        entry.add( "postOfficeBox", "1" );
         store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
         
         // Entry #4
@@ -95,6 +101,8 @@
         entry = new DefaultServerEntry( registries, dn );
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Engineering" );
+        entry.add( "postalCode", "2" );
+        entry.add( "postOfficeBox", "2" );
         store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
         
         // Entry #5
@@ -105,6 +113,8 @@
         entry.add( "ou", "Sales" );
         entry.add( "cn", "JOhnny WAlkeR");
         entry.add( "sn", "WAlkeR");
+        entry.add( "postalCode", "3" );
+        entry.add( "postOfficeBox", "3" );
         store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
         
         // Entry #6
@@ -115,6 +125,8 @@
         entry.add( "ou", "Sales" );
         entry.add( "cn",  "JIM BEAN");
         entry.add( "surName", "BEAN");
+        entry.add( "postalCode", "4" );
+        entry.add( "postOfficeBox", "4" );
         store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
 
         // Entry #7
@@ -123,6 +135,8 @@
         entry = new DefaultServerEntry( registries, dn );
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Apache" );
+        entry.add( "postalCode", "5" );
+        entry.add( "postOfficeBox", "5" );
         store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
         
         // Entry #8
@@ -133,6 +147,8 @@
         entry.add( "ou", "Engineering" );
         entry.add( "cn",  "Jack Daniels");
         entry.add( "SN",  "Daniels");
+        entry.add( "postalCode", "6" );
+        entry.add( "postOfficeBox", "6" );
         store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
 
         // aliases -------------

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java?rev=650006&r1=650005&r2=650006&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/SchemaConstants.java
Sun Apr 20 19:37:56 2008
@@ -153,6 +153,14 @@
     String STREET_ADDRESS_AT = "streetAddress";
     String STREET_AT_OID = "2.5.4.9";
 
+    // PostalCode
+    String POSTALCODE_AT = "postalCode";
+    String POSTALCODE_AT_OID = "2.5.4.17";
+
+    // PostOfficeBox
+    String POSTOFFICEBOX_AT = "postOfficeBox";
+    String POSTOFFICEBOX_AT_OID = "2.5.4.18";
+
     // SearchGuide
     String SEARCHGUIDE_AT = "searchguide";
     String SEARCHGUIDE_AT_OID = "2.5.4.14";



Mime
View raw message