Package org.apache.phoenix.schema

Examples of org.apache.phoenix.schema.PDataType


            return isDeterministic ? TRUE_EXPRESSION : ND_TRUE_EXPRESSION;
        }
        if (value == null) {
            return isDeterministic ? NULL_EXPRESSION : ND_NULL_EXPRESSION;
        }
        PDataType type = PDataType.fromLiteral(value);
        byte[] b = type.toBytes(value);
        if (type.isNull(b)) {
            return TYPED_NULL_EXPRESSIONS[type.ordinal() + ( isDeterministic ? 0 : TYPED_NULL_EXPRESSIONS.length/2)];
        }
        if (type == PDataType.VARCHAR) {
            String s = (String) value;
            if (s.length() == b.length) { // single byte characters only
                type = PDataType.CHAR;
View Full Code Here


            return isDeterministic ? FALSE_EXPRESSION : ND_FALSE_EXPRESSION;
        }
        if (Boolean.TRUE.equals(value)) {
            return isDeterministic ? TRUE_EXPRESSION : ND_TRUE_EXPRESSION;
        }
        PDataType actualType = PDataType.fromLiteral(value);
        // For array we should check individual element in it?
        // It would be costly though!!!!!
        if (!actualType.isCoercibleTo(type, value)) {
            throw TypeMismatchException.newException(type, actualType, value.toString());
        }
        value = type.toObject(value, actualType);
        try {
            byte[] b = type.toBytes(value, sortOrder);
View Full Code Here

        mutationState.commit();
    }

    @Override
    public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
      PDataType arrayPrimitiveType = PDataType.fromSqlTypeName(typeName);
      return PArrayDataType.instantiatePhoenixArray(arrayPrimitiveType, elements);
    }
View Full Code Here

            }
            if (ptr.getLength() == 0) {
                return true;
            }
           
            PDataType childType = childExpr.getDataType();
            SortOrder childSortOrder = childExpr.getSortOrder();
            BigDecimal bd= (BigDecimal)PDataType.DECIMAL.toObject(ptr, childType, childSortOrder);
           
            if (result == null) {
                result = bd;
View Full Code Here

            throw TypeMismatchException.newException(expectedType, actualType);
        }
    }

    public LiteralParseNode literal(Object value, PDataType expectedType) throws SQLException {
        PDataType actualType = PDataType.fromLiteral(value);
        if (actualType != null && actualType != expectedType) {
            checkTypeMatch(expectedType, actualType);
            value = expectedType.toObject(value, actualType);
        }
        return new LiteralParseNode(value);
View Full Code Here

        }
        return new LiteralParseNode(value);
    }

    public LiteralParseNode coerce(LiteralParseNode literalNode, PDataType expectedType) throws SQLException {
        PDataType actualType = literalNode.getType();
        if (actualType != null) {
            Object before = literalNode.getValue();
            checkTypeMatch(expectedType, actualType);
            Object after = expectedType.toObject(before, actualType);
            if (before != after) {
View Full Code Here

        this.upsertListener = upsertListener;
        this.arrayElementSeparator = arrayElementSeparator;
        this.dataTypes = Lists.newArrayList();
        this.conversionFunctions = Lists.newArrayList();
        for (ColumnInfo columnInfo : columnInfoList) {
            PDataType dataType = PDataType.fromTypeId(columnInfo.getSqlType());
            dataTypes.add(dataType);
            conversionFunctions.add(createConversionFunction(dataType));
        }
    }
View Full Code Here

        byte[] result = ByteUtil.EMPTY_BYTE_ARRAY;
        for (int i=0; i<children.size(); i++) {
            if (children.get(i).getDataType() == null || !children.get(i).evaluate(tuple, ptr)) {
                continue;
            }
            PDataType childType = children.get(i).getDataType();
            SortOrder sortOrder = children.get(i).getSortOrder();
            // We could potentially not invert the bytes, but we might as well since we're allocating
            // additional space here anyway.
            if (childType.isCoercibleTo(PDataType.VARCHAR)) {
                result = ByteUtil.concat(result, ByteUtil.concat(sortOrder, ptr));
            } else {
                result = ByteUtil.concat(result, PDataType.VARCHAR.toBytes(childType.toObject(ptr, sortOrder).toString()));
            }
        }
        ptr.set(result);
        return true;
    }
View Full Code Here

        if (ptr.getLength() == 0) {
            throw new IllegalDataException(getMissingEncodeFormatMsg());
        }

        PDataType type = encodingExpression.getDataType();
        String encodingFormat = ((String) type.toObject(ptr)).toUpperCase();
        EncodeFormat format = EncodeFormat.valueOf(encodingFormat);
        switch (format) {
            case BASE62:
                String encodedString = Base62Encoder.toString(num);
                ptr.set(PDataType.VARCHAR.toBytes(encodedString));
View Full Code Here

    public RoundDecimalExpression() {}
   
    protected RoundDecimalExpression(List<Expression> children) {
        super(children);
        LiteralExpression scaleChild = (LiteralExpression)children.get(1);
        PDataType scaleType = scaleChild.getDataType();
        Object scaleValue = scaleChild.getValue();
        if(scaleValue != null) {
            if (scaleType.isCoercibleTo(PDataType.INTEGER, scaleValue)) {
                int scale = (Integer)PDataType.INTEGER.toObject(scaleValue, scaleType);
                if (scale >=0 && scale <= PDataType.MAX_PRECISION) {
                    this.scale = scale;
                    return;
                }
View Full Code Here

TOP

Related Classes of org.apache.phoenix.schema.PDataType

Copyright © 2018 www.massapicom. 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.