Package org.apache.phoenix.schema

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


    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

        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

            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

        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

                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

        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

        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

            }
            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

    protected Integer getScale(Expression e) {
        Integer scale = e.getScale();
        if (scale != null) {
            return scale;
        }
        PDataType dataType = e.getDataType();
        if (dataType != null) {
            scale = dataType.getScale(null);
            if (scale != null) {
                return scale;
            }
        }
        return null;
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.