Record maxRec = factory.createKeyOnly() ;
// Set the prefixes.
for ( int i = 0 ; i < pattern.size() ; i++ )
{
NodeId X = pattern.get(i) ;
if ( NodeId.isAny(X) )
{
X = null ;
// No longer seting leading key slots.
leading = false ;
continue ;
}
numSlots++ ;
if ( leading )
{
leadingIdx = i ;
Bytes.setLong(X.getId(), minRec.getKey(), i*SizeOfNodeId) ;
Bytes.setLong(X.getId(), maxRec.getKey(), i*SizeOfNodeId) ;
}
}
// Is it a simple existence test?
if ( numSlots == pattern.size() )
{
if ( index.contains(minRec) )
return new SingletonIterator<Tuple<NodeId>>(pattern) ;
else
return new NullIterator<Tuple<NodeId>>() ;
}
Iterator<Record> iter = null ;
if ( leadingIdx < 0 )
{
if ( ! fullScanAllowed )
return null ;
//System.out.println("Full scan") ;
// Full scan necessary
iter = index.iterator() ;
}
else
{
// Adjust the maxRec.
NodeId X = pattern.get(leadingIdx) ;
// Set the max Record to the leading NodeIds, +1.
// Example, SP? inclusive to S(P+1)? exclusive where ? is zero.
Bytes.setLong(X.getId()+1, maxRec.getKey(), leadingIdx*SizeOfNodeId) ;
iter = index.iterator(minRec, maxRec) ;
}
Iterator<Tuple<NodeId>> tuples = Iter.map(iter, transformToTuple) ;