Cursor<IndexEntry<ParentIdAndRdn, String>> rdnCursor = new SingletonIndexCursor<ParentIdAndRdn>(
startingPos );
String parentId = parentIdAndRdn.getParentId();
Cursor<IndexEntry<String, String>> scopeCursor = new DescendantCursor( db, baseId, parentId, 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() )
{
String aliasedDn = db.getAliasIndex().reverseLookup( uuid );
if ( aliasedDn != null )
{
String aliasedId = db.getEntryId( new Dn( searchResult.getSchemaManager(), 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++;
ScopeNode newScopeNode = new ScopeNode(
node.getDerefAliases(),
new Dn( searchResult.getSchemaManager(), aliasedDn ),
aliasedId,
node.getScope() );
nbResults += computeSubLevelScope( newScopeNode, searchResult );
}
}
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;
}