Examples of PDatum


Examples of org.apache.phoenix.schema.PDatum

        if (index <= 0 || index > params.length) {
            throw new SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND)
                .setMessage("The index is " + index + ". Must be between 1 and " + params.length)
                .build().buildException();
        }
        PDatum param = params[index-1];
       
        if (param == EMPTY_DATUM) {
            //value at params[index-1] was never set.
            throw new SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_VALUE_UNBOUND)
                .setMessage("Parameter at index " + index + " is unbound").build().buildException();
View Full Code Here

Examples of org.apache.phoenix.schema.PDatum

        }
        return param;
    }
    @Override
    public String getParameterClassName(int index) throws SQLException {
        PDatum datum = getParam(index);
        PDataType type = datum == null ? null : datum.getDataType();
        return type == null ? null : type.getJavaClassName();
    }
View Full Code Here

Examples of org.apache.phoenix.schema.PDatum

        }
        return (T)this;
    }

    public void addParam(BindParseNode bind, PDatum datum) throws SQLException {
        PDatum bindDatum = params[bind.getIndex()];
        if (bindDatum != null && bindDatum.getDataType() != null && !datum.getDataType().isCoercibleTo(bindDatum.getDataType())) {
            throw TypeMismatchException.newException(datum.getDataType(), bindDatum.getDataType());
        }
        params[bind.getIndex()] = datum;
    }
View Full Code Here

Examples of org.apache.phoenix.schema.PDatum

    }

    private static RowKeySchema buildSchema(int[] widths) {
        RowKeySchemaBuilder builder = new RowKeySchemaBuilder(10);
        for (final int width : widths) {
            builder.addField(new PDatum() {
                @Override
                public boolean isNullable() {
                    return false;
                }
                @Override
View Full Code Here

Examples of org.apache.phoenix.schema.PDatum

        if (index <= 0 || index > params.length) {
            throw new SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND)
                .setMessage("The index is " + index + ". Must be between 1 and " + params.length)
                .build().buildException();
        }
        PDatum param = params[index-1];
       
        if (param == EMPTY_DATUM) {
            //value at params[index-1] was never set.
            throw new SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_VALUE_UNBOUND)
                .setMessage("Parameter at index " + index + " is unbound").build().buildException();
View Full Code Here

Examples of org.apache.phoenix.schema.PDatum

        }
        return param;
    }
    @Override
    public String getParameterClassName(int index) throws SQLException {
        PDatum datum = getParam(index);
        PDataType type = datum == null ? null : datum.getDataType();
        return type == null ? null : type.getJavaClassName();
    }
View Full Code Here

Examples of org.apache.phoenix.schema.PDatum

        }
        return (T)this;
    }

    public void addParam(BindParseNode bind, PDatum datum) throws SQLException {
        PDatum bindDatum = params[bind.getIndex()];
        if (bindDatum != null && bindDatum.getDataType() != null && !datum.getDataType().isCoercibleTo(bindDatum.getDataType())) {
            throw new TypeMismatchException(datum.getDataType(), bindDatum.getDataType());
        }
        params[bind.getIndex()] = datum;
    }
View Full Code Here

Examples of org.apache.phoenix.schema.PDatum

        ImmutableBytesWritable ptr = context.getTempPtr();
        PDataType firstChildType = firstChild.getDataType();
        ParseNode firstChildNode = node.getChildren().get(0);
       
        if (firstChildNode instanceof BindParseNode) {
            PDatum datum = firstChild;
            if (firstChildType == null) {
                datum = inferBindDatum(inChildren);
            }
            context.getBindManager().addParamMetaData((BindParseNode)firstChildNode, datum);
        }
View Full Code Here

Examples of org.apache.phoenix.schema.PDatum

        }       
    };

    private static PDatum inferBindDatum(List<Expression> children) {
        boolean isChildTypeUnknown = false;
        PDatum datum = children.get(1);
        for (int i = 2; i < children.size(); i++) {
            Expression child = children.get(i);
            PDataType childType = child.getDataType();
            if (childType == null) {
                isChildTypeUnknown = true;
            } else if (datum.getDataType() == null) {
                datum = child;
                isChildTypeUnknown = true;
            } else if (datum.getDataType() == childType || childType.isCoercibleTo(datum.getDataType())) {
                continue;
            } else if (datum.getDataType().isCoercibleTo(childType)) {
                datum = child;
            }
        }
        // If we found an "unknown" child type and the return type is a number
        // make the return type be the most general number type of DECIMAL.
        // TODO: same for TIMESTAMP for DATE/TIME?
        if (isChildTypeUnknown && datum.getDataType() != null && datum.getDataType().isCoercibleTo(PDataType.DECIMAL)) {
            return DECIMAL_DATUM;
        }
        return datum;
    }
View Full Code Here

Examples of org.apache.phoenix.schema.PDatum

                // If we're binding the first parameter and the second parameter
                // is a date
                // we know that the first parameter must be a date type too.
                if (i == 0 && (type = children.get(1).getDataType()) != null
                        && type.isCoercibleTo(PDataType.DATE)) {
                    return new PDatum() {
                        @Override
                        public boolean isNullable() {
                            return expression.isNullable();
                        }
                        @Override
                        public PDataType getDataType() {
                            return type;
                        }
                        @Override
                        public Integer getByteSize() {
                            return type.getByteSize();
                        }
                        @Override
                        public Integer getMaxLength() {
                            return expression.getMaxLength();
                        }
                        @Override
                        public Integer getScale() {
                            return expression.getScale();
                        }
                        @Override
                        public ColumnModifier getColumnModifier() {
                            return expression.getColumnModifier();
                        }                       
                    };
                } else if (expression.getDataType() != null
                        && expression.getDataType().isCoercibleTo(
                                PDataType.DATE)) {
                    return new PDatum() { // Same as with addition
                        @Override
                        public boolean isNullable() {
                            return expression.isNullable();
                        }
                        @Override
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.