Package com.salesforce.phoenix.schema

Examples of com.salesforce.phoenix.schema.PDataType


        return rowProjector.getColumnProjector(column-1).getName();
    }

    @Override
    public int getColumnType(int column) throws SQLException {
        PDataType type = rowProjector.getColumnProjector(column-1).getExpression().getDataType();
        return type == null ? Types.NULL : type.getResultSetSqlType();
    }
View Full Code Here


        return type == null ? Types.NULL : type.getResultSetSqlType();
    }

    @Override
    public String getColumnTypeName(int column) throws SQLException {
        PDataType type = rowProjector.getColumnProjector(column-1).getExpression().getDataType();
        return type == null ? null : type.getSqlTypeName();
    }
View Full Code Here

        return true;
    }

    @Override
    public boolean isSigned(int column) throws SQLException {
        PDataType type = rowProjector.getColumnProjector(column-1).getExpression().getDataType();
        if (type == null) {
            return false;
        }
        return type.isCoercibleTo(PDataType.DECIMAL);
    }
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

    public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
        if (!super.evaluate(tuple, ptr)) {
            return false;
        }
        if (isConstantExpression()) {
            PDataType type = getDataType();
            Object constantValue = ((LiteralExpression)children.get(0)).getValue();
            if (type == PDataType.DECIMAL) {
                BigDecimal value = ((BigDecimal)constantValue).multiply((BigDecimal)PDataType.DECIMAL.toObject(ptr, PDataType.LONG));
                ptr.set(PDataType.DECIMAL.toBytes(value));
            } else {
                long constantLongValue = ((Number)constantValue).longValue();
                long value = constantLongValue * type.getCodec().decodeLong(ptr, null);
                ptr.set(new byte[type.getByteSize()]);
                type.getCodec().encodeLong(value, ptr);
            }
        }
        return true;
    }
View Full Code Here

    public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
        Expression expression = getExpression();
        if (!expression.evaluate(tuple, ptr)) {
            return false;
        }
        PDataType type = expression.getDataType();
        Object value = formatter.format(type.toObject(ptr, expression.getColumnModifier()));
        byte[] b = getDataType().toBytes(value);
        ptr.set(b);
        return true;
     }
View Full Code Here

            return false;
        } else if (ptr.getLength() == 0) {
            return true;
        }

        PDataType type = expression.getDataType();
        if (type.isCoercibleTo(PDataType.TIMESTAMP)) {
          Date date = (Date) type.toObject(ptr, expression.getColumnModifier());
          BigDecimal time = new BigDecimal(date.getTime());
            byte[] byteValue = getDataType().toBytes(time);
            ptr.set(byteValue);
            return true;
        }
       
        String stringValue = (String)type.toObject(ptr, expression.getColumnModifier());
        if (stringValue == null) {
            ptr.set(EMPTY_BYTE_ARRAY);
            return true;
        }
        stringValue = stringValue.trim();
View Full Code Here

        return true;
    }

    @Override
    public Aggregator newServerAggregator(Configuration conf) {
        final PDataType type = getAggregatorExpression().getDataType();
        ColumnModifier columnModifier = getAggregatorExpression().getColumnModifier();
        return new MinAggregator(columnModifier) {
            @Override
            public PDataType getDataType() {
                return type;
View Full Code Here

            }
        }
        String indexColName = IndexUtil.getIndexColumnName(dataColRef.getColumn());
        // Same alias as before, but use the index column name instead of the data column name
        ParseNode indexColNode = new ColumnParseNode(tName, indexColName, node.getAlias());
        PDataType indexColType = IndexUtil.getIndexColumnDataType(dataColRef.getColumn());
        PDataType dataColType = dataColRef.getColumn().getDataType();

        // Coerce index column reference back to same type as data column so that
        // expression behave exactly the same. No need to invert, as this will be done
        // automatically as needed. If node is used at the top level, do not convert, as
        // otherwise the wrapper gets in the way in the group by clause. For example,
View Full Code Here

    }
   
    @Override
    public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
        if (children.get(0).evaluate(tuple, ptr)) {
            PDataType dataType = getDataType();
            long time = dataType.getCodec().decodeLong(ptr, children.get(0).getColumnModifier());
            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

TOP

Related Classes of com.salesforce.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.