Search in sources :

Example 1 with RawBucketResultNode

use of com.yahoo.searchlib.expression.RawBucketResultNode 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)

Example 2 with RawBucketResultNode

use of com.yahoo.searchlib.expression.RawBucketResultNode in project vespa by vespa-engine.

the class ExpressionConverter method toBucketList.

private ResultNodeVector toBucketList(PredefinedFunction fnc) {
    ResultNodeVector ret = null;
    for (int i = 0, len = fnc.getNumBuckets(); i < len; ++i) {
        BucketResultNode bucket = toBucket(fnc.getBucket(i));
        if (ret == null) {
            if (bucket instanceof FloatBucketResultNode) {
                ret = new FloatBucketResultNodeVector();
            } else if (bucket instanceof IntegerBucketResultNode) {
                ret = new IntegerBucketResultNodeVector();
            } else if (bucket instanceof RawBucketResultNode) {
                ret = new RawBucketResultNodeVector();
            } else {
                ret = new StringBucketResultNodeVector();
            }
        }
        ret.add(bucket);
    }
    return ret;
}
Also used : FloatBucketResultNode(com.yahoo.searchlib.expression.FloatBucketResultNode) FloatBucketResultNodeVector(com.yahoo.searchlib.expression.FloatBucketResultNodeVector) IntegerBucketResultNodeVector(com.yahoo.searchlib.expression.IntegerBucketResultNodeVector) FloatBucketResultNodeVector(com.yahoo.searchlib.expression.FloatBucketResultNodeVector) ResultNodeVector(com.yahoo.searchlib.expression.ResultNodeVector) StringBucketResultNodeVector(com.yahoo.searchlib.expression.StringBucketResultNodeVector) RawBucketResultNodeVector(com.yahoo.searchlib.expression.RawBucketResultNodeVector) IntegerBucketResultNode(com.yahoo.searchlib.expression.IntegerBucketResultNode) BucketResultNode(com.yahoo.searchlib.expression.BucketResultNode) FloatBucketResultNode(com.yahoo.searchlib.expression.FloatBucketResultNode) RawBucketResultNode(com.yahoo.searchlib.expression.RawBucketResultNode) StringBucketResultNode(com.yahoo.searchlib.expression.StringBucketResultNode) IntegerBucketResultNode(com.yahoo.searchlib.expression.IntegerBucketResultNode) StringBucketResultNodeVector(com.yahoo.searchlib.expression.StringBucketResultNodeVector) IntegerBucketResultNodeVector(com.yahoo.searchlib.expression.IntegerBucketResultNodeVector) RawBucketResultNode(com.yahoo.searchlib.expression.RawBucketResultNode) RawBucketResultNodeVector(com.yahoo.searchlib.expression.RawBucketResultNodeVector)

Aggregations

FloatBucketResultNode (com.yahoo.searchlib.expression.FloatBucketResultNode)2 IntegerBucketResultNode (com.yahoo.searchlib.expression.IntegerBucketResultNode)2 RawBucketResultNode (com.yahoo.searchlib.expression.RawBucketResultNode)2 StringBucketResultNode (com.yahoo.searchlib.expression.StringBucketResultNode)2 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 BucketResultNode (com.yahoo.searchlib.expression.BucketResultNode)1 FloatBucketResultNodeVector (com.yahoo.searchlib.expression.FloatBucketResultNodeVector)1 IntegerBucketResultNodeVector (com.yahoo.searchlib.expression.IntegerBucketResultNodeVector)1 RawBucketResultNodeVector (com.yahoo.searchlib.expression.RawBucketResultNodeVector)1 RawResultNode (com.yahoo.searchlib.expression.RawResultNode)1 ResultNodeVector (com.yahoo.searchlib.expression.ResultNodeVector)1 StringBucketResultNodeVector (com.yahoo.searchlib.expression.StringBucketResultNodeVector)1 StringResultNode (com.yahoo.searchlib.expression.StringResultNode)1