}
}
if(typeConstraint != null){
//boolean useIndexDataFromIterator = false;
JODBIndexingRootAgent indexingRootAgent = _session.getIndexingRootAgent();
ClassDescriptor classDescriptor = _session.getDescriptorForClass((Class)typeConstraint.getObject());
JODBIndexingAgent indexingAgent = null;
if(sortDataCache!=null){
//lookup indexing data to optimize query
SortNodeRecord[] sortRecords = sortDataCache.getSortNodes();
int fieldId = classDescriptor.getFieldIDForName(sortRecords[0]._fullPath);
if(fieldId!=-1){
indexingAgent = indexingRootAgent.getIndexingAgent(fieldId, base);
if(indexingAgent!=null){
indexIterator = indexingAgent.getIndexIterator(sortRecords[0]._orderAscending);
indexedNode = _descendants.get(sortRecords[0]._fullPath);
skipConventionalSorting = sortRecords.length == 1;
}
}
}
if(indexIterator == null){
//search first index
Iterator<String> descendants = _descendants.keySet().iterator();
while (descendants.hasNext() && indexIterator == null) {
String next = descendants.next();
Field field = classDescriptor.getFieldForName(next);
if(field==null){
continue;
}
indexingAgent = indexingRootAgent.getIndexingAgent(field, base);
if(indexingAgent!=null){
indexIterator = indexingAgent.getIndexIterator(true);
indexedNode = _descendants.get(next);
}
}