Search in sources :

Example 1 with RawValue

use of com.yahoo.search.grouping.request.RawValue in project vespa by vespa-engine.

the class ExpressionConverter method toBucket.

private BucketResultNode toBucket(GroupingExpression exp) {
    if (!(exp instanceof BucketValue)) {
        throw new UnsupportedOperationException("Can not convert '" + exp + "' to a bucket.");
    }
    ConstantValue<?> begin = ((BucketValue) exp).getFrom();
    ConstantValue<?> end = ((BucketValue) exp).getTo();
    if (begin instanceof DoubleValue || end instanceof DoubleValue) {
        return new FloatBucketResultNode(begin instanceof InfiniteValue ? FloatResultNode.getNegativeInfinity().getFloat() : Double.valueOf(begin.toString()), end instanceof InfiniteValue ? FloatResultNode.getPositiveInfinity().getFloat() : Double.valueOf(end.toString()));
    } else if (begin instanceof LongValue || end instanceof LongValue) {
        return new IntegerBucketResultNode(begin instanceof InfiniteValue ? IntegerResultNode.getNegativeInfinity().getInteger() : Long.valueOf(begin.toString()), end instanceof InfiniteValue ? IntegerResultNode.getPositiveInfinity().getInteger() : Long.valueOf(end.toString()));
    } else if (begin instanceof StringValue || end instanceof StringValue) {
        return new StringBucketResultNode(begin instanceof InfiniteValue ? StringResultNode.getNegativeInfinity() : new StringResultNode((String) begin.getValue()), end instanceof InfiniteValue ? StringResultNode.getPositiveInfinity() : new StringResultNode((String) end.getValue()));
    } else {
        return new RawBucketResultNode(begin instanceof InfiniteValue ? RawResultNode.getNegativeInfinity() : new RawResultNode(((RawValue) begin).getValue().getBytes()), end instanceof InfiniteValue ? RawResultNode.getPositiveInfinity() : new RawResultNode(((RawValue) end).getValue().getBytes()));
    }
}
Also used : IntegerBucketResultNode(com.yahoo.searchlib.expression.IntegerBucketResultNode) BucketValue(com.yahoo.search.grouping.request.BucketValue) FloatBucketResultNode(com.yahoo.searchlib.expression.FloatBucketResultNode) InfiniteValue(com.yahoo.search.grouping.request.InfiniteValue) DoubleValue(com.yahoo.search.grouping.request.DoubleValue) RawResultNode(com.yahoo.searchlib.expression.RawResultNode) LongValue(com.yahoo.search.grouping.request.LongValue) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) StringBucketResultNode(com.yahoo.searchlib.expression.StringBucketResultNode) StringValue(com.yahoo.search.grouping.request.StringValue) RawBucketResultNode(com.yahoo.searchlib.expression.RawBucketResultNode) RawValue(com.yahoo.search.grouping.request.RawValue)

Aggregations

BucketValue (com.yahoo.search.grouping.request.BucketValue)1 DoubleValue (com.yahoo.search.grouping.request.DoubleValue)1 InfiniteValue (com.yahoo.search.grouping.request.InfiniteValue)1 LongValue (com.yahoo.search.grouping.request.LongValue)1 RawValue (com.yahoo.search.grouping.request.RawValue)1 StringValue (com.yahoo.search.grouping.request.StringValue)1 FloatBucketResultNode (com.yahoo.searchlib.expression.FloatBucketResultNode)1 IntegerBucketResultNode (com.yahoo.searchlib.expression.IntegerBucketResultNode)1 RawBucketResultNode (com.yahoo.searchlib.expression.RawBucketResultNode)1 RawResultNode (com.yahoo.searchlib.expression.RawResultNode)1 StringBucketResultNode (com.yahoo.searchlib.expression.StringBucketResultNode)1 StringResultNode (com.yahoo.searchlib.expression.StringResultNode)1