*/
protected Cursor<Entry> buildCursor( ExprNode root ) throws Exception
{
Evaluator<? extends ExprNode> evaluator = evaluatorBuilder.build( root );
PartitionSearchResult searchResult = new PartitionSearchResult( schemaManager );
Set<IndexEntry<String, String>> resultSet = new HashSet<IndexEntry<String, String>>();
Set<String> uuids = new HashSet<String>();
searchResult.setCandidateSet( uuids );
long candidates = cursorBuilder.build( root, searchResult );
if ( candidates < Long.MAX_VALUE )
{
for ( String uuid : uuids )
{
IndexEntry<String, String> indexEntry = new IndexEntry<String, String>();
indexEntry.setId( uuid );
resultSet.add( indexEntry );
}
}
else
{
// Full scan : use the MasterTable
Cursor<IndexEntry<String, String>> cursor = new IndexCursorAdaptor( store.getMasterTable().cursor(), true );
while ( cursor.next() )
{
IndexEntry<String, String> indexEntry = cursor.get();
// Here, the indexEntry contains a <UUID, Entry> tuple. Convert it to <UUID, UUID>
IndexEntry<String, String> forwardIndexEntry = new IndexEntry<String, String>();
forwardIndexEntry.setKey( indexEntry.getKey() );
forwardIndexEntry.setId( indexEntry.getKey() );
forwardIndexEntry.setEntry( indexEntry.getEntry() );
resultSet.add( forwardIndexEntry );
}
}
searchResult.setResultSet( resultSet );
searchResult.setEvaluator( evaluator );
// We want all the user attributes plus the entryUUID
SearchOperationContext operationContext =
new SearchOperationContext( session, Dn.ROOT_DSE, SearchScope.ONELEVEL, null, "*", "EntryUUID" );