Evaluator<? extends ExprNode> evaluator = null;
if ( filter instanceof ObjectClassNode )
{
ScopeNode node = new ScopeNode( aliasDerefMode, effectiveBase, effectiveBaseId, scope );
evaluator = new BaseLevelScopeEvaluator<Entry>( db, node );
}
else
{
optimizer.annotate( filter );
evaluator = evaluatorBuilder.build( filter );
// Special case if the filter selects no candidate
if ( evaluator == null )
{
ScopeNode node = new ScopeNode( aliasDerefMode, effectiveBase, effectiveBaseId, scope );
evaluator = new BaseLevelScopeEvaluator<Entry>( db, node );
}
}
indexEntry.setEntry( entry );
resultSet.add( indexEntry );
searchResult.setEvaluator( evaluator );
searchResult.setResultSet( resultSet );
return searchResult;
}
// This is not a BaseObject scope search.
// Add the scope node using the effective base to the filter
ExprNode root = null;
if ( filter instanceof ObjectClassNode )
{
root = new ScopeNode( aliasDerefMode, effectiveBase, effectiveBaseId, scope );
}
else
{
root = new AndNode();
( ( AndNode ) root ).getChildren().add( filter );
ExprNode node = new ScopeNode( aliasDerefMode, effectiveBase, effectiveBaseId, scope );
( ( AndNode ) root ).getChildren().add( node );
}
// Annotate the node with the optimizer and return search enumeration.
optimizer.annotate( root );