directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r640532 - in /directory/sandbox/akarasulu/bigbang/apacheds: btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ core-cursor/src/main/java/org/apache/directory/server/core/cursor/ jdbm-store/ jdbm-store/src/main/j...
Date Mon, 24 Mar 2008 19:25:33 GMT
Author: akarasulu
Date: Mon Mar 24 12:25:28 2008
New Revision: 640532

URL: http://svn.apache.org/viewvc?rev=640532&view=rev
Log:
Changes to jdbm-store ...

 o making Cursors Iterable so we can use them in foreach based for loops
 o jdbm-store has test scope dep on xdbm-tools to easily analyze indices while
   troubleshooting problems with the implementation
 o added new CursorIterator to easily be able to make any Cursor implementation
   return an iterator to implement Iterable interface for foreach construct use
 o added some pretty print methods toString methods to the IndexEntry methods 

Added:
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorIterator.java
Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ForwardIndexEntry.java
    directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ReverseIndexEntry.java
    directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/AbstractCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/pom.xml
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursor.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/JdbmStoreTest.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ForwardIndexEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ForwardIndexEntry.java?rev=640532&r1=640531&r2=640532&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ForwardIndexEntry.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ForwardIndexEntry.java
Mon Mar 24 12:25:28 2008
@@ -113,4 +113,16 @@
         tuple.setKey( entry.getValue() );
         tuple.setValue( entry.getId() );
     }
+
+
+    public String toString()
+    {
+        StringBuilder buf = new StringBuilder();
+        buf.append( "ForwardIndexEntry[ " );
+        buf.append( tuple.getValue() );
+        buf.append( ", " );
+        buf.append( tuple.getKey() );
+        buf.append( " ]" );
+        return buf.toString();
+    }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ReverseIndexEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ReverseIndexEntry.java?rev=640532&r1=640531&r2=640532&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ReverseIndexEntry.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ReverseIndexEntry.java
Mon Mar 24 12:25:28 2008
@@ -113,4 +113,16 @@
         tuple.setKey( entry.getId() );
         tuple.setValue( entry.getValue() );
     }
+
+
+    public String toString()
+    {
+        StringBuilder buf = new StringBuilder();
+        buf.append( "ReverseIndexEntry[ " );
+        buf.append( tuple.getKey() );
+        buf.append( ", " );
+        buf.append( tuple.getValue() );
+        buf.append( " ]" );
+        return buf.toString();
+    }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java?rev=640532&r1=640531&r2=640532&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java
Mon Mar 24 12:25:28 2008
@@ -19,9 +19,8 @@
 package org.apache.directory.server.core.partition.impl.btree;
 
 
-import org.apache.directory.server.core.cursor.Cursor;
-import org.apache.directory.server.core.cursor.CursorClosedException;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.cursor.AbstractCursor;
 import org.apache.directory.shared.ldap.NotImplementedException;
 
 import java.util.Arrays;
@@ -34,7 +33,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ValueArrayCursor<K,V> implements Cursor<Tuple>
+public class ValueArrayCursor<K,V> extends AbstractCursor<Tuple>
 {
     private static final int BEFORE_FIRST = -1;
 
@@ -42,7 +41,6 @@
     private final List<V> values;
     private final Tuple<K,V> tuple = new Tuple<K,V>();
 
-    private boolean closed;
     private int pos = BEFORE_FIRST;
 
 
@@ -62,16 +60,6 @@
     }
 
 
-    protected void checkClosed( String operation ) throws Exception
-    {
-        if ( closed )
-        {
-            throw new CursorClosedException( "Attempting " + operation
-                    + " operation on a closed Cursor." );
-        }
-    }
-
-
     public boolean available()
     {
         return inRangeOnValue();
@@ -188,12 +176,6 @@
     }
 
 
