use of com.yahoo.prelude.query.RangeItem in project vespa by vespa-engine.
the class RangeItemTestCase method testRangeConstruction.
@Test
public void testRangeConstruction() {
verifyRange(new RangeItem(5, 7, 9, "a", true), 9, true);
verifyRange(new RangeItem(5, 7, "a", true), 0, true);
verifyRange(new RangeItem(5, 7, "a"), 0, false);
}
use of com.yahoo.prelude.query.RangeItem in project vespa by vespa-engine.
the class YqlParser method instantiateRangeItem.
@NonNull
private IntItem instantiateRangeItem(List<OperatorNode<ExpressionOperator>> args, OperatorNode<ExpressionOperator> spec) {
Preconditions.checkArgument(args.size() == 3, "Expected 3 arguments, got %s.", args.size());
Number lowerArg = getBound(args.get(1));
Number upperArg = getBound(args.get(2));
String bounds = getAnnotation(spec, BOUNDS, String.class, null, "whether bounds should be open or closed");
// TODO: add support for implicit transforms
if (bounds == null) {
return new RangeItem(lowerArg, upperArg, getIndex(args.get(0)));
} else {
Limit from;
Limit to;
if (BOUNDS_OPEN.equals(bounds)) {
from = new Limit(lowerArg, false);
to = new Limit(upperArg, false);
} else if (BOUNDS_LEFT_OPEN.equals(bounds)) {
from = new Limit(lowerArg, false);
to = new Limit(upperArg, true);
} else if (BOUNDS_RIGHT_OPEN.equals(bounds)) {
from = new Limit(lowerArg, true);
to = new Limit(upperArg, false);
} else {
throw newUnexpectedArgumentException(bounds, BOUNDS_OPEN, BOUNDS_LEFT_OPEN, BOUNDS_RIGHT_OPEN);
}
return new IntItem(from, to, getIndex(args.get(0)));
}
}