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 2008/03/20 14:05:48 UTC
svn commit: r639279 - in /directory/sandbox/akarasulu/bigbang/apacheds:
btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/
core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/
jdbm-store/src/main/ja...
Author: akarasulu
Date: Thu Mar 20 06:05:46 2008
New Revision: 639279
URL: http://svn.apache.org/viewvc?rev=639279&view=rev
Log:
jdbm store changes ...
o added new cursor to traverse same key tuples over a avltree
o added new table cursor methods to access values and tuples over same key
o added new index cursor methods to access values and index entries over same
index value
o generified jdbm store
o patched up IndexDialog which may be moved out into a btree-tools module later
Added:
directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeySetTupleCursor.java
- copied, changed from r639129, directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.java
Modified:
directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Index.java
directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Table.java
directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/IndexDialog.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/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.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
Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Index.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/Index.java?rev=639279&r1=639278&r2=639279&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Index.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Index.java Thu Mar 20 06:05:46 2008
@@ -25,8 +25,6 @@
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.server.core.cursor.Cursor;
-import javax.naming.directory.Attributes;
-
/**
* An index into the master table which returns one or more entry's positions
@@ -37,7 +35,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public interface Index<K>
+public interface Index<K, O>
{
int DEFAULT_INDEX_CACHE_SIZE = 100;
@@ -176,10 +174,22 @@
void drop( K attrVal, Long id ) throws Exception;
- Cursor<IndexEntry<K, Attributes>> reverseCursor() throws Exception;
+ Cursor<IndexEntry<K, O>> reverseCursor() throws Exception;
+
+
+ Cursor<IndexEntry<K, O>> forwardCursor() throws Exception;
+
+
+ Cursor<IndexEntry<K, O>> reverseCursor( Long id ) throws Exception;
+
+
+ Cursor<IndexEntry<K, O>> forwardCursor( K key ) throws Exception;
+
+
+ Cursor<K> reverseValueCursor( Long id ) throws Exception;
- Cursor<IndexEntry<K, Attributes>> forwardCursor() throws Exception;
+ Cursor<Long> forwardValueCursor( K key ) throws Exception;
boolean has( K attrVal, Long id ) throws Exception;
Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Table.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/Table.java?rev=639279&r1=639278&r2=639279&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Table.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/Table.java Thu Mar 20 06:05:46 2008
@@ -265,12 +265,45 @@
/**
- * Creates a Cursor that traverses records in a Table.
+ * Creates a Cursor that traverses Tuples in a Table.
*
* @return a Cursor over Tuples containing the key value pairs
* @throws Exception if there are failures accessing underlying stores
*/
Cursor<Tuple<K,V>> cursor() throws Exception;
+
+
+ /**
+ * Creates a Cursor that traverses Table Tuples for the same key. Only
+ * Tuples with the provided key will be returned if the key exists at
+ * all. If the key does not exist an empty Cursor is returned. The
+ * motivation behind this method is to minimize the need for callers to
+ * actively constrain Cursor operations based on the Tuples they return
+ * to a specific key. This Cursor is naturally limited to return only
+ * the tuples for the same key.
+ *
+ * @param key the duplicate key to return the Tuples of
+ * @return a Cursor over Tuples containing the same key
+ * @throws Exception if there are failures accessing underlying stores
+ */
+ Cursor<Tuple<K,V>> cursor( K key ) throws Exception;
+
+
+ /**
+ * Creates a Cursor that traverses Table values for the same key. Only
+ * Tuples with the provided key will have their values returned if the key
+ * exists at all. If the key does not exist an empty Cursor is returned.
+ * The motivation behind this method is to minimize the need for callers
+ * to actively constrain Cursor operations to a specific key while
+ * removing overheads in creating new Tuples or population one that is
+ * reused to return key value pairs. This Cursor is naturally limited to
+ * return only the values for the same key.
+ *
+ * @param key the duplicate key to return the values of
+ * @return a Cursor over values of a key
+ * @throws Exception if there are failures accessing underlying stores
+ */
+ Cursor<V> valueCursor( K key ) throws Exception;
// ------------------------------------------------------------------------
Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/IndexDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/IndexDialog.java?rev=639279&r1=639278&r2=639279&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/IndexDialog.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/IndexDialog.java Thu Mar 20 06:05:46 2008
@@ -26,9 +26,7 @@
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.util.regex.Pattern;
-import javax.naming.NamingEnumeration;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
@@ -48,8 +46,10 @@
import org.apache.directory.server.core.partition.impl.btree.Index;
import org.apache.directory.server.core.partition.impl.btree.IndexEntry;
+import org.apache.directory.server.core.partition.impl.btree.ForwardIndexEntry;
+import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
-import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.directory.shared.ldap.NotImplementedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,9 +61,9 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class IndexDialog extends JDialog
+public class IndexDialog<K,O> extends JDialog
{
- private static final Logger log = LoggerFactory.getLogger( IndexDialog.class );
+ private static final Logger LOG = LoggerFactory.getLogger( IndexDialog.class );
private static final long serialVersionUID = 3689917253680445238L;
@@ -87,11 +87,10 @@
private JLabel jLabel2 = new JLabel();
private JButton scanBut = new JButton();
- private Index index = null;
+ private Index<K,O> index = null;
- /** Creates new form JDialog */
- public IndexDialog( Frame parent, boolean modal, Index index )
+ public IndexDialog( Frame parent, boolean modal, Index<K,O> index )
{
super( parent, modal );
this.index = index;
@@ -99,7 +98,7 @@
}
- public IndexDialog( Index index )
+ public IndexDialog( Index<K,O> index )
{
super();
this.index = index;
@@ -226,7 +225,8 @@
{
public void actionPerformed( ActionEvent e )
{
- doScan( keyText.getText(), selectedCursorType );
+ //noinspection unchecked
+ doScan( ( K ) keyText.getText(), selectedCursorType );
}
} );
@@ -239,23 +239,23 @@
{
public void actionPerformed( ActionEvent e )
{
- if ( e.getActionCommand() == DEFAULT_CURSOR )
+ if ( e.getActionCommand().equals( DEFAULT_CURSOR ) )
{
selectedCursorType = DEFAULT_CURSOR;
}
- else if ( e.getActionCommand() == EQUALITY_CURSOR )
+ else if ( e.getActionCommand().equals( EQUALITY_CURSOR ) )
{
selectedCursorType = EQUALITY_CURSOR;
}
- else if ( e.getActionCommand() == GREATER_CURSOR )
+ else if ( e.getActionCommand().equals( GREATER_CURSOR ) )
{
selectedCursorType = GREATER_CURSOR;
}
- else if ( e.getActionCommand() == LESS_CURSOR )
+ else if ( e.getActionCommand().equals( LESS_CURSOR ) )
{
selectedCursorType = LESS_CURSOR;
}
- else if ( e.getActionCommand() == REGEX_CURSOR )
+ else if ( e.getActionCommand().equals( REGEX_CURSOR ) )
{
selectedCursorType = REGEX_CURSOR;
}
@@ -270,75 +270,104 @@
}
- public boolean doScan( String key, String scanType )
+ public boolean doScan( K key, String scanType )
{
- if ( key == null || key.trim().equals( "" ) )
- {
- key = null;
- }
-
- if ( key == null && scanType != DEFAULT_CURSOR )
+ if ( key == null && ! scanType.equals( DEFAULT_CURSOR ) )
{
JOptionPane.showMessageDialog( null, "Cannot use a " + scanType + " scan type with a null key constraint.",
"Missing Key Constraint", JOptionPane.ERROR_MESSAGE );
return false;
}
+ Object[] cols = new Object[2];
+ Object[] row;
+ cols[0] = "Keys ( Attribute Value )";
+ cols[1] = "Values ( Entry Id )";
+ DefaultTableModel model = new DefaultTableModel( cols, 0 );
+ int count = 0;
+
try
{
- NamingEnumeration<IndexRecord> list = null;
+ Cursor<IndexEntry<K, O>> list;
- if ( scanType == EQUALITY_CURSOR )
- {
- list = index.listIndices( key );
- }
- else if ( scanType == GREATER_CURSOR )
+ if ( scanType.equals( EQUALITY_CURSOR ) )
{
- list = index.listIndices( key, true );
- }
- else if ( scanType == LESS_CURSOR )
- {
- list = index.listIndices( key, false );
+ list = index.forwardCursor( key );
+ list.beforeFirst();
+ while ( list.next() )
+ {
+ IndexEntry<K,O> rec = list.get();
+ row = new Object[2];
+ row[0] = rec.getValue();
+ row[1] = rec.getId();
+ model.addRow( row );
+ count++;
+ }
}
- else if ( scanType == REGEX_CURSOR )
+ else if ( scanType.equals( GREATER_CURSOR ) )
{
- Pattern regex = StringTools.getRegex( key );
- int starIndex = key.indexOf( '*' );
-
- if ( starIndex > 0 )
+ list = index.forwardCursor();
+ ForwardIndexEntry<K, O> entry = new ForwardIndexEntry<K, O>();
+ entry.setValue( key );
+ list.before( entry );
+ while ( list.next() )
{
- String prefix = key.substring( 0, starIndex );
-
- if ( log.isDebugEnabled() )
- log.debug( "Regex prefix = " + prefix );
-
- list = index.listIndices( regex, prefix );
+ IndexEntry<K,O> rec = list.get();
+ row = new Object[2];
+ row[0] = rec.getValue();
+ row[1] = rec.getId();
+ model.addRow( row );
+ count++;
}
- else
+ }
+ else if ( scanType.equals( LESS_CURSOR ) )
+ {
+ list = index.forwardCursor();
+ ForwardIndexEntry<K, O> entry = new ForwardIndexEntry<K, O>();
+ entry.setValue( key );
+ list.after( entry );
+ while ( list.previous() )
{
- list = index.listIndices( regex );
+ IndexEntry<K,O> rec = list.get();
+ row = new Object[2];
+ row[0] = rec.getValue();
+ row[1] = rec.getId();
+ model.addRow( row );
+ count++;
}
}
- else
+ else if ( scanType.equals( REGEX_CURSOR ) )
{
- list = index.listIndices();
+// Pattern regex = StringTools.getRegex( key );
+// int starIndex = key.indexOf( '*' );
+//
+// if ( starIndex > 0 )
+// {
+// String prefix = key.substring( 0, starIndex );
+//
+// if ( log.isDebugEnabled() )
+// log.debug( "Regex prefix = " + prefix );
+//
+// list = index.listIndices( regex, prefix );
+// }
+// else
+// {
+// list = index.listIndices( regex );
+// }
+ throw new NotImplementedException();
}
-
- Object[] cols = new Object[2];
- Object[] row = null;
- cols[0] = "Keys ( Attribute Value )";
- cols[1] = "Values ( Entry Id )";
- DefaultTableModel model = new DefaultTableModel( cols, 0 );
- int count = 0;
-
- while ( list.hasMore() )
- {
- IndexEntry rec = ( IndexEntry ) list.next();
- row = new Object[2];
- row[0] = rec.getValue();
- row[1] = rec.getId();
- model.addRow( row );
- count++;
+ else
+ {
+ list = index.forwardCursor();
+ while ( list.next() )
+ {
+ IndexEntry<K,O> rec = list.get();
+ row = new Object[2];
+ row[0] = rec.getValue();
+ row[1] = rec.getId();
+ model.addRow( row );
+ count++;
+ }
}
resultsTbl.setModel( model );
@@ -363,6 +392,7 @@
msg = "Error while scanning index " + "on attribute " + index.getAttribute() + " using a " + scanType
+ " cursor type with a key constraint of '" + key + "':\n" + msg;
+ LOG.error( msg, e );
JTextArea area = new JTextArea();
area.setText( msg );
JOptionPane.showMessageDialog( null, area, "Index Scan Error", JOptionPane.ERROR_MESSAGE );
@@ -375,6 +405,7 @@
public static void show( Index index )
{
+ //noinspection unchecked
IndexDialog dialog = new IndexDialog( index );
dialog.setVisible( true );
}
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=639279&r1=639278&r2=639279&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 Thu Mar 20 06:05:46 2008
@@ -44,7 +44,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class JdbmIndex<K> implements Index<K>
+public class JdbmIndex<K,O> implements Index<K,O>
{
/**
* default duplicate limit before duplicate keys switch to using a btree for values
@@ -460,17 +460,43 @@
// ------------------------------------------------------------------------
- public Cursor<IndexEntry<K, Attributes>> reverseCursor() throws Exception
+ public Cursor<IndexEntry<K, O>> reverseCursor() throws Exception
{
//noinspection unchecked
- return new IndexCursor<K, Attributes>( ( Cursor ) reverse.cursor(), false );
+ return new IndexCursor<K, O>( ( Cursor ) reverse.cursor(), false );
}
- public Cursor<IndexEntry<K, Attributes>> forwardCursor() throws Exception
+ public Cursor<IndexEntry<K, O>> forwardCursor() throws Exception
{
//noinspection unchecked
- return new IndexCursor<K, Attributes>( ( Cursor ) forward.cursor(), true );
+ return new IndexCursor<K, O>( ( Cursor ) forward.cursor(), true );
+ }
+
+
+ public Cursor<IndexEntry<K, O>> reverseCursor( Long id ) throws Exception
+ {
+ //noinspection unchecked
+ return new IndexCursor<K, O>( ( Cursor ) reverse.cursor( id ), false );
+ }
+
+
+ public Cursor<IndexEntry<K, O>> forwardCursor( K key ) throws Exception
+ {
+ //noinspection unchecked
+ return new IndexCursor<K, O>( ( Cursor ) forward.cursor( key ), true );
+ }
+
+
+ public Cursor<K> reverseValueCursor( Long id ) throws Exception
+ {
+ return reverse.valueCursor( id );
+ }
+
+
+ public Cursor<Long> forwardValueCursor( K key ) throws Exception
+ {
+ return forward.valueCursor( key );
}
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=639279&r1=639278&r2=639279&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 Thu Mar 20 06:05:46 2008
@@ -67,7 +67,7 @@
import java.util.Set;
-public class JdbmStore
+public class JdbmStore<E>
{
/** static logger */
private static final Logger LOG = LoggerFactory.getLogger( JdbmStore.class );
@@ -95,19 +95,19 @@
private boolean isSyncOnWrite = true;
/** the normalized distinguished name index */
- private JdbmIndex<String> ndnIdx;
+ private JdbmIndex<String,E> ndnIdx;
/** the user provided distinguished name index */
- private JdbmIndex<String> updnIdx;
+ private JdbmIndex<String,E> updnIdx;
/** the attribute existance index */
- private JdbmIndex<String> existanceIdx;
+ private JdbmIndex<String,E> existanceIdx;
/** the parent child relationship index */
- private JdbmIndex<Long> hierarchyIdx;
+ private JdbmIndex<Long,E> hierarchyIdx;
/** the one level scope alias index */
- private JdbmIndex<Long> oneAliasIdx;
+ private JdbmIndex<Long,E> oneAliasIdx;
/** the subtree scope alias index */
- private JdbmIndex<Long> subAliasIdx;
+ private JdbmIndex<Long,E> subAliasIdx;
/** a system index on aliasedObjectName attribute */
- private JdbmIndex<String> aliasIdx;
+ private JdbmIndex<String,E> aliasIdx;
/** Two static declaration to avoid lookup all over the code */
private static AttributeType OBJECT_CLASS_AT;
@@ -331,7 +331,7 @@
if ( ndnIdx == null )
{
- ndnIdx = new JdbmIndex<String>();
+ ndnIdx = new JdbmIndex<String,E>();
ndnIdx.setAttributeId( Oid.NDN );
systemIndices.put( Oid.NDN, ndnIdx );
ndnIdx.init( attributeTypeRegistry.lookup( Oid.NDN ), workingDirectory );
@@ -339,7 +339,7 @@
if ( updnIdx == null )
{
- updnIdx = new JdbmIndex<String>();
+ updnIdx = new JdbmIndex<String,E>();
updnIdx.setAttributeId( Oid.UPDN );
systemIndices.put( Oid.UPDN, updnIdx );
updnIdx.init( attributeTypeRegistry.lookup( Oid.UPDN ), workingDirectory );
@@ -347,7 +347,7 @@
if ( existanceIdx == null )
{
- existanceIdx = new JdbmIndex<String>();
+ existanceIdx = new JdbmIndex<String,E>();
existanceIdx.setAttributeId( Oid.EXISTANCE );
systemIndices.put( Oid.EXISTANCE, existanceIdx );
existanceIdx.init( attributeTypeRegistry.lookup( Oid.EXISTANCE ), workingDirectory );
@@ -355,7 +355,7 @@
if ( hierarchyIdx == null )
{
- hierarchyIdx = new JdbmIndex<Long>();
+ hierarchyIdx = new JdbmIndex<Long,E>();
hierarchyIdx.setAttributeId( Oid.HIERARCHY );
systemIndices.put( Oid.HIERARCHY, hierarchyIdx );
hierarchyIdx.init( attributeTypeRegistry.lookup( Oid.HIERARCHY ), workingDirectory );
@@ -363,7 +363,7 @@
if ( oneAliasIdx == null )
{
- oneAliasIdx = new JdbmIndex<Long>();
+ oneAliasIdx = new JdbmIndex<Long,E>();
oneAliasIdx.setAttributeId( Oid.ONEALIAS );
systemIndices.put( Oid.ONEALIAS, oneAliasIdx );
oneAliasIdx.init( attributeTypeRegistry.lookup( Oid.ONEALIAS ), workingDirectory );
@@ -371,7 +371,7 @@
if ( subAliasIdx == null )
{
- subAliasIdx = new JdbmIndex<Long>();
+ subAliasIdx = new JdbmIndex<Long,E>();
subAliasIdx.setAttributeId( Oid.SUBALIAS );
systemIndices.put( Oid.SUBALIAS, subAliasIdx );
subAliasIdx.init( attributeTypeRegistry.lookup( Oid.SUBALIAS ), workingDirectory );
@@ -379,7 +379,7 @@
if ( aliasIdx == null )
{
- aliasIdx = new JdbmIndex<String>();
+ aliasIdx = new JdbmIndex<String,E>();
aliasIdx.setAttributeId( Oid.ALIAS );
systemIndices.put( Oid.ALIAS, aliasIdx );
aliasIdx.init( attributeTypeRegistry.lookup( Oid.ALIAS ), workingDirectory );
@@ -435,6 +435,9 @@
/**
* Close the parttion : we have to close all the userIndices and the master table.
+ *
+ * @throws Exception lazily thrown on any closer failures to avoid leaving
+ * open files
*/
public synchronized void destroy() throws Exception
{
@@ -557,7 +560,7 @@
}
- public void setExistanceIndex( JdbmIndex<String> index ) throws NamingException
+ public void setExistanceIndex( JdbmIndex<String,E> index ) throws NamingException
{
protect( "existanceIndex" );
existanceIdx = index;
@@ -571,7 +574,7 @@
}
- public void setHierarchyIndex( JdbmIndex<Long> index ) throws NamingException
+ public void setHierarchyIndex( JdbmIndex<Long,E> index ) throws NamingException
{
protect( "hierarchyIndex" );
hierarchyIdx = index;
@@ -585,7 +588,7 @@
}
- public void setAliasIndex( JdbmIndex<String> index ) throws NamingException
+ public void setAliasIndex( JdbmIndex<String,E> index ) throws NamingException
{
protect( "aliasIndex" );
aliasIdx = index;
@@ -599,7 +602,7 @@
}
- public void setOneAliasIndex( JdbmIndex<Long> index ) throws NamingException
+ public void setOneAliasIndex( JdbmIndex<Long,E> index ) throws NamingException
{
protect( "oneAliasIndex" );
oneAliasIdx = index;
@@ -613,7 +616,7 @@
}
- public void setSubAliasIndex( JdbmIndex<Long> index ) throws NamingException
+ public void setSubAliasIndex( JdbmIndex<Long,E> index ) throws NamingException
{
protect( "subAliasIndex" );
subAliasIdx = index;
@@ -627,7 +630,7 @@
}
- public void setUpdnIndex( JdbmIndex<String> index ) throws NamingException
+ public void setUpdnIndex( JdbmIndex<String,E> index ) throws NamingException
{
protect( "updnIndex" );
updnIdx = index;
@@ -641,7 +644,7 @@
}
- public void setNdnIndex( JdbmIndex<String> index ) throws NamingException
+ public void setNdnIndex( JdbmIndex<String,E> index ) throws NamingException
{
protect( "ndnIndex" );
ndnIdx = index;
@@ -1097,9 +1100,9 @@
}
- public Cursor<IndexEntry<Long, Attributes>> list( Long id ) throws Exception
+ public Cursor<IndexEntry<Long,E>> list( Long id ) throws Exception
{
- Cursor<IndexEntry<Long,Attributes>> cursor = hierarchyIdx.forwardCursor();
+ Cursor<IndexEntry<Long,E>> cursor = hierarchyIdx.forwardCursor();
ForwardIndexEntry recordForward = new ForwardIndexEntry();
recordForward.setId( id );
cursor.before( recordForward );
@@ -1186,7 +1189,7 @@
// Get all existance mappings for this id creating a special key
// that looks like so 'existance[attribute]' and the value is set to id
- Cursor<IndexEntry<String,Attributes>> list = existanceIdx.reverseCursor();
+ Cursor<IndexEntry<String,E>> list = existanceIdx.reverseCursor();
ForwardIndexEntry recordForward = new ForwardIndexEntry();
recordForward.setId( id );
list.before( recordForward );
@@ -1214,7 +1217,7 @@
// Get all parent child mappings for this entry as the parent using the
// key 'child' with many entries following it.
- Cursor<IndexEntry<Long,Attributes>> children = hierarchyIdx.forwardCursor();
+ Cursor<IndexEntry<Long,E>> children = hierarchyIdx.forwardCursor();
recordForward = new ForwardIndexEntry();
recordForward.setId( id );
children.before( recordForward );
@@ -1662,7 +1665,7 @@
}
}
- Cursor<IndexEntry<Long,Attributes>> children = list( id );
+ Cursor<IndexEntry<Long,E>> children = list( id );
while ( children.next() )
{
// Get the child and its id
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=639279&r1=639278&r2=639279&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 Thu Mar 20 06:05:46 2008
@@ -26,6 +26,8 @@
import org.apache.directory.server.core.avltree.*;
import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.cursor.EmptyCursor;
+import org.apache.directory.server.core.cursor.SingletonCursor;
import org.apache.directory.server.core.partition.impl.btree.*;
import org.apache.directory.server.core.partition.impl.btree.Tuple;
import org.apache.directory.server.schema.SerializableComparator;
@@ -762,6 +764,69 @@
}
return new NoDupsCursor<K,V>( this );
+ }
+
+
+ public Cursor<Tuple<K,V>> cursor( K key ) throws Exception
+ {
+ if ( key == null )
+ {
+ return new EmptyCursor<Tuple<K,V>>();
+ }
+
+ Object raw = bt.find( key );
+
+ if ( null == raw )
+ {
+ return new EmptyCursor<Tuple<K,V>>();
+ }
+
+ if ( ! allowsDuplicates )
+ {
+ //noinspection unchecked
+ return new SingletonCursor<Tuple<K,V>>( new Tuple<K,V>( key, ( V ) raw ) );
+ }
+
+ byte[] serialized = ( byte[] ) raw;
+ if ( BTreeRedirectMarshaller.isRedirect( serialized ) )
+ {
+ BTree tree = getBTree( BTreeRedirectMarshaller.INSTANCE.deserialize( serialized ) );
+ return new SameKeyTupleCursor<K,V>( tree, key, keyComparator );
+ }
+
+ AvlTree<V> set = marshaller.deserialize( serialized );
+ return new KeySetTupleCursor<K,V>( set, key, valueComparator );
+ }
+
+
+ public Cursor<V> valueCursor( K key ) throws Exception
+ {
+ if ( key == null )
+ {
+ return new EmptyCursor<V>();
+ }
+
+ Object raw = bt.find( key );
+
+ if ( null == raw )
+ {
+ return new EmptyCursor<V>();
+ }
+
+ if ( ! allowsDuplicates )
+ {
+ //noinspection unchecked
+ return new SingletonCursor<V>( ( V ) raw );
+ }
+
+ byte[] serialized = ( byte[] ) raw;
+ if ( BTreeRedirectMarshaller.isRedirect( serialized ) )
+ {
+ BTree tree = getBTree( BTreeRedirectMarshaller.INSTANCE.deserialize( serialized ) );
+ return new KeyCursor<V>( tree, valueComparator );
+ }
+
+ return new AvlTreeCursor<V>( marshaller.deserialize( serialized ) );
}
Copied: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeySetTupleCursor.java (from r639129, directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.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/KeySetTupleCursor.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeySetTupleCursor.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.java&r1=639129&r2=639279&rev=639279&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeySetTupleCursor.java Thu Mar 20 06:05:46 2008
@@ -22,46 +22,42 @@
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 org.apache.directory.server.core.avltree.AvlTree;
+import org.apache.directory.server.core.avltree.AvlTreeCursor;
import java.util.Comparator;
-import jdbm.helper.TupleBrowser;
-import jdbm.btree.BTree;
-
/**
- * 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.
+ * Cursor over a set of values for the same key which are store in an in
+ * memory AvlTree. 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 SameKeyTupleCursor extends AbstractCursor<Tuple>
+public class KeySetTupleCursor<K,V> extends AbstractCursor<Tuple<K,V>>
{
- private final Comparator comparator;
- private final BTree btree;
- private final Object key;
-
- private jdbm.helper.Tuple valueTuple = new jdbm.helper.Tuple();
- private Tuple returnedTuple = new Tuple();
- private TupleBrowser browser;
+ private final Comparator<V> comparator;
+ private final AvlTreeCursor<V> wrapped;
+ private final K key;
+
+ private Tuple<K,V> returnedTuple = new Tuple<K,V>();
private boolean valueAvailable;
/**
- * Creates a Cursor over the tuples of a JDBM BTree.
+ * Creates a Cursor over the tuples of an AvlTree.
*
- * @param btree the JDBM BTree to build a Cursor over
+ * @param avlTree the AvlTree to build a Tuple returning Cursor over
* @param key the constant key for which values are returned
* @param comparator the Comparator used to determine <b>key</b> ordering
- * @throws Exception of there are problems accessing the BTree
*/
- public SameKeyTupleCursor( BTree btree, Object key, Comparator comparator ) throws Exception
+ public KeySetTupleCursor( AvlTree<V> avlTree, K key, Comparator<V> comparator )
{
this.key = key;
- this.btree = btree;
this.comparator = comparator;
+ this.wrapped = new AvlTreeCursor<V>( avlTree );
}
@@ -81,22 +77,22 @@
/**
* 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.
+ * supplied element Tuple. The supplied element Tuple's key is not
+ * considered at all.
*
* @param element the valueTuple who's value is used to position this Cursor
* @throws Exception if there are failures to position the Cursor
*/
- public void before( Tuple element ) throws Exception
+ public void before( Tuple<K,V> element ) throws Exception
{
- browser = btree.browse( element.getValue() );
+ wrapped.before( element.getValue() );
clearValue();
}
- public void after( Tuple element ) throws Exception
+ public void after( Tuple<K,V> element ) throws Exception
{
- browser = btree.browse( element.getValue() );
+ wrapped.after( element.getValue() );
/*
* While the next value is less than or equal to the element keep
@@ -105,12 +101,11 @@
* the element then we stop, backup, and return so subsequent calls
* to getNext() will return a value greater than the element.
*/
- while ( browser.getNext( valueTuple ) )
+ while ( wrapped.next() )
{
- Object next = valueTuple.getKey();
+ V next = wrapped.get();
- //noinspection unchecked
- int nextCompared = comparator.compare( next, element.getKey() );
+ int nextCompared = comparator.compare( next, element.getValue() );
if ( nextCompared <= 0 )
{
@@ -121,15 +116,15 @@
/*
* If we just have values greater than the element argument
* then we are before the first element and cannot backup, and
- * the call below to getPrevious() will fail. In this special
- * case we just reset the Cursor's browser and return.
+ * the call below to previous() will fail. In this special
+ * case we just reset the Cursor's position and return.
*/
- if ( browser.getPrevious( valueTuple ) )
+ if ( wrapped.previous() )
{
}
else
{
- browser = btree.browse( element.getKey() );
+ wrapped.before( element.getValue() );
}
clearValue();
@@ -138,43 +133,40 @@
}
clearValue();
- // just return
}
public void beforeFirst() throws Exception
{
- browser = btree.browse();
+ wrapped.beforeFirst();
clearValue();
}
public void afterLast() throws Exception
{
- browser = btree.browse( null );
+ wrapped.afterLast();
}
public boolean first() throws Exception
{
- beforeFirst();
- return next();
+ return wrapped.first();
}
public boolean last() throws Exception
{
- afterLast();
- return previous();
+ return wrapped.last();
}
public boolean previous() throws Exception
{
- if ( browser.getPrevious( valueTuple ) )
+ if ( wrapped.previous() )
{
returnedTuple.setKey( key );
- returnedTuple.setValue( valueTuple.getKey() );
+ returnedTuple.setValue( wrapped.get() );
return valueAvailable = true;
}
else
@@ -187,10 +179,10 @@
public boolean next() throws Exception
{
- if ( browser.getNext( valueTuple ) )
+ if ( wrapped.next() )
{
returnedTuple.setKey( key );
- returnedTuple.setValue( valueTuple.getKey() );
+ returnedTuple.setValue( wrapped.get() );
return valueAvailable = true;
}
else
@@ -201,11 +193,10 @@
}
- public Tuple get() throws Exception
+ public Tuple<K,V> get() throws Exception
{
if ( valueAvailable )
{
- //noinspection unchecked
return returnedTuple;
}
Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.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?rev=639279&r1=639278&r2=639279&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/SameKeyTupleCursor.java Thu Mar 20 06:05:46 2008
@@ -37,11 +37,11 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class SameKeyTupleCursor extends AbstractCursor<Tuple>
+public class SameKeyTupleCursor<K,V> extends AbstractCursor<Tuple<K,V>>
{
- private final Comparator comparator;
+ private final Comparator<K> comparator;
private final BTree btree;
- private final Object key;
+ private final K key;
private jdbm.helper.Tuple valueTuple = new jdbm.helper.Tuple();
private Tuple returnedTuple = new Tuple();
@@ -57,7 +57,7 @@
* @param comparator the Comparator used to determine <b>key</b> ordering
* @throws Exception of there are problems accessing the BTree
*/
- public SameKeyTupleCursor( BTree btree, Object key, Comparator comparator ) throws Exception
+ public SameKeyTupleCursor( BTree btree, K key, Comparator<K> comparator ) throws Exception
{
this.key = key;
this.btree = btree;
@@ -87,14 +87,14 @@
* @param element the valueTuple who's value is used to position this Cursor
* @throws Exception if there are failures to position the Cursor
*/
- public void before( Tuple element ) throws Exception
+ public void before( Tuple<K,V> element ) throws Exception
{
browser = btree.browse( element.getValue() );
clearValue();
}
- public void after( Tuple element ) throws Exception
+ public void after( Tuple<K,V> element ) throws Exception
{
browser = btree.browse( element.getValue() );
@@ -107,7 +107,8 @@
*/
while ( browser.getNext( valueTuple ) )
{
- Object next = valueTuple.getKey();
+ //noinspection unchecked
+ K next = ( K ) valueTuple.getKey();
//noinspection unchecked
int nextCompared = comparator.compare( next, element.getKey() );
@@ -201,7 +202,7 @@
}
- public Tuple get() throws Exception
+ public Tuple<K,V> get() throws Exception
{
if ( valueAvailable )
{
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=639279&r1=639278&r2=639279&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 Thu Mar 20 06:05:46 2008
@@ -32,9 +32,9 @@
import org.apache.directory.server.core.partition.impl.btree.Index;
import org.apache.directory.server.core.partition.impl.btree.IndexEntry;
import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import javax.naming.directory.Attributes;
import java.util.Set;
import java.util.HashSet;
import java.io.File;
@@ -51,7 +51,7 @@
{
AttributeTypeRegistry registry;
File dbFileDir;
- Index<String> idx;
+ Index<String,ServerEntry> idx;
@Before
@@ -107,15 +107,15 @@
void initIndex() throws Exception
{
- initIndex( new JdbmIndex<String>() );
+ initIndex( new JdbmIndex<String,ServerEntry>() );
}
- void initIndex( JdbmIndex<String> jdbmIdx ) throws Exception
+ void initIndex( JdbmIndex<String,ServerEntry> jdbmIdx ) throws Exception
{
if ( jdbmIdx == null )
{
- jdbmIdx = new JdbmIndex<String>();
+ jdbmIdx = new JdbmIndex<String,ServerEntry>();
}
jdbmIdx.init( registry.lookup( SchemaConstants.OU_AT ), dbFileDir );
@@ -152,7 +152,7 @@
assertEquals( "ou", idx.getAttributeId() );
destroyIndex();
- initIndex( new JdbmIndex<String>( "foo" ) );
+ initIndex( new JdbmIndex<String,ServerEntry>( "foo" ) );
assertEquals( "foo", idx.getAttributeId() );
}
@@ -183,7 +183,7 @@
public void testWkDirPath() throws Exception
{
// uninitialized index
- JdbmIndex<String> jdbmIndex = new JdbmIndex<String>();
+ JdbmIndex<String,ServerEntry> jdbmIndex = new JdbmIndex<String,ServerEntry>();
jdbmIndex.setWkDirPath( new File( dbFileDir, "foo" ) );
assertEquals( "foo", jdbmIndex.getWkDirPath().getName() );
@@ -200,7 +200,7 @@
assertEquals( dbFileDir, idx.getWkDirPath() );
destroyIndex();
- jdbmIndex = new JdbmIndex<String>();
+ jdbmIndex = new JdbmIndex<String,ServerEntry>();
File wkdir = new File( dbFileDir, "foo" );
wkdir.mkdirs();
jdbmIndex.setWkDirPath( wkdir );
@@ -492,21 +492,21 @@
assertEquals( 3, idx.count() );
// use forward index's cursor
- Cursor<IndexEntry<String, Attributes>> cursor = idx.forwardCursor();
+ Cursor<IndexEntry<String,ServerEntry>> cursor = idx.forwardCursor();
cursor.beforeFirst();
cursor.next();
- IndexEntry<String,Attributes> e1 = cursor.get();
+ IndexEntry<String,ServerEntry> e1 = cursor.get();
assertEquals( 555L, ( long ) e1.getId() );
assertEquals( "bar", e1.getValue() );
cursor.next();
- IndexEntry<String,Attributes> e2 = cursor.get();
+ IndexEntry<String,ServerEntry> e2 = cursor.get();
assertEquals( 333L, ( long ) e2.getId() );
assertEquals( "foo", e2.getValue() );
cursor.next();
- IndexEntry<String,Attributes> e3 = cursor.get();
+ IndexEntry<String,ServerEntry> e3 = cursor.get();
assertEquals( 1234L, ( long ) e3.getId() );
assertEquals( "foo", e3.getValue() );
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=639279&r1=639278&r2=639279&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 Thu Mar 20 06:05:46 2008
@@ -31,13 +31,13 @@
import org.apache.directory.server.schema.registries.*;
import org.apache.directory.server.schema.SerializableComparator;
import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.core.partition.impl.btree.IndexNotFoundException;
-import org.apache.directory.server.constants.CoreSchemaConstants;
import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.constants.SystemSchemaConstants;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import javax.naming.directory.Attributes;
import java.io.File;
import java.util.Set;
import java.util.HashSet;
@@ -134,7 +134,7 @@
JdbmStore store = new JdbmStore();
assertNull( store.getAliasIndex() );
- store.setAliasIndex( new JdbmIndex<String>( "alias" ) );
+ store.setAliasIndex( new JdbmIndex<String,Attributes>( "alias" ) );
assertNotNull( store.getAliasIndex() );
assertEquals( JdbmStore.DEFAULT_CACHE_SIZE, store.getCacheSize() );
@@ -146,11 +146,11 @@
assertNotNull( store.getContextEntry() );
assertNull( store.getExistanceIndex() );
- store.setExistanceIndex( new JdbmIndex<String>( "existence" ) );
+ store.setExistanceIndex( new JdbmIndex<String,Attributes>( "existence" ) );
assertNotNull( store.getExistanceIndex() );
assertNull( store.getHierarchyIndex() );
- store.setHierarchyIndex( new JdbmIndex<Long>( "hierarchy" ) );
+ store.setHierarchyIndex( new JdbmIndex<Long,Attributes>( "hierarchy" ) );
assertNotNull( store.getHierarchyIndex() );
assertNull( store.getName() );
@@ -158,15 +158,15 @@
assertEquals( "foo", store.getName() );
assertNull( store.getNdnIndex() );
- store.setNdnIndex( new JdbmIndex<String>( "ndn" ) );
+ store.setNdnIndex( new JdbmIndex<String,Attributes>( "ndn" ) );
assertNotNull( store.getNdnIndex() );
assertNull( store.getOneAliasIndex() );
- store.setOneAliasIndex( new JdbmIndex<Long>( "oneAlias" ) );
+ store.setOneAliasIndex( new JdbmIndex<Long,Attributes>( "oneAlias" ) );
assertNotNull( store.getNdnIndex() );
assertNull( store.getSubAliasIndex() );
- store.setSubAliasIndex( new JdbmIndex<Long>( "subAlias" ) );
+ store.setSubAliasIndex( new JdbmIndex<Long,Attributes>( "subAlias" ) );
assertNotNull( store.getSubAliasIndex() );
assertNull( store.getSuffixDn() );
@@ -174,7 +174,7 @@
assertEquals( "dc=example,dc=com", store.getSuffixDn() );
assertNull( store.getUpdnIndex() );
- store.setUpdnIndex( new JdbmIndex<String>( "updn" ) );
+ store.setUpdnIndex( new JdbmIndex<String,Attributes>( "updn" ) );
assertNotNull( store.getUpdnIndex() );
assertNull( store.getUpSuffix() );
@@ -204,7 +204,7 @@
public void testSimplePropertiesLocked() throws Exception
{
assertNotNull( store.getAliasIndex() );
- try { store.setAliasIndex( new JdbmIndex<String>( "alias" ) ); fail(); }
+ try { store.setAliasIndex( new JdbmIndex<String,Attributes>( "alias" ) ); fail(); }
catch( IllegalStateException e ) {}
assertEquals( 10, store.getCacheSize() );
@@ -216,11 +216,11 @@
catch( IllegalStateException e ) {}
assertNotNull( store.getExistanceIndex() );
- try { store.setExistanceIndex( new JdbmIndex<String>( "existence" ) ); fail(); }
+ try { store.setExistanceIndex( new JdbmIndex<String,Attributes>( "existence" ) ); fail(); }
catch( IllegalStateException e ) {}
assertNotNull( store.getHierarchyIndex() );
- try { store.setHierarchyIndex( new JdbmIndex<Long>( "hierarchy" ) ); fail(); }
+ try { store.setHierarchyIndex( new JdbmIndex<Long,Attributes>( "hierarchy" ) ); fail(); }
catch( IllegalStateException e ) {}
assertNotNull( store.getName() );
@@ -228,15 +228,15 @@
catch( IllegalStateException e ) {}
assertNotNull( store.getNdnIndex() );
- try { store.setNdnIndex( new JdbmIndex<String>( "ndn" ) ); fail(); }
+ try { store.setNdnIndex( new JdbmIndex<String,Attributes>( "ndn" ) ); fail(); }
catch( IllegalStateException e ) {}
assertNotNull( store.getOneAliasIndex() );
- try { store.setOneAliasIndex( new JdbmIndex<Long>( "oneAlias" ) ); fail(); }
+ try { store.setOneAliasIndex( new JdbmIndex<Long,Attributes>( "oneAlias" ) ); fail(); }
catch( IllegalStateException e ) {}
assertNotNull( store.getSubAliasIndex() );
- try { store.setSubAliasIndex( new JdbmIndex<Long>( "subAlias" ) ); fail(); }
+ try { store.setSubAliasIndex( new JdbmIndex<Long,Attributes>( "subAlias" ) ); fail(); }
catch( IllegalStateException e ) {}
assertNotNull( store.getSuffixDn() );
@@ -244,7 +244,7 @@
catch( IllegalStateException e ) {}
assertNotNull( store.getUpdnIndex() );
- try { store.setUpdnIndex( new JdbmIndex<String>( "updn" ) ); fail(); }
+ try { store.setUpdnIndex( new JdbmIndex<String,Attributes>( "updn" ) ); fail(); }
catch( IllegalStateException e ) {}
Iterator<String> systemIndices = store.systemIndices();
for ( int ii = 0; ii < 7; ii++ )
@@ -290,10 +290,24 @@
@Test
- public void testEmptyStore() throws Exception
+ public void testFreshStore() throws Exception
{
LdapDN dn = new LdapDN( "dc=example,dc=com" );
dn.normalize( attributeRegistry.getNormalizerMapping() );
assertEquals( 1L, ( long ) store.getEntryId( dn.toNormName() ) );
+ assertEquals( 1, store.count() );
+// assertEquals( "dc=example,dc=com", store.getEntryUpdn( "dc=example,dc=com" ) );
+ }
+
+
+ @Test
+ public void testEntryOperations() throws Exception
+ {
+ LdapDN dn = new LdapDN( "ou=Engineering,dc=example,dc=com" );
+ dn.normalize( attributeRegistry.getNormalizerMapping() );
+ DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+ entry.add( "objectClass", "top", "organizationalUnit" );
+ entry.add( "ou", "Engineering" );
+ store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
}
}