IndexEntry<ParentIdAndRdn, String> startingPos = new IndexEntry<ParentIdAndRdn, String>();
startingPos.setKey( new ParentIdAndRdn( node.getBaseId(), ( Rdn[] ) null ) );
rdnCursor.before( startingPos );
Cursor<IndexEntry<String, String>> scopeCursor = new ChildrenCursor( db, node.getBaseId(), rdnCursor );
Set<String> candidateSet = searchResult.getCandidateSet();
// Fetch all the UUIDs if we have an index
// And loop on it
while ( scopeCursor.next() )
{
IndexEntry<String, String> indexEntry = scopeCursor.get();
String uuid = indexEntry.getId();
// If the entry is an alias, and we asked for it to be dereferenced,
// we will dereference the alias
if ( searchResult.isDerefAlways() || searchResult.isDerefInSearching() )
{
Dn aliasedDn = db.getAliasIndex().reverseLookup( uuid );
if ( aliasedDn != null )
{
aliasedDn.apply( evaluatorBuilder.getSchemaManager() );
String aliasedId = db.getEntryId( aliasedDn );
// This is an alias. Add it to the set of candidates to process, if it's not already
// present in the candidate set
if ( !candidateSet.contains( aliasedId ) )
{
candidateSet.add( aliasedId );
nbResults++;
}
}
else
{
// This is not an alias
if ( !candidateSet.contains( uuid ) )
{
// The UUID is not present in the Set, we add it
candidateSet.add( uuid );
nbResults++;
}
}
}
else
{
if ( !candidateSet.contains( uuid ) )
{
// The UUID is not present in the Set, we add it
candidateSet.add( uuid );
nbResults++;
}
}
}
scopeCursor.close();
return nbResults;
}