final NodeState index = indexMeta.getChildNode(indexStorageNodeName);
if (pr.first != null && !pr.first.equals(pr.last)) {
// '>' & '>=' and between use case
ChildNodeEntry firstValueableItem;
Iterable<String> it = Collections.emptyList();
Iterable<ChildNodeEntry> childrenIterable;
if (pr.last == null) {
LOG.debug("> & >= case.");
firstValueableItem = seek(index,
new PredicateGreaterThan(pr.first.getValue(Type.STRING), pr.firstIncluding));
if (firstValueableItem != null) {
if (direction.isAscending()) {
childrenIterable = new SeekedIterable(index, firstValueableItem);
it = new QueryResultsWrapper(filter, indexName, childrenIterable);
} else {
it = new QueryResultsWrapper(filter, indexName, new BetweenIterable(index,
firstValueableItem, pr.first.getValue(Type.STRING), pr.firstIncluding,
direction));
}
}
} else {
String first, last;
boolean includeFirst, includeLast;
first = pr.first.getValue(Type.STRING);
last = pr.last.getValue(Type.STRING);
includeFirst = pr.firstIncluding;
includeLast = pr.lastIncluding;
if (LOG.isDebugEnabled()) {
final String op1 = includeFirst ? ">=" : ">";
final String op2 = includeLast ? "<=" : "<";
LOG.debug("in between case. direction: {} - Condition: (x {} {} AND x {} {})",
new Object[] { direction, op1, first, op2, last });
}
if (direction.equals(OrderDirection.ASC)) {
firstValueableItem = seek(index,
new PredicateGreaterThan(first, includeFirst));
} else {
firstValueableItem = seek(index,
new PredicateLessThan(last, includeLast));
}
LOG.debug("firstValueableItem: {}", firstValueableItem);
if (firstValueableItem != null) {
childrenIterable = new BetweenIterable(index, firstValueableItem, last,
includeLast, direction);
it = new QueryResultsWrapper(filter, indexName, childrenIterable);
}
}
return it;
} else if (pr.last != null && !pr.last.equals(pr.first)) {
// '<' & '<=' use case
final String searchfor = pr.last.getValue(Type.STRING);
final boolean include = pr.lastIncluding;
Predicate<ChildNodeEntry> predicate = new PredicateLessThan(searchfor, include);
LOG.debug("< & <= case. - searchfor: {} - include: {} - predicate: {}",
new Object[] { searchfor, include, predicate });
ChildNodeEntry firstValueableItem = seek(index, predicate);
LOG.debug("firstValuableItem: {}", firstValueableItem);
Iterable<String> it = Collections.emptyList();
if (firstValueableItem != null) {