Package org.apache.phoenix.schema

Examples of org.apache.phoenix.schema.PDataType.toBytes()


                }
                type = pkColumns.get(i).getDataType();
               
                //for fixed width data types like CHAR and BINARY, we need to pad values to be of max length.
                Object paddedObj = type.pad(values[i - offset], pkColumns.get(i).getMaxLength());
                byte[] value = type.toBytes(paddedObj);
                output.write(value);
            }
            return output.toByteArray();
        } finally {
            try {
View Full Code Here


            PDataType dataType = getDataType();
            int nanos = dataType.getNanos(ptr, sortOrder);
            if(nanos >= HALF_OF_NANOS_IN_MILLI) {
                long timeMillis = dataType.getMillis(ptr, sortOrder);
                Timestamp roundedTs = new Timestamp(timeMillis + 1);
                byte[] byteValue = dataType.toBytes(roundedTs);
                ptr.set(byteValue);
            }
            return true; // for timestamp we only support rounding up the milliseconds.
        }
        return false;
View Full Code Here

        }
        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;
View Full Code Here

            PDataType dataType = getDataType();
            int nanos = dataType.getNanos(ptr, sortOrder);
            if (nanos > 0) {
                long millis = dataType.getMillis(ptr, sortOrder);
                Timestamp roundedTs = new Timestamp(millis + 1);
                byte[] byteValue = dataType.toBytes(roundedTs);
                ptr.set(byteValue);
            }
            return true; // for timestamp we only support rounding up the milliseconds.
        }
        return false;
View Full Code Here

            PDataType dataType = getDataType();
            long time = dataType.getCodec().decodeLong(ptr, children.get(0).getSortOrder());
            long value = roundTime(time);
           
            Date d = new Date(value);
            byte[] byteValue = dataType.toBytes(d);
            ptr.set(byteValue);
            return true;
        }
        return false;
    }
View Full Code Here

            tempPtr.set(ptr.get(), ptr.getOffset(), ptr.getLength());
            childType.coerceBytes(tempPtr, childType, child.getColumnModifier(), null);
            Timestamp value = (Timestamp) childType.toObject(tempPtr);
            if (value.getNanos() > 0) {
                value = new Timestamp(value.getTime()+getRoundUpAmount());
                byte[] b = childType.toBytes(value, child.getColumnModifier());
                ptr.set(b);
            }
            return true;
        }
        return false;
View Full Code Here

        }
        if (value == null) {
            return NULL_EXPRESSION;
        }
        PDataType type = PDataType.fromLiteral(value);
        byte[] b = type.toBytes(value);
        if (b.length == 0) {
            return TYPED_NULL_EXPRESSIONS[type.ordinal()];
        }
        if (type == PDataType.VARCHAR) {
            String s = (String) value;
View Full Code Here

        if (child.evaluate(tuple, ptr)) {
            PDataType childType = child.getDataType();
            childType.coerceBytes(ptr, childType, child.getColumnModifier(), null);
            BigDecimal value = (BigDecimal) childType.toObject(ptr);
            value = value.round(getMathContext());
            byte[] b = childType.toBytes(value, child.getColumnModifier());
            ptr.set(b);
            return true;
        }
        return false;
    }
View Full Code Here

            for (int i = offset; i < pkColumns.size(); i++) {
                if (type != null && !type.isFixedWidth()) {
                    output.write(QueryConstants.SEPARATOR_BYTE);
                }
                type = pkColumns.get(i).getDataType();
                byte[] value = type.toBytes(values[i - offset]);
                output.write(value);
            }
            return output.toByteArray();
        } finally {
            try {
View Full Code Here

                }
                type = pkColumns.get(i).getDataType();
               
                //for fixed width data types like CHAR and BINARY, we need to pad values to be of max length.
                Object paddedObj = type.pad(values[i - offset], pkColumns.get(i).getMaxLength());
                byte[] value = type.toBytes(paddedObj);
                output.write(value);
            }
            return output.toByteArray();
        } finally {
            try {
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.