Package org.apache.phoenix.expression

Examples of org.apache.phoenix.expression.Expression.evaluate()


     * @throws IOException
     */
    public static ImmutableBytesPtr getConcatenatedValue(Tuple result, List<Expression> expressions) throws IOException {
        ImmutableBytesPtr value = new ImmutableBytesPtr(ByteUtil.EMPTY_BYTE_ARRAY);
        Expression expression = expressions.get(0);
        boolean evaluated = expression.evaluate(result, value);
       
        if (expressions.size() == 1) {
            if (!evaluated) {
                value.set(ByteUtil.EMPTY_BYTE_ARRAY);
            }
View Full Code Here


                    if (!expression.getDataType().isFixedWidth()) {
                        output.write(QueryConstants.SEPARATOR_BYTE);
                    }
                    expression = expressions.get(i);
                    // TODO: should we track trailing null values and omit the separator bytes?
                    if (expression.evaluate(result, value)) {
                        output.write(value.get(), value.getOffset(), value.getLength());
                    } else if (i < expressions.size()-1 && expression.getDataType().isFixedWidth()) {
                        // This should never happen, because any non terminating nullable fixed width type (i.e. INT or LONG) is
                        // converted to a variable length type (i.e. DECIMAL) to allow an empty byte array to represent null.
                        throw new DoNotRetryIOException("Non terminating null value found for fixed width expression (" + expression + ") in row: " + result);
View Full Code Here

            }
        }
        Expression expression = new LikeExpression(children);
        if (node.isConstant()) {
            ImmutableBytesWritable ptr = context.getTempPtr();
            if (!expression.evaluate(null, ptr)) {
                return LiteralExpression.NULL_EXPRESSION;
            } else {
                return LiteralExpression.newConstant(Boolean.TRUE.equals(PDataType.BOOLEAN.toObject(ptr)) ^ node.isNegate());
            }
        }
View Full Code Here

            ParseNode childNode = node.getChildren().get(i);
            if (childNode instanceof BindParseNode) {
                context.getBindManager().addParamMetaData((BindParseNode)childNode, firstChild);
            }
        }
        if (firstChildNode.isConstant() && firstChild.evaluate(null, ptr) && ptr.getLength() == 0) {
            return LiteralExpression.newConstant(null, PDataType.BOOLEAN);
        }
       
        Expression e = InListExpression.create(inChildren, ptr);
        if (node.isNegate()) {
View Full Code Here

        Expression e = InListExpression.create(inChildren, ptr);
        if (node.isNegate()) {
            e = new NotExpression(e);
        }
        if (node.isConstant()) {
            if (!e.evaluate(null, ptr) || ptr.getLength() == 0) {
                return LiteralExpression.newConstant(null, e.getDataType());
            }
            Object value = e.getDataType().toObject(ptr);
            return LiteralExpression.newConstant(value, e.getDataType());
        }
View Full Code Here

        ImmutableBytesWritable ptr = context.getTempPtr();

        // If all children are literals, just evaluate now
        if (isLiteral) {
            // We can use null here because we don't need any row/tuple data when evaluating literals
            expression.evaluate(null,ptr);
            return LiteralExpression. newConstant(expression.getDataType().toObject(ptr), expression.getDataType());
        } else if (isNull) {
            return LiteralExpression. newConstant(null, expression.getDataType());
        }
        // Otherwise create and return the expression
View Full Code Here

        if (sourceStr == null) {
            return false;
        }

        Expression offsetExpression = getOffsetExpression();
        if (!offsetExpression.evaluate(tuple, ptr)) {
            return false;
        }
        int offset = offsetExpression.getDataType().getCodec().decodeInt(ptr, offsetExpression.getColumnModifier());

        int strlen = sourceStr.length();
View Full Code Here

    }
   
    @Override
    public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
        Expression child = children.get(0);
        if (!child.evaluate(tuple, ptr)) {
            return false;
        }
        if (ptr.getLength() == 0) {
            return true;
        }
View Full Code Here

    }

    @Override
    public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
        Expression arg = getChildren().get(0);
        if (!arg.evaluate(tuple, ptr)) {
            return false;
        }

        int targetOffset = ptr.getLength();
        if (targetOffset == 0) {
View Full Code Here

        // Can't parse if there is no replacement pattern.
        if (pattern == null) {
            return false;
        }
        Expression sourceStrExpression = getSourceStrExpression();
        if (!sourceStrExpression.evaluate(tuple, ptr)) {
            return false;
        }
        String sourceStr = (String)PDataType.VARCHAR.toObject(ptr, sourceStrExpression.getColumnModifier());
        if (sourceStr == null) {
            return false;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.