-    public boolean isClosed() throws Exception
-    {
-        return closed;
-    }
-
-
     public boolean previous() throws Exception
     {
         checkClosed( "previous()" );
@@ -242,11 +224,5 @@
     public boolean isElementReused()
     {
         return true;
-    }
-
-
-    public void close() throws Exception
-    {
-        closed = true;
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/AbstractCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/AbstractCursor.java?rev=640532&r1=640531&r2=640532&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/AbstractCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/AbstractCursor.java
Mon Mar 24 12:25:28 2008
@@ -19,6 +19,9 @@
 package org.apache.directory.server.core.cursor;
 
 
+import java.util.Iterator;
+
+
 /**
  * Simple class that contains often used Cursor code.
  *
@@ -48,5 +51,11 @@
     public void close()
     {
         closed = true;
+    }
+
+
+    public Iterator<E> iterator()
+    {
+        return new CursorIterator<E>( this );
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java?rev=640532&r1=640531&r2=640532&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java
Mon Mar 24 12:25:28 2008
@@ -37,7 +37,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface Cursor<E>
+public interface Cursor<E> extends Iterable<E>
 {
     /**
      * Determines whether or not a call to get() will succeed.

Added: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorIterator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorIterator.java?rev=640532&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorIterator.java
(added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorIterator.java
Mon Mar 24 12:25:28 2008
@@ -0,0 +1,69 @@
+/*
+ *  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.core.cursor;
+
+
+import java.util.Iterator;
+
+
+/**
+ * An Iterator over a Cursor so Cursors can be Iterable for using in foreach
+ * constructs.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $$Rev$$
+ */
+public class CursorIterator<E> implements Iterator<E>
+{
+    private Cursor<E> cursor;
+
+
+    public CursorIterator( Cursor cursor )
+    {
+        this.cursor = cursor;
+    }
+
+
+    public boolean hasNext()
+    {
+        return cursor.available();
+    }
+
+
+    public E next()
+    {
+        try
+        {
+            E element = cursor.get();
+            cursor.next();
+            return element;
+        }
+        catch ( Exception e )
+        {
+            throw new RuntimeException( "Failure on underlying Cursor.", e );
+        }
+    }
+
+
+    public void remove()
+    {
+        throw new UnsupportedOperationException( "Underlying Cursor does not support removal."
);
+    }
+}

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java?rev=640532&r1=640531&r2=640532&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java
Mon Mar 24 12:25:28 2008
@@ -19,6 +19,9 @@
 package org.apache.directory.server.core.cursor;
 
 
+import java.util.Iterator;
+
+
 /**
  * An empty Cursor implementation.
  *

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/pom.xml?rev=640532&r1=640531&r2=640532&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/pom.xml (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/pom.xml Mon Mar 24 12:25:28 2008
@@ -75,6 +75,13 @@
 
     <dependency>
       <groupId>${pom.groupId}</groupId>
+      <artifactId>apacheds-xdbm-tools</artifactId>
+      <version>${pom.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
       <artifactId>apacheds-schema-registries</artifactId>
       <version>${pom.version}</version>
     </dependency>

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursor.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/IndexCursor.java?rev=640532&r1=640531&r2=640532&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursor.java
Mon Mar 24 12:25:28 2008
@@ -25,6 +25,9 @@
 import org.apache.directory.server.core.partition.impl.btree.ForwardIndexEntry;
 import org.apache.directory.server.core.partition.impl.btree.ReverseIndexEntry;
 import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.cursor.CursorIterator;
+
+import java.util.Iterator;
 
 
 /**
@@ -153,5 +156,11 @@
     public void close() throws Exception
     {
         wrappedCursor.close();
+    }
+
+
+    public Iterator<IndexEntry<K, O>> iterator()
+    {
+        return new CursorIterator<IndexEntry<K,O>>( this );
     }
 }

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=640532&r1=640531&r2=640532&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
Mon Mar 24 12:25:28 2008
@@ -34,6 +34,7 @@
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.server.xdbm.tools.IndexUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
@@ -753,6 +754,7 @@
 
     public Long getParentId( Long childId ) throws Exception
     {
+        IndexUtils.printContents( hierarchyIdx, null );
         return hierarchyIdx.reverseLookup( childId );
     }
 

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=640532&r1=640531&r2=640532&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
Mon Mar 24 12:25:28 2008
@@ -331,7 +331,7 @@
         assertNull( store.getParentId( 0L ) );
 
         // should not be allowed
-        try { store.delete( 1L ); fail(); } catch( LdapOperationNotSupportedException e )
+xxx        try { store.delete( 1L ); fail(); } catch( LdapOperationNotSupportedException
e )
         {
             assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
         }



Mime
View raw message