Package org.apache.phoenix.schema

Examples of org.apache.phoenix.schema.PDataType


        estimatedByteSize = 0;
        Arrays.fill(ptrs, null);
    }
   
    private static int getExpressionByteCount(Expression e) {
        PDataType childType = e.getDataType();
        if (childType != null && !childType.isFixedWidth()) {
            return 1;
        } else {
            // Write at least one null byte in the case of the child being null with a childType of null
            return childType == null || !childType.isFixedWidth() ? 1 : SchemaUtil.getFixedByteSize(e);
        }
    }
View Full Code Here


                TrustedByteArrayOutputStream output = new TrustedByteArrayOutputStream(estimatedByteSize);
                try {
                    boolean previousCarryOver = false;
                    for (int i = 0; i< expressionCount; i++) {
                        Expression child = getChildren().get(i);
                        PDataType childType = child.getDataType();
                        ImmutableBytesWritable tempPtr = ptrs[i];
                        if (tempPtr == null) {
                            // Since we have a null and have no representation for null,
                            // we must decrement the value of the current. Otherwise,
                            // we'd have an ambiguity if this value happened to be the
                            // min possible value.
                            previousCarryOver = childType == null || childType.isFixedWidth();
                            int bytesToWrite = getExpressionByteCount(child);
                            for (int m = 0; m < bytesToWrite; m++) {
                                output.write(QueryConstants.SEPARATOR_BYTE);
                            }
                        } else {
                            output.write(tempPtr.get(), tempPtr.getOffset(), tempPtr.getLength());
                            if (!childType.isFixedWidth()) {
                                output.write(QueryConstants.SEPARATOR_BYTE);
                            }
                            if (previousCarryOver) {
                                previousCarryOver = !ByteUtil.previousKey(output.getBuffer(), output.size());
                            }
View Full Code Here

        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

            }
            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

            }
            if (ptr.getLength() == 0) {
                return true;
            }
            BigDecimal value;
            PDataType type = children.get(i).getDataType();
            SortOrder sortOrder = children.get(i).getSortOrder();
            if(type == PDataType.TIMESTAMP || type == PDataType.UNSIGNED_TIMESTAMP) {
                value = (BigDecimal)(PDataType.DECIMAL.toObject(ptr, type, sortOrder));
            } else if (type.isCoercibleTo(PDataType.DECIMAL)) {
                value = (((BigDecimal)PDataType.DECIMAL.toObject(ptr, sortOrder)).multiply(BD_MILLIS_IN_DAY)).setScale(6, RoundingMode.HALF_UP);
            } else if (type.isCoercibleTo(PDataType.DOUBLE)) {
                value = ((BigDecimal.valueOf(type.getCodec().decodeDouble(ptr, sortOrder))).multiply(BD_MILLIS_IN_DAY)).setScale(6, RoundingMode.HALF_UP);
            } else {
                value = BigDecimal.valueOf(type.getCodec().decodeLong(ptr, sortOrder));
            }
            if (i == 0) {
                finalResult = value;
            } else {
                finalResult = finalResult.subtract(value);
View Full Code Here

        for(int i=0;i<children.size();i++) {
            if (!children.get(i).evaluate(tuple, ptr) || ptr.getLength() == 0) {
                return false;
            }
            long value;
            PDataType type = children.get(i).getDataType();
            SortOrder sortOrder = children.get(i).getSortOrder();
            if (type == PDataType.DECIMAL) {
                BigDecimal bd = (BigDecimal)PDataType.DECIMAL.toObject(ptr, sortOrder);
                value = bd.multiply(BD_MILLIS_IN_DAY).longValue();
            } else if (type.isCoercibleTo(PDataType.LONG)) {
                value = type.getCodec().decodeLong(ptr, sortOrder) * QueryConstants.MILLIS_IN_DAY;
            } else if (type.isCoercibleTo(PDataType.DOUBLE)) {
                value = (long)(type.getCodec().decodeDouble(ptr, sortOrder) * QueryConstants.MILLIS_IN_DAY);
            } else {
                value = type.getCodec().decodeLong(ptr, sortOrder);
            }
            if (i == 0) {
                finalResult = value;
            } else {
                finalResult -= value;
View Full Code Here

    @Override
    public String toString() {
        int maxToStringLen = 200;
        Expression firstChild = children.get(0);
        PDataType type = firstChild.getDataType();
        StringBuilder buf = new StringBuilder(firstChild + " IN (");
        for (ImmutableBytesPtr value : values) {
            if (firstChild.getSortOrder() != null) {
                type.coerceBytes(value, type, firstChild.getSortOrder(), SortOrder.getDefault());
            }
            buf.append(type.toStringLiteral(value, null));
            buf.append(',');
            if (buf.length() >= maxToStringLen) {
                buf.append("... ");
                break;
            }
View Full Code Here

    ColumnDef(ColumnName columnDefName, String sqlTypeName, boolean isArray, Integer arrSize, Boolean isNull, Integer maxLength,
                    Integer scale, boolean isPK, SortOrder sortOrder) {
      try {
         Preconditions.checkNotNull(sortOrder);
          PDataType localType = null;
         this.columnDefName = columnDefName;
         this.isArray = isArray;
         // TODO : Add correctness check for arrSize.  Should this be ignored as in postgres
         // Also add what is the limit that we would support.  Are we going to support a
         //  fixed size or like postgres allow infinite.  May be the data types max limit can
View Full Code Here

            }
            if (ptr.getLength() == 0) {
                return true;
            }
           
            PDataType childType = childExpr.getDataType();
            boolean isDate = childType.isCoercibleTo(PDataType.DATE);
            SortOrder childSortOrder = childExpr.getSortOrder();
            BigDecimal bd = isDate ?
                    BigDecimal.valueOf(childType.getCodec().decodeLong(ptr, childSortOrder)) :
                    (BigDecimal)PDataType.DECIMAL.toObject(ptr, childType, childSortOrder);
           
            if (result == null) {
                result = bd;
            } else {
View Full Code Here

            }
            if (ptr.getLength() == 0) {
                return true;
            }
            long value;
            PDataType type = children.get(i).getDataType();
            SortOrder sortOrder = children.get(i).getSortOrder();
            if (type == PDataType.DECIMAL) {
                BigDecimal bd = (BigDecimal)PDataType.DECIMAL.toObject(ptr, sortOrder);
                value = bd.multiply(BD_MILLIS_IN_DAY).longValue();
            } else if (type.isCoercibleTo(PDataType.LONG)) {
                value = type.getCodec().decodeLong(ptr, sortOrder) * QueryConstants.MILLIS_IN_DAY;
            } else if (type.isCoercibleTo(PDataType.DOUBLE)) {
                value = (long)(type.getCodec().decodeDouble(ptr, sortOrder) * QueryConstants.MILLIS_IN_DAY);
            } else {
                value = type.getCodec().decodeLong(ptr, sortOrder);
            }
            finalResult += value;
        }
        byte[] resultPtr = new byte[getDataType().getByteSize()];
        getDataType().getCodec().encodeLong(finalResult, resultPtr, 0);
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.