use of com.yahoo.search.grouping.request.BucketValue 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()));
}
}
Aggregations