directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r925576 - in /directory/apacheds/trunk: avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/ jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ xdbm-base/src/main/java/org/apache/dire...
Date Sat, 20 Mar 2010 10:48:27 GMT
Author: seelmann
Date: Sat Mar 20 10:48:26 2010
New Revision: 925576

URL: http://svn.apache.org/viewvc?rev=925576&view=rev
Log:
added generic index implementation, use it in tests

Added:
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java
Modified:
    directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java

Modified: directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java?rev=925576&r1=925575&r2=925576&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
(original)
+++ directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
Sat Mar 20 10:48:26 2010
@@ -44,8 +44,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerModification;
+import org.apache.directory.server.xdbm.GenericIndex;
 import org.apache.directory.server.xdbm.Index;
-import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.IndexNotFoundException;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
@@ -58,7 +58,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
-import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
@@ -562,229 +561,7 @@ public class AvlStoreTest
     @Test
     public void testConvertIndex() throws Exception
     {
-        Index nonAvlIndex = new Index<Object, ServerEntry, Long>()
-        {
-
-            public void add( Object attrVal, Long id ) throws Exception
-            {
-            }
-
-
-            public void close() throws Exception
-            {
-            }
-
-
-            public int count() throws Exception
-            {
-                return 0;
-            }
-
-
-            public int count( Object attrVal ) throws Exception
-            {
-                return 0;
-            }
-
-
-            public void drop( Long id ) throws Exception
-            {
-            }
-
-
-            public void drop( Object attrVal, Long id ) throws Exception
-            {
-            }
-
-
-            public IndexCursor forwardCursor() throws Exception
-            {
-                return null;
-            }
-
-
-            public IndexCursor forwardCursor( Object key ) throws Exception
-            {
-                return null;
-            }
-
-
-            public Long forwardLookup( Object attrVal ) throws Exception
-            {
-                return null;
-            }
-
-
-            public Cursor forwardValueCursor( Object key ) throws Exception
-            {
-                return null;
-            }
-
-
-            public boolean forward( Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean forward( Object attrVal, Long id ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean reverse( Long id ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean reverse( Long id, Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean forwardGreaterOrEq( Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean forwardGreaterOrEq( Object attrVal, Long id ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean reverseGreaterOrEq( Long id ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean reverseGreaterOrEq( Long id, Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean forwardLessOrEq( Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            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()
-            {
-                return false;
-            }
-
-
-            public int lessThanCount( Object attrVal ) throws Exception
-            {
-                return 0;
-            }
-
-
-            public IndexCursor reverseCursor() throws Exception
-            {
-                return null;
-            }
-
-
-            public IndexCursor reverseCursor( Long id ) throws Exception
-            {
-                return null;
-            }
-
-
-            public Object reverseLookup( Long id ) throws Exception
-            {
-                return null;
-            }
-
-
-            public Cursor reverseValueCursor( Long id ) throws Exception
-            {
-                return null;
-            }
-
-
-            public void setAttributeId( String attributeId )
-            {
-            }
-
-
-            public void setCacheSize( int cacheSize )
-            {
-            }
-
-
-            public void setWkDirPath( File wkDirPath )
-            {
-            }
-
-
-            public void sync() throws Exception
-            {
-            }
-
-        };
+        Index nonAvlIndex = new GenericIndex( "ou", 10, new File( "." ) );
 
         Method convertIndex = store.getClass().getDeclaredMethod( "convert", Index.class
);
         convertIndex.setAccessible( true );

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=925576&r1=925575&r2=925576&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Sat Mar 20 10:48:26 2010
@@ -45,8 +45,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerModification;
+import org.apache.directory.server.xdbm.GenericIndex;
 import org.apache.directory.server.xdbm.Index;
-import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.IndexNotFoundException;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
@@ -59,7 +59,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
-import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
@@ -595,229 +594,7 @@ public class JdbmStoreTest
     @Test
     public void testConvertIndex() throws Exception
     {
-        Index nonJdbmIndex = new Index<Object, Object, Long>()
-        {
-
-            public void add( Object attrVal, Long id ) throws Exception
-            {
-            }
-
-
-            public void close() throws Exception
-            {
-            }
-
-
-            public int count() throws Exception
-            {
-                return 0;
-            }
-
-
-            public int count( Object attrVal ) throws Exception
-            {
-                return 0;
-            }
-
-
-            public void drop( Long id ) throws Exception
-            {
-            }
-
-
-            public void drop( Object attrVal, Long id ) throws Exception
-            {
-            }
-
-
-            public IndexCursor forwardCursor() throws Exception
-            {
-                return null;
-            }
-
-
-            public IndexCursor forwardCursor( Object key ) throws Exception
-            {
-                return null;
-            }
-
-
-            public Long forwardLookup( Object attrVal ) throws Exception
-            {
-                return null;
-            }
-
-
-            public Cursor forwardValueCursor( Object key ) throws Exception
-            {
-                return null;
-            }
-
-
-            public boolean forward( Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean forward( Object attrVal, Long id ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean reverse( Long id ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean reverse( Long id, Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean forwardGreaterOrEq( Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean forwardGreaterOrEq( Object attrVal, Long id ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean reverseGreaterOrEq( Long id ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean reverseGreaterOrEq( Long id, Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            public boolean forwardLessOrEq( Object attrVal ) throws Exception
-            {
-                return false;
-            }
-
-
-            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()
-            {
-                return false;
-            }
-
-
-            public int lessThanCount( Object attrVal ) throws Exception
-            {
-                return 0;
-            }
-
-
-            public IndexCursor reverseCursor() throws Exception
-            {
-                return null;
-            }
-
-
-            public IndexCursor reverseCursor( Long id ) throws Exception
-            {
-                return null;
-            }
-
-
-            public Object reverseLookup( Long id ) throws Exception
-            {
-                return null;
-            }
-
-
-            public Cursor reverseValueCursor( Long id ) throws Exception
-            {
-                return null;
-            }
-
-
-            public void setAttributeId( String attributeId )
-            {
-            }
-
-
-            public void setCacheSize( int cacheSize )
-            {
-            }
-
-
-            public void setWkDirPath( File wkDirPath )
-            {
-            }
-
-
-            public void sync() throws Exception
-            {
-            }
-
-        };
+        Index nonJdbmIndex = new GenericIndex( "ou", 10, new File( "." ) );
 
         Method convertIndex = store.getClass().getDeclaredMethod( "convertIndex", Index.class
);
         convertIndex.setAccessible( true );

Added: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java?rev=925576&view=auto
==============================================================================
--- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java
(added)
+++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java
Sat Mar 20 10:48:26 2010
@@ -0,0 +1,298 @@
+/*
+ *  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;
+
+
+import java.io.File;
+
+import org.apache.directory.shared.ldap.cursor.Cursor;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
+
+/**
+ * A generic index implementation that is just used to hold the index configuration
+ * parameters (attributeId, cacheSize, wkDirPath). All other methods are not working.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 917312 $
+ */
+public class GenericIndex<K, O, ID> implements Index<K, O, ID>
+{
+
+    protected String attributeId;
+    protected int cacheSize;
+    protected File wkDirPath;
+
+
+    /**
+     * Creates a new instance of GenericIndex.
+     * 
+     * @param attributeId the attribute ID
+     * @param cacheSize the cache size
+     */
+    public GenericIndex( String attributeId, int cacheSize )
+    {
+        this( attributeId, cacheSize, null );
+    }
+
+
+    /**
+     * Creates a new instance of GenericIndex.
+     *
+     * @param attributeId the attribute ID
+     * @param cacheSize the cache size
+     * @param wkDirPath the working directory
+     */
+    public GenericIndex( String attributeId, int cacheSize, File wkDirPath )
+    {
+        this.attributeId = attributeId;
+        this.cacheSize = cacheSize;
+        this.wkDirPath = wkDirPath;
+    }
+
+
+    public void add( K attrVal, ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void close() throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public int count() throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public int count( K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void drop( ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void drop( K attrVal, ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public IndexCursor<K, O, ID> forwardCursor() throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public IndexCursor<K, O, ID> forwardCursor( K key ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public ID forwardLookup( K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public Cursor<ID> forwardValueCursor( K key ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean forward( K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean forward( K attrVal, ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean reverse( ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean reverse( ID id, K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean forwardGreaterOrEq( K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean forwardGreaterOrEq( K attrVal, ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean reverseGreaterOrEq( ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean reverseGreaterOrEq( ID id, K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean forwardLessOrEq( K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean forwardLessOrEq( K attrVal, ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean reverseLessOrEq( ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean reverseLessOrEq( ID id, K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public AttributeType getAttribute()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public String getAttributeId()
+    {
+        return attributeId;
+    }
+
+
+    public int getCacheSize()
+    {
+        return cacheSize;
+    }
+
+
+    public K getNormalized( K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public File getWkDirPath()
+    {
+        return wkDirPath;
+    }
+
+
+    public int greaterThanCount( K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public boolean isCountExact()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public int lessThanCount( K attrVal ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public IndexCursor<K, O, ID> reverseCursor() throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public IndexCursor<K, O, ID> reverseCursor( ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public K reverseLookup( ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public Cursor<K> reverseValueCursor( ID id ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void setAttributeId( String attributeId )
+    {
+        this.attributeId = attributeId;
+    }
+
+
+    public void setCacheSize( int cacheSize )
+    {
+        this.cacheSize = cacheSize;
+    }
+
+
+    public void setWkDirPath( File wkDirPath )
+    {
+        this.wkDirPath = wkDirPath;
+    }
+
+
+    public void sync() throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+}



Mime
View raw message