You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/12/31 21:41:02 UTC
svn commit: r607775 - in /directory/sandbox/akarasulu/bigbang/apacheds:
btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/
jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
Author: akarasulu
Date: Mon Dec 31 12:41:01 2007
New Revision: 607775
URL: http://svn.apache.org/viewvc?rev=607775&view=rev
Log:
added new cursor but there are issues here: need to remove this whole TubleBrowserFactory garbage
Added:
directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.java
- copied, changed from r607563, directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/TupleCursor.java
Modified:
directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoDupsCursor.java
directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoDupsCursor.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/NoDupsCursor.java?rev=607775&r1=607774&r2=607775&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoDupsCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoDupsCursor.java Mon Dec 31 12:41:01 2007
@@ -20,7 +20,6 @@
import org.apache.directory.server.core.cursor.AbstractCursor;
-import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
import org.apache.directory.server.core.cursor.InconsistentCursorStateException;
import org.apache.directory.shared.ldap.NotImplementedException;
Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.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/JdbmTable.java?rev=607775&r1=607774&r2=607775&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java Mon Dec 31 12:41:01 2007
@@ -1050,7 +1050,7 @@
if ( values instanceof BTreeRedirect )
{
- return new BTreeTupleEnumeration( getBTree( ( BTreeRedirect ) values ), key );
+ return new SameKeyTupleCursor( getBTree( ( BTreeRedirect ) values ), key, comparator.getValueComparator() );
}
throw new IllegalStateException( "When using duplicate keys either a TreeSet or BTree is used for values." );
Copied: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.java (from r607563, directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/TupleCursor.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/SameKeyTupleCursor.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/TupleCursor.java&r1=607563&r2=607775&rev=607775&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/TupleCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.java Mon Dec 31 12:41:01 2007
@@ -21,30 +21,31 @@
import org.apache.directory.server.core.cursor.AbstractCursor;
import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.partition.impl.btree.Tuple;
import java.io.IOException;
import java.util.Comparator;
-import jdbm.helper.Tuple;
import jdbm.helper.TupleBrowser;
import jdbm.btree.BTree;
/**
- * Cursor over the Tuples of a JDBM BTree. Duplicate keys are not supported
- * by JDBM natively so you will not see duplicate keys. For this reason as
- * well before() and after() positioning only considers the key of the Tuple
- * arguments provided.
+ * Cursor over a set of values for the same key which are store in another
+ * BTree. This Cursor is limited to the same key and it's tuples will always
+ * return the same key.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class TupleCursor extends AbstractCursor<Tuple>
+public class SameKeyTupleCursor extends AbstractCursor<Tuple>
{
private final Comparator comparator;
private final BTree btree;
+ private final Object key;
- private Tuple tuple = new Tuple();
+ private jdbm.helper.Tuple valueTuple = new jdbm.helper.Tuple();
+ private Tuple returnedTuple = new Tuple();
private TupleBrowser browser;
private boolean valueAvailable;
@@ -53,11 +54,13 @@
* Creates a Cursor over the tuples of a JDBM BTree.
*
* @param btree the JDBM BTree to build a Cursor over
+ * @param key the constant key for which values are returned
* @param comparator the Comparator used to determine <b>key</b> ordering
* @throws IOException of there are problems accessing the BTree
*/
- public TupleCursor( BTree btree, Comparator comparator ) throws IOException
+ public SameKeyTupleCursor( BTree btree, Object key, Comparator comparator ) throws IOException
{
+ this.key = key;
this.btree = btree;
this.comparator = comparator;
}
@@ -65,8 +68,8 @@
private void clearValue()
{
- tuple.setKey( null );
- tuple.setValue( null );
+ returnedTuple.setKey( key );
+ returnedTuple.setValue( null );
valueAvailable = false;
}
@@ -78,21 +81,23 @@
/**
- * Positions this Cursor before the key of the supplied tuple.
+ * Positions this Cursor over the same keys before the value of the
+ * supplied valueTuple. The supplied element Tuple's key is not considered at
+ * all.
*
- * @param element the tuple who's key is used to position this Cursor
+ * @param element the valueTuple who's value is used to position this Cursor
* @throws IOException if there are failures to position the Cursor
*/
public void before( Tuple element ) throws IOException
{
- browser = btree.browse( element.getKey() );
+ browser = btree.browse( element.getValue() );
clearValue();
}
public void after( Tuple element ) throws IOException
{
- browser = btree.browse( element.getKey() );
+ browser = btree.browse( element.getValue() );
/*
* While the next value is less than or equal to the element keep
@@ -101,9 +106,9 @@
* the element then we stop, backup, and return so subsequent calls
* to getNext() will return a value greater than the element.
*/
- while ( browser.getNext( tuple ) )
+ while ( browser.getNext( valueTuple ) )
{
- Object next = tuple.getKey();
+ Object next = valueTuple.getKey();
//noinspection unchecked
int nextCompared = comparator.compare( next, element.getKey() );
@@ -120,7 +125,7 @@
* the call below to getPrevious() will fail. In this special
* case we just reset the Cursor's browser and return.
*/
- if ( browser.getPrevious( tuple ) )
+ if ( browser.getPrevious( valueTuple ) )
{
}
else
@@ -167,8 +172,10 @@
public boolean previous() throws IOException
{
- if ( browser.getPrevious( tuple ) )
+ if ( browser.getPrevious( valueTuple ) )
{
+ returnedTuple.setKey( key );
+ returnedTuple.setValue( valueTuple.getKey() );
return valueAvailable = true;
}
else
@@ -181,8 +188,10 @@
public boolean next() throws IOException
{
- if ( browser.getNext( tuple ) )
+ if ( browser.getNext( valueTuple ) )
{
+ returnedTuple.setKey( key );
+ returnedTuple.setValue( valueTuple.getKey() );
return valueAvailable = true;
}
else
@@ -198,7 +207,7 @@
if ( valueAvailable )
{
//noinspection unchecked
- return tuple;
+ return returnedTuple;
}
throw new InvalidCursorPositionException();
@@ -209,10 +218,4 @@
{
return true;
}
-
-
- BTree getBTree()
- {
- return btree;
- }
-}
+}
\ No newline at end of file