You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2010/03/07 21:33:09 UTC
svn commit: r920097 - in /directory/apacheds/trunk:
avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/
jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
ldif-partition/src/main/java/org/apache...
Author: seelmann
Date: Sun Mar 7 20:33:09 2010
New Revision: 920097
URL: http://svn.apache.org/viewvc?rev=920097&view=rev
Log:
Fix for DIRSERVER-1465 (objectClass, entryUUID, entryCSN indices not used in search optimizer)
o added hasIndexOn() and getIndex() to Store interface which combines user and system indices
o use those new methods in the DefaultOptimizer, Cursors, and Evaluators
o optimization in PresenceEvaluator: for system indices (objectClass,entryUUID,entryCSN) it always evaluates to true
Modified:
directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java
directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java
directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java (original)
+++ directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java Sun Mar 7 20:33:09 2010
@@ -595,7 +595,34 @@
}
throw new IndexNotFoundException( I18n.err( I18n.ERR_2, id, name ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Index<?, E, Long> getIndex( String id ) throws IndexNotFoundException
+ {
+ try
+ {
+ id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
+ }
+ catch ( NamingException e )
+ {
+ LOG.error( I18n.err( I18n.ERR_1, id ), e.getLocalizedMessage() );
+ throw new IndexNotFoundException( I18n.err( I18n.ERR_1, id ), id, e );
+ }
+ if ( userIndices.containsKey( id ) )
+ {
+ return userIndices.get( id );
+ }
+ if ( systemIndices.containsKey( id ) )
+ {
+ return systemIndices.get( id );
+ }
+
+ throw new IndexNotFoundException( I18n.err( I18n.ERR_2, id, name ) );
}
@@ -644,6 +671,15 @@
/**
* {@inheritDoc}
*/
+ public boolean hasIndexOn( String id ) throws Exception
+ {
+ return hasUserIndexOn( id ) || hasSystemIndexOn( id );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public boolean hasSystemIndexOn( String id ) throws Exception
{
return systemIndices.containsKey( id );
Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Sun Mar 7 20:33:09 2010
@@ -854,6 +854,12 @@
}
+ public boolean hasIndexOn( String id ) throws NamingException
+ {
+ return hasUserIndexOn( id ) || hasSystemIndexOn( id );
+ }
+
+
public boolean hasUserIndexOn( String id ) throws NamingException
{
return userIndices.containsKey( schemaManager.getAttributeTypeRegistry().getOidByName( id ) );
@@ -866,6 +872,32 @@
}
+ public Index<?, E, Long> getIndex( String id ) throws IndexNotFoundException
+ {
+ try
+ {
+ id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
+ }
+ catch ( NamingException e )
+ {
+ String msg = I18n.err( I18n.ERR_128, id );
+ LOG.error( msg, e );
+ throw new IndexNotFoundException( msg, id, e );
+ }
+
+ if ( userIndices.containsKey( id ) )
+ {
+ return userIndices.get( id );
+ }
+ if ( systemIndices.containsKey( id ) )
+ {
+ return systemIndices.get( id );
+ }
+
+ throw new IndexNotFoundException( I18n.err( I18n.ERR_3, id, name ) );
+ }
+
+
public Index<?, E, Long> getUserIndex( String id ) throws IndexNotFoundException
{
try
Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java Sun Mar 7 20:33:09 2010
@@ -401,6 +401,12 @@
}
+ public Index<?, E, Long> getIndex( String id ) throws IndexNotFoundException
+ {
+ return wrappedStore.getIndex( id );
+ }
+
+
public Index<?, E, Long> getSystemIndex( String id ) throws IndexNotFoundException
{
return wrappedStore.getSystemIndex( id );
@@ -425,6 +431,12 @@
}
+ public boolean hasIndexOn( String id ) throws Exception
+ {
+ return wrappedStore.hasIndexOn( id );
+ }
+
+
public boolean hasSystemIndexOn( String id ) throws Exception
{
return wrappedStore.hasSystemIndexOn( id );
Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java (original)
+++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java Sun Mar 7 20:33:09 2010
@@ -377,6 +377,16 @@
/**
+ * Tells if an index is already present in the User's <strong>or</strong> System's index list
+ * @param id The index we are looking for
+ * @return <code>true</code> if the index is already present in the
+ * User's <strong>or</strong> System's index list
+ * @throws Exception If something went wrong
+ */
+ boolean hasIndexOn( String id ) throws Exception;
+
+
+ /**
* Tells if an index is already present in the User's index list
* @param id The index we are looking for
* @return <code>true</code> if the index is already present in the
@@ -397,6 +407,15 @@
/**
+ * Get the user <strong>or</strong> system index associated with the given name
+ * @param id The index name we are looking for
+ * @return The associated user <strong>or</strong> system index
+ * @throws IndexNotFoundException If the index does not exist
+ */
+ Index<?, E, ID> getIndex( String id ) throws IndexNotFoundException;
+
+
+ /**
* Get the user index associated with the given name
* @param id The index name we are looking for
* @return The associated user index
@@ -406,9 +425,9 @@
/**
- * Get the user index associated with the given name
+ * Get the system index associated with the given name
* @param id The index name we are looking for
- * @return The associated user index
+ * @return The associated system index
* @throws IndexNotFoundException If the index does not exist
*/
Index<?, E, ID> getSystemIndex( String id ) throws IndexNotFoundException;
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java Sun Mar 7 20:33:09 2010
@@ -60,16 +60,16 @@
private boolean available = false;
+ @SuppressWarnings("unchecked")
public ApproximateCursor( Store<ServerEntry, ID> db, ApproximateEvaluator<V, ID> approximateEvaluator ) throws Exception
{
this.approximateEvaluator = approximateEvaluator;
String attribute = approximateEvaluator.getExpression().getAttribute();
Value<V> value = approximateEvaluator.getExpression().getValue();
- if ( db.hasUserIndexOn( attribute ) )
+ if ( db.hasIndexOn( attribute ) )
{
- //noinspection unchecked
- Index<V, ServerEntry, ID> index = ( Index<V, ServerEntry, ID> ) db.getUserIndex( attribute );
+ Index<V, ServerEntry, ID> index = ( Index<V, ServerEntry, ID> ) db.getIndex( attribute );
userIdxCursor = index.forwardCursor( value.get() );
ndnIdxCursor = null;
}
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java Sun Mar 7 20:33:09 2010
@@ -56,6 +56,7 @@
private final Index<T, ServerEntry, ID> idx;
+ @SuppressWarnings("unchecked")
public ApproximateEvaluator( ApproximateNode<T> node, Store<ServerEntry, ID> db, SchemaManager schemaManager )
throws Exception
{
@@ -63,10 +64,9 @@
this.node = node;
this.schemaManager = schemaManager;
- if ( db.hasUserIndexOn( node.getAttribute() ) )
+ if ( db.hasIndexOn( node.getAttribute() ) )
{
- //noinspection unchecked
- idx = ( Index<T, ServerEntry, ID> ) db.getUserIndex( node.getAttribute() );
+ idx = ( Index<T, ServerEntry, ID> ) db.getIndex( node.getAttribute() );
type = null;
normalizer = null;
ldapComparator = null;
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java Sun Mar 7 20:33:09 2010
@@ -273,9 +273,9 @@
@SuppressWarnings("unchecked")
private <V> long getEqualityScan( SimpleNode<V> node ) throws Exception
{
- if ( db.hasUserIndexOn( node.getAttribute() ) )
+ if ( db.hasIndexOn( node.getAttribute() ) )
{
- Index<V, E, ID> idx = ( Index<V, E, ID> ) db.getUserIndex( node.getAttribute() );
+ Index<V, E, ID> idx = ( Index<V, E, ID> ) db.getIndex( node.getAttribute() );
return idx.count( node.getValue().get() );
}
@@ -296,9 +296,9 @@
@SuppressWarnings("unchecked")
private <V> long getGreaterLessScan( SimpleNode<V> node, boolean isGreaterThan ) throws Exception
{
- if ( db.hasUserIndexOn( node.getAttribute() ) )
+ if ( db.hasIndexOn( node.getAttribute() ) )
{
- Index<V, E, ID> idx = ( Index<V, E, ID> ) db.getUserIndex( node.getAttribute() );
+ Index<V, E, ID> idx = ( Index<V, E, ID> ) db.getIndex( node.getAttribute() );
if ( isGreaterThan )
{
return idx.greaterThanCount( node.getValue().get() );
@@ -326,9 +326,9 @@
@SuppressWarnings("unchecked")
private long getFullScan( LeafNode node ) throws Exception
{
- if ( db.hasUserIndexOn( node.getAttribute() ) )
+ if ( db.hasIndexOn( node.getAttribute() ) )
{
- Index idx = db.getUserIndex( node.getAttribute() );
+ Index idx = db.getIndex( node.getAttribute() );
return idx.count();
}
@@ -351,6 +351,13 @@
Index<String, E, ID> idx = db.getPresenceIndex();
return idx.count( node.getAttribute() );
}
+ else if ( db.hasSystemIndexOn( node.getAttribute() ) )
+ {
+ // the system indices (objectClass, entryUUID, entryCSN) are maintained for
+ // each entry, so we could just return the index count
+ Index<?, E, ID> idx = db.getSystemIndex( node.getAttribute() );
+ return idx.count();
+ }
return Long.MAX_VALUE;
}
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java Sun Mar 7 20:33:09 2010
@@ -66,9 +66,9 @@
String attribute = equalityEvaluator.getExpression().getAttribute();
Value<V> value = equalityEvaluator.getExpression().getValue();
- if ( db.hasUserIndexOn( attribute ) )
+ if ( db.hasIndexOn( attribute ) )
{
- Index<V, ServerEntry, ID> userIndex = ( Index<V, ServerEntry, ID> ) db.getUserIndex( attribute );
+ Index<V, ServerEntry, ID> userIndex = ( Index<V, ServerEntry, ID> ) db.getIndex( attribute );
userIdxCursor = userIndex.forwardCursor( value.get() );
ndnIdxCursor = null;
}
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java Sun Mar 7 20:33:09 2010
@@ -69,6 +69,7 @@
private final Index<T, ServerEntry, ID> idx;
+ @SuppressWarnings("unchecked")
public EqualityEvaluator( EqualityNode<T> node, Store<ServerEntry, ID> db, SchemaManager schemaManager )
throws Exception
{
@@ -76,10 +77,9 @@
this.node = node;
this.schemaManager = schemaManager;
- if ( db.hasUserIndexOn( node.getAttribute() ) )
+ if ( db.hasIndexOn( node.getAttribute() ) )
{
- //noinspection unchecked
- idx = ( Index<T, ServerEntry, ID> ) db.getUserIndex( node.getAttribute() );
+ idx = ( Index<T, ServerEntry, ID> ) db.getIndex( node.getAttribute() );
type = null;
normalizer = null;
comparator = null;
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java Sun Mar 7 20:33:09 2010
@@ -71,9 +71,9 @@
this.greaterEqEvaluator = greaterEqEvaluator;
String attribute = greaterEqEvaluator.getExpression().getAttribute();
- if ( db.hasUserIndexOn( attribute ) )
+ if ( db.hasIndexOn( attribute ) )
{
- userIdxCursor = ( ( Index<V, ServerEntry, ID> ) db.getUserIndex( attribute ) ).forwardCursor();
+ userIdxCursor = ( ( Index<V, ServerEntry, ID> ) db.getIndex( attribute ) ).forwardCursor();
ndnIdxCursor = null;
}
else
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java Sun Mar 7 20:33:09 2010
@@ -56,6 +56,7 @@
private final Index<Object, ServerEntry, ID> idx;
+ @SuppressWarnings("unchecked")
public GreaterEqEvaluator( GreaterEqNode<T> node, Store<ServerEntry, ID> db, SchemaManager schemaManager )
throws Exception
{
@@ -64,10 +65,9 @@
this.schemaManager = schemaManager;
this.type = schemaManager.lookupAttributeTypeRegistry( node.getAttribute() );
- if ( db.hasUserIndexOn( node.getAttribute() ) )
+ if ( db.hasIndexOn( node.getAttribute() ) )
{
- //noinspection unchecked
- idx = ( Index<Object, ServerEntry, ID> ) db.getUserIndex( node.getAttribute() );
+ idx = ( Index<Object, ServerEntry, ID> ) db.getIndex( node.getAttribute() );
}
else
{
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java Sun Mar 7 20:33:09 2010
@@ -71,9 +71,9 @@
this.lessEqEvaluator = lessEqEvaluator;
String attribute = lessEqEvaluator.getExpression().getAttribute();
- if ( db.hasUserIndexOn( attribute ) )
+ if ( db.hasIndexOn( attribute ) )
{
- userIdxCursor = ( ( Index<V, ServerEntry, ID> ) db.getUserIndex( attribute ) ).forwardCursor();
+ userIdxCursor = ( ( Index<V, ServerEntry, ID> ) db.getIndex( attribute ) ).forwardCursor();
ndnIdxCursor = null;
}
else
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java Sun Mar 7 20:33:09 2010
@@ -56,17 +56,18 @@
private final Index<T, ServerEntry, ID> idx;
- public LessEqEvaluator( LessEqNode<T> node, Store<ServerEntry, ID> db, SchemaManager schemaManager ) throws Exception
+ @SuppressWarnings("unchecked")
+ public LessEqEvaluator( LessEqNode<T> node, Store<ServerEntry, ID> db, SchemaManager schemaManager )
+ throws Exception
{
this.db = db;
this.node = node;
this.schemaManager = schemaManager;
this.type = schemaManager.lookupAttributeTypeRegistry( node.getAttribute() );
- if ( db.hasUserIndexOn( node.getAttribute() ) )
+ if ( db.hasIndexOn( node.getAttribute() ) )
{
- //noinspection unchecked
- idx = ( Index<T, ServerEntry, ID> ) db.getUserIndex( node.getAttribute() );
+ idx = ( Index<T, ServerEntry, ID> ) db.getIndex( node.getAttribute() );
}
else
{
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java Sun Mar 7 20:33:09 2010
@@ -50,6 +50,9 @@
this.presenceEvaluator = presenceEvaluator;
AttributeType type = presenceEvaluator.getAttributeType();
+ // we don't maintain a presence index for objectClass, entryUUID, and entryCSN
+ // as it doesn't make sense because every entry has such an attribute
+ // instead for those attributes and all un-indexed attributes we use the ndn index
if ( db.hasUserIndexOn( type.getOid() ) )
{
presenceCursor = db.getPresenceIndex().forwardCursor( type.getOid() );
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java Sun Mar 7 20:33:09 2010
@@ -119,6 +119,13 @@
// wrapper or the raw normalized value
public boolean evaluateEntry( ServerEntry entry ) throws Exception
{
+ if ( db.hasSystemIndexOn( node.getAttribute() ) )
+ {
+ // we don't maintain a presence index for objectClass, entryUUID, and entryCSN
+ // however as every entry has such an attribute this evaluator always evaluates to true
+ return true;
+ }
+
// get the attribute
ServerAttribute attr = ( ServerAttribute ) entry.get( type );
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java Sun Mar 7 20:33:09 2010
@@ -48,14 +48,15 @@
@SuppressWarnings("unchecked")
- public SubstringCursor( Store<ServerEntry, ID> db, final SubstringEvaluator<ID> substringEvaluator ) throws Exception
+ public SubstringCursor( Store<ServerEntry, ID> db, final SubstringEvaluator<ID> substringEvaluator )
+ throws Exception
{
evaluator = substringEvaluator;
- hasIndex = db.hasUserIndexOn( evaluator.getExpression().getAttribute() );
+ hasIndex = db.hasIndexOn( evaluator.getExpression().getAttribute() );
if ( hasIndex )
{
- wrapped = ( ( Index<String, ServerEntry, ID> ) db.getUserIndex( evaluator.getExpression().getAttribute() ) )
+ wrapped = ( ( Index<String, ServerEntry, ID> ) db.getIndex( evaluator.getExpression().getAttribute() ) )
.forwardCursor();
}
else
Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java Sun Mar 7 20:33:09 2010
@@ -75,6 +75,7 @@
* @param registries the set of registries
* @throws Exception if there are failures accessing resources and the db
*/
+ @SuppressWarnings("unchecked")
public SubstringEvaluator( SubstringNode node, Store<ServerEntry, ID> db, SchemaManager schemaManager )
throws Exception
{
@@ -104,10 +105,9 @@
// compile the regular expression to search for a matching attribute
regex = node.getRegex( normalizer );
- if ( db.hasUserIndexOn( node.getAttribute() ) )
+ if ( db.hasIndexOn( node.getAttribute() ) )
{
- //noinspection unchecked
- idx = ( Index<String, ServerEntry, ID> ) db.getUserIndex( node.getAttribute() );
+ idx = ( Index<String, ServerEntry, ID> ) db.getIndex( node.getAttribute() );
}
else
{
@@ -116,12 +116,12 @@
}
+ @SuppressWarnings("unchecked")
public boolean evaluate( IndexEntry<?, ServerEntry, ID> indexEntry ) throws Exception
{
if ( idx == null )
{
- //noinspection unchecked
return evaluateWithoutIndex( ( IndexEntry<String, ServerEntry, ID> ) indexEntry );
}
else
@@ -136,7 +136,6 @@
if ( idx == null )
{
- //noinspection unchecked
return evaluateWithoutIndex( id );
}
else
Modified: directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java?rev=920097&r1=920096&r2=920097&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java (original)
+++ directory/apacheds/trunk/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java Sun Mar 7 20:33:09 2010
@@ -26,6 +26,8 @@
import static org.junit.Assert.fail;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.directory.server.core.entry.ServerEntry;
@@ -215,8 +217,8 @@
assertEquals( SchemaConstants.CN_AT_OID, cursor.get().getValue() );
node = new PresenceNode( SchemaConstants.OU_AT_OID );
- evaluator = new PresenceEvaluator( node, store, schemaManager );
- cursor = new PresenceCursor( store, evaluator );
+ evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
+ cursor = new PresenceCursor<Long>( store, evaluator );
assertTrue( cursor.isElementReused() );
@@ -258,6 +260,37 @@
@Test
+ public void testSystemIndexedServerEntry() throws Exception
+ {
+ testSystemIndexedServerEntry( SchemaConstants.OBJECT_CLASS_AT_OID );
+ testSystemIndexedServerEntry( SchemaConstants.ENTRY_UUID_AT_OID );
+ testSystemIndexedServerEntry( SchemaConstants.ENTRY_CSN_AT_OID );
+ }
+
+
+ public void testSystemIndexedServerEntry( String oid ) throws Exception
+ {
+ PresenceNode node = new PresenceNode( oid );
+ PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
+ PresenceCursor<Long> cursor = new PresenceCursor<Long>( store, evaluator );
+
+ assertEquals( node, evaluator.getExpression() );
+ assertTrue( cursor.isElementReused() );
+
+ cursor.beforeFirst();
+
+ List<Long> ids = new ArrayList<Long>();
+ while ( cursor.next() && cursor.available() )
+ {
+ ids.add( cursor.get().getId() );
+ }
+ assertEquals( 11, ids.size() );
+ assertFalse( cursor.next() );
+ assertFalse( cursor.available() );
+ }
+
+
+ @Test
public void testNonIndexedServerEntry() throws Exception
{
PresenceNode node = new PresenceNode( SchemaConstants.SN_AT_OID );
@@ -322,8 +355,8 @@
// ----------- organizationName attribute
node = new PresenceNode( SchemaConstants.O_AT_OID );
- evaluator = new PresenceEvaluator( node, store, schemaManager );
- cursor = new PresenceCursor( store, evaluator );
+ evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
+ cursor = new PresenceCursor<Long>( store, evaluator );
assertTrue( cursor.isElementReused() );
@@ -357,6 +390,32 @@
@Test
+ public void testEvaluatorSystemIndexed() throws Exception
+ {
+ testEvaluatorSystemIndexed( SchemaConstants.OBJECT_CLASS_AT_OID );
+ testEvaluatorSystemIndexed( SchemaConstants.ENTRY_UUID_AT_OID );
+ testEvaluatorSystemIndexed( SchemaConstants.ENTRY_CSN_AT_OID );
+ }
+
+
+ private void testEvaluatorSystemIndexed( String oid ) throws Exception
+ {
+ PresenceNode node = new PresenceNode( oid );
+ PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
+
+ ForwardIndexEntry<String, ServerEntry, Long> entry = new ForwardIndexEntry<String, ServerEntry, Long>();
+ // no need to set a value or id, because the evaluator must always evaluate to true
+ // as each entry contains an objectClass, entryUUID, and entryCSN attribute
+ assertTrue( evaluator.evaluate( entry ) );
+
+ entry = new ForwardIndexEntry<String, ServerEntry, Long>();
+ entry.setValue( oid );
+ entry.setId( ( long ) 5 );
+ assertTrue( evaluator.evaluate( entry ) );
+ }
+
+
+ @Test
public void testEvaluatorNotIndexed() throws Exception
{
PresenceNode node = new PresenceNode( SchemaConstants.NAME_AT_OID );