Examples of PDataType


Examples of org.apache.phoenix.schema.PDataType

            @Override
            public KeyRange getKeyRange(CompareOp op, Expression rhs) {
                byte[] lowerRange = KeyRange.UNBOUND;
                byte[] upperRange = KeyRange.UNBOUND;
                boolean lowerInclusive = true;
                PDataType type = getColumn().getDataType();
                switch (op) {
                case EQUAL:
                    lowerRange = evaluateExpression(rhs);
                    upperRange = ByteUtil.nextKey(lowerRange);
                    break;
                case GREATER:
                    lowerRange = ByteUtil.nextKey(evaluateExpression(rhs));
                    break;
                case LESS_OR_EQUAL:
                    upperRange = ByteUtil.nextKey(evaluateExpression(rhs));
                    lowerInclusive = false;
                    break;
                default:
                    return childPart.getKeyRange(op, rhs);
                }
                Integer length = getColumn().getMaxLength();
                if (type.isFixedWidth() && length != null) {
                    if (lowerRange != KeyRange.UNBOUND) {
                        lowerRange = StringUtil.padChar(lowerRange, length);
                    }
                    if (upperRange != KeyRange.UNBOUND) {
                        upperRange = StringUtil.padChar(upperRange, length);
View Full Code Here

Examples of org.apache.phoenix.schema.PDataType

        // is not fixed width, the maxLength would be null.
        isOffsetConstant = getOffsetExpression() instanceof LiteralExpression;
        Number offsetNumber = (Number)((LiteralExpression)getOffsetExpression()).getValue();
        if (offsetNumber != null) {
            int offset = offsetNumber.intValue();
            PDataType type = getSourceStrExpression().getDataType();
            if (type.isFixedWidth()) {
                if (offset >= 0) {
                    Integer maxLength = getSourceStrExpression().getMaxLength();
                    this.maxLength = maxLength - offset - (offset == 0 ? 0 : 1);
                } else {
                    this.maxLength = -offset;
View Full Code Here

Examples of org.apache.phoenix.schema.PDataType

    if (!arrayExpr.evaluate(tuple, ptr)) {
      return false;
    } else if (ptr.getLength() == 0) {
      return true;
    }
    PDataType baseType = PDataType.fromTypeId(children.get(0).getDataType()
        .getSqlType()
        - PDataType.ARRAY_TYPE_BASE);
    int length = PArrayDataType.getArrayLength(ptr, baseType, arrayExpr.getMaxLength());
    byte[] lengthBuf = new byte[PDataType.INTEGER.getByteSize()];
    PDataType.INTEGER.getCodec().encodeInt(length, lengthBuf, 0);
View Full Code Here

Examples of org.apache.phoenix.schema.PDataType

        super(childExpressions, delegate);
    }

    @Override
    public Aggregator newServerAggregator(Configuration conf) {
        final PDataType type = getAggregatorExpression().getDataType();
        SortOrder sortOrder = getAggregatorExpression().getSortOrder();
        return new MaxAggregator(sortOrder) {
            @Override
            public PDataType getDataType() {
                return type;
View Full Code Here

Examples of org.apache.phoenix.schema.PDataType

            for (Entry groupByEntry : groupByEntries) {
                expressions.add(groupByEntry.getExpression());
            }
            for (int i = expressions.size()-2; i >= 0; i--) {
                Expression expression = expressions.get(i);
                PDataType keyType = getKeyType(expression);
                if (keyType == expression.getDataType()) {
                    continue;
                }
                // Copy expressions only when keyExpressions will be different than expressions
                if (keyExpressions == expressions) {
View Full Code Here

Examples of org.apache.phoenix.schema.PDataType

        GroupBy groupBy = new GroupBy.GroupByBuilder().setScanAttribName(groupExprAttribName).setExpressions(expressions).setKeyExpressions(keyExpressions).build();
        return groupBy;
    }
   
    private static PDataType getKeyType(Expression expression) {
        PDataType type = expression.getDataType();
        if (!expression.isNullable() || !type.isFixedWidth()) {
            return type;
        }
        if (type.isCastableTo(PDataType.DECIMAL)) {
            return PDataType.DECIMAL;
        }
        if (type.isCastableTo(PDataType.VARCHAR)) {
            return PDataType.VARCHAR;
        }
        // This might happen if someone tries to group by an array
        throw new IllegalStateException("Multiple occurrences of type " + type + " may not occur in a GROUP BY clause");
    }
View Full Code Here

Examples of org.apache.phoenix.schema.PDataType

                Pair<Expression, Expression> p = iter.next();
                EqualParseNode equalNode = (EqualParseNode) condition;
                expressionCompiler.reset();
                Expression right = equalNode.getRHS().accept(expressionCompiler);
                Expression left = p.getFirst();
                PDataType toType = getCommonType(left.getDataType(), right.getDataType());
                if (left.getDataType() != toType) {
                    left = CoerceExpression.create(left, toType);
                    p.setFirst(left);
                }
                if (right.getDataType() != toType) {
View Full Code Here

Examples of org.apache.phoenix.schema.PDataType

        return getRoundExpression(children);
    }

    public static Expression getRoundExpression(List<Expression> children) throws SQLException {
        final Expression firstChild = children.get(0);
        final PDataType firstChildDataType = firstChild.getDataType();
       
        if(firstChildDataType.isCoercibleTo(PDataType.DATE)) {
            return RoundDateExpression.create(children);
        } else if (firstChildDataType.isCoercibleTo(PDataType.TIMESTAMP)) {
            return RoundTimestampExpression.create(children);
        } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) {
            return RoundDecimalExpression.create(children);
        } else {
            throw TypeMismatchException.newException(firstChildDataType, "1");
        }
    }
View Full Code Here

Examples of org.apache.phoenix.schema.PDataType

        return getFloorExpression(children);
    }

    public static Expression getFloorExpression(List<Expression> children) throws SQLException {
        final Expression firstChild = children.get(0);
        final PDataType firstChildDataType = firstChild.getDataType();
       
        //FLOOR on timestamp doesn't really care about the nanos part i.e. it just sets it to zero.
        //Which is exactly what FloorDateExpression does too.
        if(firstChildDataType.isCoercibleTo(PDataType.TIMESTAMP)) {
            return FloorDateExpression.create(children);
        } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) {
            return FloorDecimalExpression.create(children);
        } else {
            throw TypeMismatchException.newException(firstChildDataType, "1");
        }
    }
View Full Code Here

Examples of org.apache.phoenix.schema.PDataType

            }
            if (ptr.getLength() == 0) {
                return true;
            }
           
            PDataType childType = children.get(i).getDataType();
            SortOrder childSortOrder = children.get(i).getSortOrder();
            BigDecimal bd = (BigDecimal)PDataType.DECIMAL.toObject(ptr, childType, childSortOrder);
           
            if (result == null) {
                result = bd;
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.