use of org.apache.phoenix.parse.ParseException in project phoenix by apache.
the class ArrayIndexFunction method evaluate.
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
Expression indexExpr = children.get(1);
if (!indexExpr.evaluate(tuple, ptr)) {
return false;
} else if (ptr.getLength() == 0) {
return true;
}
// Use Codec to prevent Integer object allocation
int index = PInteger.INSTANCE.getCodec().decodeInt(ptr, indexExpr.getSortOrder());
if (index < 0) {
throw new ParseException("Index cannot be negative :" + index);
}
Expression arrayExpr = children.get(0);
return PArrayDataTypeDecoder.positionAtArrayElement(tuple, ptr, index, arrayExpr, getDataType(), getMaxLength());
}
Aggregations