Search in sources :

Example 1 with ParseException

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());
}
Also used : Expression(org.apache.phoenix.expression.Expression) ParseException(org.apache.phoenix.parse.ParseException)

Aggregations

Expression (org.apache.phoenix.expression.Expression)1 ParseException (org.apache.phoenix.parse.ParseException)1