use of com.yahoo.searchlib.expression.FloatBucketResultNode 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()));
}
}
use of com.yahoo.searchlib.expression.FloatBucketResultNode 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;
}
Aggregations