You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/07/13 16:27:04 UTC
svn commit: r963729 - in /directory/apacheds/trunk:
core-jndi/src/main/java/org/apache/directory/server/core/jndi/
core/src/main/java/org/apache/directory/server/core/normalization/
xdbm-partition/src/main/java/org/apache/directory/server/core/partitio...
Author: elecharny
Date: Tue Jul 13 14:27:04 2010
New Revision: 963729
URL: http://svn.apache.org/viewvc?rev=963729&view=rev
Log:
o Some optimization in the FilterVistor
o Cleaned up the Evaluator, adding some Javadoc
o Minor cleanup
Modified:
directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Tue Jul 13 14:27:04 2010
@@ -336,7 +336,6 @@ public abstract class ServerContext impl
{
OperationManager operationManager = service.getOperationManager();
EntryFilteringCursor results = null;
- OperationContext opContext;
Object typesOnlyObj = getEnvironment().get( "java.naming.ldap.typesOnly" );
boolean typesOnly = false;
@@ -388,10 +387,10 @@ public abstract class ServerContext impl
// It's a Search
// setup the op context and populate with request controls
- searchContext = new SearchOperationContext( session, dn, filter, searchControls );
- searchContext.setAliasDerefMode( aliasDerefMode );
- searchContext.addRequestControls( JndiUtils.fromJndiControls( requestControls ) );
- searchContext.setTypesOnly( typesOnly );
+ searchContext = new SearchOperationContext( session, dn, filter, searchControls );
+ searchContext.setAliasDerefMode( aliasDerefMode );
+ searchContext.addRequestControls( JndiUtils.fromJndiControls( requestControls ) );
+ searchContext.setTypesOnly( typesOnly );
// Inject the referral handling into the operation context
injectReferralControl( searchContext );
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java Tue Jul 13 14:27:04 2010
@@ -191,15 +191,18 @@ public class FilterNormalizingVisitor im
*/
private ExprNode visitSimpleNode( SimpleNode node ) throws LdapException
{
- // still need this check here in case the top level is a leaf node
- // with an undefined attributeType for its attribute
- if ( !ncn.isDefined( node.getAttribute() ) )
+ if ( node.getAttributeType() == null )
{
- return null;
+ // still need this check here in case the top level is a leaf node
+ // with an undefined attributeType for its attribute
+ if ( !ncn.isDefined( node.getAttribute() ) )
+ {
+ return null;
+ }
+
+ node.setAttributeType( schemaManager.lookupAttributeTypeRegistry( node.getAttribute() ) );
}
- node.setAttributeType( schemaManager.lookupAttributeTypeRegistry( node.getAttribute() ) );
-
Value<?> normalized = normalizeValue( node.getAttributeType(), node.getValue() );
if ( normalized == null )
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java Tue Jul 13 14:27:04 2010
@@ -53,6 +53,8 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
import org.apache.directory.shared.ldap.exception.LdapNoSuchObjectException;
import org.apache.directory.shared.ldap.exception.LdapOperationErrorException;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
import org.apache.directory.shared.ldap.name.DN;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.SchemaManager;
@@ -275,9 +277,11 @@ public abstract class BTreePartition<ID>
{
SearchControls searchCtls = searchContext.getSearchControls();
IndexCursor<ID, Entry, ID> underlying;
+ DN dn = searchContext.getDn();
+ AliasDerefMode derefMode = searchContext.getAliasDerefMode();
+ ExprNode filter = searchContext.getFilter();
- underlying = searchEngine.cursor( searchContext.getDn(), searchContext.getAliasDerefMode(), searchContext.getFilter(),
- searchCtls );
+ underlying = searchEngine.cursor( dn, derefMode, filter, searchCtls );
return new BaseEntryFilteringCursor( new ServerEntryCursorAdaptor<ID>( this, underlying ), searchContext );
}
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java Tue Jul 13 14:27:04 2010
@@ -20,16 +20,16 @@
package org.apache.directory.server.xdbm.search.impl;
-import org.apache.directory.shared.ldap.entry.Entry;
-import org.apache.directory.shared.ldap.filter.AndNode;
-import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.server.xdbm.IndexEntry;
-import org.apache.directory.server.xdbm.search.Evaluator;
-
-import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.search.Evaluator;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.filter.AndNode;
+import org.apache.directory.shared.ldap.filter.ExprNode;
/**
@@ -39,8 +39,10 @@ import java.util.Comparator;
*/
public class AndEvaluator<ID> implements Evaluator<AndNode, Entry, ID>
{
+ /** The list of evaluators associated with each of the children */
private final List<Evaluator<? extends ExprNode, Entry, ID>> evaluators;
+ /** The AndNode */
private final AndNode node;
@@ -68,6 +70,7 @@ public class AndEvaluator<ID> implements
List<Evaluator<? extends ExprNode, Entry, ID>> optimized = new ArrayList<Evaluator<? extends ExprNode, Entry, ID>>(
unoptimized.size() );
optimized.addAll( unoptimized );
+
Collections.sort( optimized, new Comparator<Evaluator<?, Entry, ID>>()
{
public int compare( Evaluator<?, Entry, ID> e1, Evaluator<?, Entry, ID> e2 )
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java Tue Jul 13 14:27:04 2010
@@ -46,12 +46,25 @@ import org.apache.directory.shared.ldap.
*/
public class ApproximateEvaluator<T, ID extends Comparable<ID>> implements Evaluator<ApproximateNode<T>, Entry, ID>
{
+ /** The ExprNode to evaluate */
private final ApproximateNode<T> node;
+
+ /** The backend */
private final Store<Entry, ID> db;
+
+ /** The SchemaManager instance */
private final SchemaManager schemaManager;
- private final AttributeType type;
+
+ /** The AttributeType we will use for the evaluation */
+ private final AttributeType attributeType;
+
+ /** The associated normalizer */
private final Normalizer normalizer;
+
+ /** The associated comparator */
private final LdapComparator<? super Object> ldapComparator;
+
+ /** The index to use if any */
private final Index<T, Entry, ID> idx;
@@ -62,20 +75,19 @@ public class ApproximateEvaluator<T, ID
this.db = db;
this.node = node;
this.schemaManager = schemaManager;
+ this.attributeType = node.getAttributeType();
- if ( db.hasIndexOn( node.getAttributeType() ) )
+ if ( db.hasIndexOn( attributeType ) )
{
- idx = ( Index<T, Entry, ID> ) db.getIndex( node.getAttributeType() );
- type = null;
+ idx = ( Index<T, Entry, ID> ) db.getIndex( attributeType );
normalizer = null;
ldapComparator = null;
}
else
{
idx = null;
- type = node.getAttributeType();
- MatchingRule mr = type.getEquality();
+ MatchingRule mr = attributeType.getEquality();
if ( mr == null )
{
@@ -97,7 +109,7 @@ public class ApproximateEvaluator<T, ID
public boolean evaluateEntry( Entry entry ) throws Exception
{
// get the attribute
- EntryAttribute attr = entry.get( type );
+ EntryAttribute attr = entry.get( attributeType );
// if the attribute does not exist just return false
if ( ( attr != null ) && evaluate( attr ) )
@@ -108,13 +120,12 @@ public class ApproximateEvaluator<T, ID
// If we do not have the attribute, loop through the sub classes of
// the attributeType. Perhaps the entry has an attribute value of a
// subtype (descendant) that will produce a match
- if ( schemaManager.getAttributeTypeRegistry().hasDescendants( node.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( attributeType ) )
{
// TODO check to see if descendant handling is necessary for the
// index so we can match properly even when for example a name
// attribute is used instead of more specific commonName
- Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
- node.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( attributeType );
while ( descendants.hasNext() )
{
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java Tue Jul 13 14:27:04 2010
@@ -50,10 +50,19 @@ import org.apache.directory.shared.ldap.
*/
public class EqualityEvaluator<T, ID extends Comparable<ID>> implements Evaluator<EqualityNode<T>, Entry, ID>
{
+ /** The ExprNode to evaluate */
private final EqualityNode<T> node;
+
+ /** The backend */
private final Store<Entry, ID> db;
+
+ /** The SchemaManager instance */
private final SchemaManager schemaManager;
- private final AttributeType type;
+
+ /** The AttributeType we will use for the evaluation */
+ private final AttributeType attributeType;
+
+ /** The associated normalizer */
private final Normalizer normalizer;
/** The comparator to use */
@@ -65,6 +74,7 @@ public class EqualityEvaluator<T, ID ext
/** The default String comparator if no comparator has been defined */
private static final Comparator<String> STRING_COMPARATOR = new StringComparator( null );
+ /** The index to use if any */
private final Index<T, Entry, ID> idx;
@@ -75,24 +85,23 @@ public class EqualityEvaluator<T, ID ext
this.db = db;
this.node = node;
this.schemaManager = schemaManager;
+ this.attributeType = node.getAttributeType();
- if ( db.hasIndexOn( node.getAttributeType() ) )
+ if ( db.hasIndexOn( attributeType ) )
{
- idx = ( Index<T, Entry, ID> ) db.getIndex( node.getAttributeType() );
- type = null;
+ idx = ( Index<T, Entry, ID> ) db.getIndex( attributeType );
normalizer = null;
comparator = null;
}
else
{
idx = null;
- type = node.getAttributeType() ;
- MatchingRule mr = type.getEquality();
+ MatchingRule mr = attributeType.getEquality();
if ( mr == null )
{
- normalizer = new NoOpNormalizer( type.getOid() );
+ normalizer = new NoOpNormalizer( attributeType.getOid() );
comparator = null;
}
else
@@ -133,10 +142,10 @@ public class EqualityEvaluator<T, ID ext
public boolean evaluateEntry( Entry entry ) throws Exception
{
// get the attribute
- EntryAttribute attr = entry.get( type );
+ EntryAttribute attr = entry.get( attributeType );
// if the attribute does not exist just return false
- if ( attr != null && evaluate( attr ) )
+ if ( ( attr != null ) && evaluate( attr ) )
{
return true;
}
@@ -144,13 +153,12 @@ public class EqualityEvaluator<T, ID ext
// If we do not have the attribute, loop through the sub classes of
// the attributeType. Perhaps the entry has an attribute value of a
// subtype (descendant) that will produce a match
- if ( schemaManager.getAttributeTypeRegistry().hasDescendants( node.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( attributeType ) )
{
// TODO check to see if descendant handling is necessary for the
// index so we can match properly even when for example a name
// attribute is used instead of more specific commonName
- Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
- node.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( attributeType );
while ( descendants.hasNext() )
{
@@ -158,7 +166,7 @@ public class EqualityEvaluator<T, ID ext
attr = entry.get( descendant );
- if ( attr != null && evaluate( attr ) )
+ if ( ( attr != null ) && evaluate( attr ) )
{
return true;
}
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java Tue Jul 13 14:27:04 2010
@@ -46,12 +46,25 @@ import org.apache.directory.shared.ldap.
*/
public class GreaterEqEvaluator<T, ID extends Comparable<ID>> implements Evaluator<GreaterEqNode<T>, Entry, ID>
{
+ /** The ExprNode to evaluate */
private final GreaterEqNode<T> node;
+
+ /** The backend */
private final Store<Entry, ID> db;
+
+ /** The SchemaManager instance */
private final SchemaManager schemaManager;
- private final AttributeType type;
+
+ /** The AttributeType we will use for the evaluation */
+ private final AttributeType attributeType;
+
+ /** The associated normalizer */
private final Normalizer normalizer;
+
+ /** The associated comparator */
private final Comparator comparator;
+
+ /** The index to use if any */
private final Index<Object, Entry, ID> idx;
@@ -62,11 +75,11 @@ public class GreaterEqEvaluator<T, ID ex
this.db = db;
this.node = node;
this.schemaManager = schemaManager;
- this.type = node.getAttributeType();
+ this.attributeType = node.getAttributeType();
if ( db.hasIndexOn( node.getAttributeType() ) )
{
- idx = ( Index<Object, Entry, ID> ) db.getIndex( node.getAttributeType() );
+ idx = ( Index<Object, Entry, ID> ) db.getIndex( attributeType );
}
else
{
@@ -79,11 +92,11 @@ public class GreaterEqEvaluator<T, ID ex
* not be. If so then we resort to using the Normalizer and
* Comparator from the equality matchingRule as a last resort.
*/
- MatchingRule mr = type.getOrdering();
+ MatchingRule mr = attributeType.getOrdering();
if ( mr == null )
{
- mr = type.getEquality();
+ mr = attributeType.getEquality();
}
if ( mr == null )
@@ -104,7 +117,7 @@ public class GreaterEqEvaluator<T, ID ex
public AttributeType getAttributeType()
{
- return type;
+ return attributeType;
}
@@ -145,7 +158,7 @@ public class GreaterEqEvaluator<T, ID ex
*/
// get the attribute
- EntryAttribute attr = entry.get( type );
+ EntryAttribute attr = entry.get( attributeType );
// if the attribute exists and has a greater than or equal value return true
//noinspection unchecked
@@ -157,13 +170,12 @@ public class GreaterEqEvaluator<T, ID ex
// If we do not have the attribute, loop through the sub classes of
// the attributeType. Perhaps the entry has an attribute value of a
// subtype (descendant) that will produce a match
- if ( schemaManager.getAttributeTypeRegistry().hasDescendants( node.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( attributeType ) )
{
// TODO check to see if descendant handling is necessary for the
// index so we can match properly even when for example a name
// attribute is used instead of more specific commonName
- Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
- node.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( attributeType );
while ( descendants.hasNext() )
{
@@ -198,10 +210,10 @@ public class GreaterEqEvaluator<T, ID ex
public boolean evaluateEntry( Entry entry ) throws Exception
{
// get the attribute
- EntryAttribute attr = entry.get( type );
+ EntryAttribute attr = entry.get( attributeType );
// if the attribute exists and has a greater than or equal value return true
- if ( attr != null && evaluate( null, attr ) )
+ if ( ( attr != null ) && evaluate( null, attr ) )
{
return true;
}
@@ -209,13 +221,12 @@ public class GreaterEqEvaluator<T, ID ex
// If we do not have the attribute, loop through the sub classes of
// the attributeType. Perhaps the entry has an attribute value of a
// subtype (descendant) that will produce a match
- if ( schemaManager.getAttributeTypeRegistry().hasDescendants( node.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( attributeType ) )
{
// TODO check to see if descendant handling is necessary for the
// index so we can match properly even when for example a name
// attribute is used instead of more specific commonName
- Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
- node.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( attributeType );
while ( descendants.hasNext() )
{
@@ -223,7 +234,7 @@ public class GreaterEqEvaluator<T, ID ex
attr = entry.get( descendant );
- if ( attr != null && evaluate( null, attr ) )
+ if ( ( attr != null ) && evaluate( null, attr ) )
{
return true;
}
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java Tue Jul 13 14:27:04 2010
@@ -46,12 +46,25 @@ import org.apache.directory.shared.ldap.
*/
public class LessEqEvaluator<T, ID extends Comparable<ID>> implements Evaluator<LessEqNode<T>, Entry, ID>
{
+ /** The ExprNode to evaluate */
private final LessEqNode<T> node;
+
+ /** The backend */
private final Store<Entry, ID> db;
+
+ /** The SchemaManager instance */
private final SchemaManager schemaManager;
- private final AttributeType type;
+
+ /** The AttributeType we will use for the evaluation */
+ private final AttributeType attributeType;
+
+ /** The associated normalizer */
private final Normalizer normalizer;
+
+ /** The associated comparator */
private final LdapComparator<? super Object> ldapComparator;
+
+ /** The index to use if any */
private final Index<T, Entry, ID> idx;
@@ -62,11 +75,11 @@ public class LessEqEvaluator<T, ID exten
this.db = db;
this.node = node;
this.schemaManager = schemaManager;
- this.type = node.getAttributeType();
+ this.attributeType = node.getAttributeType();
- if ( db.hasIndexOn( node.getAttributeType() ) )
+ if ( db.hasIndexOn( attributeType ) )
{
- idx = ( Index<T, Entry, ID> ) db.getIndex( node.getAttributeType() );
+ idx = ( Index<T, Entry, ID> ) db.getIndex( attributeType );
}
else
{
@@ -79,11 +92,11 @@ public class LessEqEvaluator<T, ID exten
* not be. If so then we resort to using the Normalizer and
* Comparator from the equality matchingRule as a last resort.
*/
- MatchingRule mr = type.getOrdering();
+ MatchingRule mr = attributeType.getOrdering();
if ( mr == null )
{
- mr = type.getEquality();
+ mr = attributeType.getEquality();
}
if ( mr == null )
@@ -104,7 +117,7 @@ public class LessEqEvaluator<T, ID exten
public AttributeType getAttributeType()
{
- return type;
+ return attributeType;
}
@@ -122,7 +135,7 @@ public class LessEqEvaluator<T, ID exten
public boolean evaluateId( ID id ) throws Exception
{
- if ( idx != null && idx.isDupsEnabled() )
+ if ( ( idx != null ) && idx.isDupsEnabled() )
{
return idx.reverseLessOrEq( id, node.getValue().get() );
}
@@ -133,7 +146,7 @@ public class LessEqEvaluator<T, ID exten
public boolean evaluate( IndexEntry<?, Entry, ID> indexEntry ) throws Exception
{
- if ( idx != null && idx.isDupsEnabled() )
+ if ( ( idx != null ) && idx.isDupsEnabled() )
{
return idx.reverseLessOrEq( indexEntry.getId(), node.getValue().get() );
}
@@ -153,7 +166,7 @@ public class LessEqEvaluator<T, ID exten
}
// get the attribute
- EntryAttribute attr = entry.get( type );
+ EntryAttribute attr = entry.get( attributeType );
// if the attribute does not exist just return false
//noinspection unchecked
@@ -165,13 +178,12 @@ public class LessEqEvaluator<T, ID exten
// If we do not have the attribute, loop through the sub classes of
// the attributeType. Perhaps the entry has an attribute value of a
// subtype (descendant) that will produce a match
- if ( schemaManager.getAttributeTypeRegistry().hasDescendants( node.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( attributeType ) )
{
// TODO check to see if descendant handling is necessary for the
// index so we can match properly even when for example a name
// attribute is used instead of more specific commonName
- Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
- node.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( attributeType );
while ( descendants.hasNext() )
{
@@ -195,10 +207,10 @@ public class LessEqEvaluator<T, ID exten
public boolean evaluateEntry( Entry entry ) throws Exception
{
// get the attribute
- EntryAttribute attr = entry.get( type );
+ EntryAttribute attr = entry.get( attributeType );
// if the attribute does not exist just return false
- if ( attr != null && evaluate( null, attr ) )
+ if ( ( attr != null ) && evaluate( null, attr ) )
{
return true;
}
@@ -206,13 +218,12 @@ public class LessEqEvaluator<T, ID exten
// If we do not have the attribute, loop through the sub classes of
// the attributeType. Perhaps the entry has an attribute value of a
// subtype (descendant) that will produce a match
- if ( schemaManager.getAttributeTypeRegistry().hasDescendants( node.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( attributeType ) )
{
// TODO check to see if descendant handling is necessary for the
// index so we can match properly even when for example a name
// attribute is used instead of more specific commonName
- Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
- node.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( attributeType );
while ( descendants.hasNext() )
{
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java Tue Jul 13 14:27:04 2010
@@ -20,11 +20,11 @@
package org.apache.directory.server.xdbm.search.impl;
-import org.apache.directory.shared.ldap.entry.Entry;
-import org.apache.directory.shared.ldap.filter.NotNode;
-import org.apache.directory.shared.ldap.filter.ExprNode;
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.search.Evaluator;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
/**
@@ -34,7 +34,10 @@ import org.apache.directory.server.xdbm.
*/
public class NotEvaluator<ID> implements Evaluator<NotNode, Entry, ID>
{
+ /** The ExprNode to evaluate */
private final NotNode node;
+
+ /** The Evaluator to use for the inner Node */
private final Evaluator<? extends ExprNode, Entry, ID> childEvaluator;
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java Tue Jul 13 14:27:04 2010
@@ -20,16 +20,16 @@
package org.apache.directory.server.xdbm.search.impl;
-import org.apache.directory.shared.ldap.entry.Entry;
-import org.apache.directory.shared.ldap.filter.OrNode;
-import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.server.xdbm.IndexEntry;
-import org.apache.directory.server.xdbm.search.Evaluator;
-
-import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.List;
+
+import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.search.Evaluator;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
/**
@@ -39,8 +39,10 @@ import java.util.Comparator;
*/
public class OrEvaluator<ID> implements Evaluator<OrNode, Entry, ID>
{
+ /** The list of evaluators associated with each of the children */
private final List<Evaluator<? extends ExprNode, Entry, ID>> evaluators;
+ /** The OrNode */
private final OrNode node;
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java Tue Jul 13 14:27:04 2010
@@ -41,10 +41,19 @@ import org.apache.directory.shared.ldap.
*/
public class PresenceEvaluator<ID extends Comparable<ID>> implements Evaluator<PresenceNode, Entry, ID>
{
+ /** The ExprNode to evaluate */
private final PresenceNode node;
+
+ /** The backend */
private final Store<Entry, ID> db;
- private final AttributeType type;
+
+ /** The AttributeType we will use for the evaluation */
+ private final AttributeType attributeType;
+
+ /** The SchemaManager instance */
private final SchemaManager schemaManager;
+
+ /** The index to use if any */
private final Index<String, Entry, ID> idx;
@@ -54,9 +63,9 @@ public class PresenceEvaluator<ID extend
this.db = db;
this.node = node;
this.schemaManager = schemaManager;
- this.type = node.getAttributeType();
+ this.attributeType = node.getAttributeType();
- if ( db.hasUserIndexOn( node.getAttributeType() ) )
+ if ( db.hasUserIndexOn( attributeType ) )
{
idx = db.getPresenceIndex();
}
@@ -75,7 +84,7 @@ public class PresenceEvaluator<ID extend
public AttributeType getAttributeType()
{
- return type;
+ return attributeType;
}
@@ -85,7 +94,7 @@ public class PresenceEvaluator<ID extend
{
if ( idx != null )
{
- return idx.forward( type.getOid(), indexEntry.getId() );
+ return idx.forward( attributeType.getOid(), indexEntry.getId() );
}
Entry entry = indexEntry.getObject();
@@ -107,7 +116,7 @@ public class PresenceEvaluator<ID extend
{
if ( idx != null )
{
- return idx.forward( type.getOid(), id );
+ return idx.forward( attributeType.getOid(), id );
}
return evaluateEntry( db.lookup( id ) );
@@ -118,7 +127,7 @@ public class PresenceEvaluator<ID extend
// wrapper or the raw normalized value
public boolean evaluateEntry( Entry entry ) throws Exception
{
- if ( db.hasSystemIndexOn( node.getAttributeType() ) )
+ if ( db.hasSystemIndexOn( attributeType ) )
{
// 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
@@ -126,7 +135,7 @@ public class PresenceEvaluator<ID extend
}
// get the attribute
- EntryAttribute attr = entry.get( type );
+ EntryAttribute attr = entry.get( attributeType );
// if the attribute exists just return true
if ( attr != null )
@@ -137,13 +146,12 @@ public class PresenceEvaluator<ID extend
// If we do not have the attribute, loop through the sub classes of
// the attributeType. Perhaps the entry has an attribute value of a
// subtype (descendant) that will produce a match
- if ( schemaManager.getAttributeTypeRegistry().hasDescendants( node.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( attributeType ) )
{
// TODO check to see if descendant handling is necessary for the
// index so we can match properly even when for example a name
// attribute is used instead of more specific commonName
- Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
- node.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( attributeType );
do
{
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java?rev=963729&r1=963728&r2=963729&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java Tue Jul 13 14:27:04 2010
@@ -59,10 +59,13 @@ public class SubstringEvaluator<ID exten
/** The regular expression generated for the SubstringNode pattern */
private final Pattern regex;
- private final AttributeType type;
+ /** The AttributeType we will use for the evaluation */
+ private final AttributeType attributeType;
+ /** The associated normalizer */
private final Normalizer normalizer;
+ /** The index to use if any */
private final Index<String, Entry, ID> idx;
@@ -81,14 +84,13 @@ public class SubstringEvaluator<ID exten
this.db = db;
this.node = node;
this.schemaManager = schemaManager;
+ this.attributeType = node.getAttributeType();
- type = node.getAttributeType();
-
- MatchingRule rule = type.getSubstring();
+ MatchingRule rule = attributeType.getSubstring();
if ( rule == null )
{
- rule = type.getEquality();
+ rule = attributeType.getEquality();
}
if ( rule != null )
@@ -97,12 +99,12 @@ public class SubstringEvaluator<ID exten
}
else
{
- normalizer = new NoOpNormalizer( type.getSyntaxOid() );
+ normalizer = new NoOpNormalizer( attributeType.getSyntaxOid() );
}
// compile the regular expression to search for a matching attribute
// if the attributeType is humanReadable
- if ( type.getSyntax().isHumanReadable() )
+ if ( attributeType.getSyntax().isHumanReadable() )
{
regex = node.getRegex( normalizer );
}
@@ -111,9 +113,9 @@ public class SubstringEvaluator<ID exten
regex = null;
}
- if ( db.hasIndexOn( node.getAttributeType() ) )
+ if ( db.hasIndexOn( attributeType ) )
{
- idx = ( Index<String, Entry, ID> ) db.getIndex( node.getAttributeType() );
+ idx = ( Index<String, Entry, ID> ) db.getIndex( attributeType );
}
else
{
@@ -253,7 +255,7 @@ public class SubstringEvaluator<ID exten
private boolean evaluateWithoutIndex( Entry entry ) throws Exception
{
// get the attribute
- EntryAttribute attr = entry.get( type );
+ EntryAttribute attr = entry.get( attributeType );
// if the attribute exists and the pattern matches return true
if ( attr != null )
@@ -282,13 +284,12 @@ public class SubstringEvaluator<ID exten
// If we do not have the attribute, loop through the descendant
// May be the node Attribute has descendant ?
- if ( schemaManager.getAttributeTypeRegistry().hasDescendants( node.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( attributeType ) )
{
// TODO check to see if descendant handling is necessary for the
// index so we can match properly even when for example a name
// attribute is used instead of more specific commonName
- Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
- node.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( attributeType );
while ( descendants.hasNext() )
{
@@ -345,7 +346,7 @@ public class SubstringEvaluator<ID exten
*/
// get the attribute
- EntryAttribute attr = entry.get( type );
+ EntryAttribute attr = entry.get( attributeType );
// if the attribute exists and the pattern matches return true
if ( attr != null )
@@ -400,13 +401,12 @@ public class SubstringEvaluator<ID exten
// If we do not have the attribute, loop through the descendant
// May be the node Attribute has descendant ?
- if ( schemaManager.getAttributeTypeRegistry().hasDescendants( node.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( attributeType ) )
{
// TODO check to see if descendant handling is necessary for the
// index so we can match properly even when for example a name
// attribute is used instead of more specific commonName
- Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants(
- node.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( attributeType );
while ( descendants.hasNext() )
{