Search in sources :

Example 1 with Limit

use of com.yahoo.prelude.query.Limit 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)));
    }
}
Also used : RangeItem(com.yahoo.prelude.query.RangeItem) IntItem(com.yahoo.prelude.query.IntItem) Limit(com.yahoo.prelude.query.Limit) NonNull(edu.umd.cs.findbugs.annotations.NonNull)

Aggregations

IntItem (com.yahoo.prelude.query.IntItem)1 Limit (com.yahoo.prelude.query.Limit)1 RangeItem (com.yahoo.prelude.query.RangeItem)1 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1