List<OrderEntry> list = plan.getSortOrder();
if (list != null && list.size() == orderings.length) {
sortUsingIndex = true;
for (int i = 0; i < list.size(); i++) {
OrderEntry e = list.get(i);
OrderingImpl o = orderings[i];
DynamicOperandImpl op = o.getOperand();
if (!(op instanceof PropertyValueImpl)) {
// ordered by a function: currently not supported
sortUsingIndex = false;
break;
}
// we only have one selector, so no need to check that
// TODO support joins
String pn = ((PropertyValueImpl) op).getPropertyName();
if (!pn.equals(e.getPropertyName())) {
// ordered by another property
sortUsingIndex = false;
break;
}
if (o.isDescending() != (e.getOrder() == Order.DESCENDING)) {
// ordered ascending versus descending
sortUsingIndex = false;
break;
}
}