Package com.foundationdb.server.types

Examples of com.foundationdb.server.types.TInstance


                                              List<ParameterNode> params, int[] paramTypes) {
        ExecuteStatementNode execute = (ExecuteStatementNode)stmt;
        this.name = execute.getName();
        paramValues = new ArrayList<>();
        for (ValueNode param : execute.getParameterList()) {
            TInstance type = null;
            if (!(param instanceof ConstantNode)) {
                throw new UnsupportedSQLException("EXECUTE arguments must be constants", param);
            }
            if (param.getType() != null)
                type = server.typesTranslator().typeForSQLType(param.getType());
View Full Code Here


                List<ExpressionNode> noperands = new ArrayList<>(2);
                noperands.add(new AggregateFunctionExpression("SUM", operand, expr.isDistinct(),
                                                              operand.getSQLtype(), null,
                                                              operand.getType(), null, null));
                DataTypeDescriptor intType = new DataTypeDescriptor(TypeId.INTEGER_ID, false);
                TInstance intInst = rulesContext.getTypesTranslator().typeForSQLType(intType);
                noperands.add(new AggregateFunctionExpression("COUNT", operand, expr.isDistinct(),
                                                              intType, null, intInst, null, null));
                return new FunctionExpression("divide",
                                              noperands,
                                              expr.getSQLtype(), expr.getSQLsource(), expr.getType());
            }
            if ("VAR_POP".equals(function) ||
                "VAR_SAMP".equals(function) ||
                "STDDEV_POP".equals(function) ||
                "STDDEV_SAMP".equals(function)) {
                ExpressionNode operand = expr.getOperand();
                List<ExpressionNode> noperands = new ArrayList<>(3);
                noperands.add(new AggregateFunctionExpression("_VAR_SUM_2", operand, expr.isDistinct(),
                                                              operand.getSQLtype(), null,
                                                              operand.getType(), null, null));
                noperands.add(new AggregateFunctionExpression("_VAR_SUM", operand, expr.isDistinct(),
                                                              operand.getSQLtype(), null,
                                                              operand.getType(), null, null));
                DataTypeDescriptor intType = new DataTypeDescriptor(TypeId.INTEGER_ID, false);
                TInstance intInst = rulesContext.getTypesTranslator().typeForSQLType(intType);
                noperands.add(new AggregateFunctionExpression("COUNT", operand, expr.isDistinct(),
                                                              intType, null, intInst, null, null));
                return new FunctionExpression("_" + function,
                                              noperands,
                                              expr.getSQLtype(), expr.getSQLsource(), expr.getType());
View Full Code Here

                    boolean nullable = isNullable(condition);
                    while (size > 0) {
                        ConditionExpression left = entry.get(--size);
                        nullable |= isNullable(left);
                        DataTypeDescriptor sqlType = new DataTypeDescriptor (TypeId.BOOLEAN_ID, nullable);
                        TInstance type = rulesContext.getTypesTranslator().typeForSQLType(sqlType);
                        condition = new BooleanOperationExpression(Operation.AND,
                                                                   left,
                                                                   condition,
                                                                   sqlType,
                                                                   null,
View Full Code Here

            ExpressionNode operand = aggregate.getOperand();
            aggregate.setOperand(null);
            if (operand == null) {
                if ("COUNT".equals(function))
                    function = "COUNT(*)";
                TInstance type = aggregate.getType(); // Some kind of BIGINT.
                operand = new ConstantExpression(1L, type);
            }
            aggregateFunctions.add(function);
            resolvedFunctions.add(aggregate);
            result.add(operand);
View Full Code Here

    protected TInstance jdbcInstance(int jdbcType) {
        return getTypesTranslator().typeClassForJDBCType(jdbcType).instance(true);
    }

    protected void setValue(int index, Object value, TInstance sourceType) {
        TInstance targetType = this.getType(index);
        if (sourceType == null) {
            sourceType = targetType;
        }
        ValueSource source = ValueSources.valuefromObject(value, sourceType);
        if (targetType != null)
            source = cachedCast(index, source, sourceType, targetType.typeClass());
        setValue(index, source);
    }
View Full Code Here

        Value target;

        protected CachedCast(TInstance sourceInstance, TClass targetClass,
                             ServerQueryContext context) {
            this.targetClass = targetClass;
            TInstance targetInstance = targetClass.instance(sourceInstance == null || sourceInstance.nullability());
            tcast = context.getServer().typesRegistryService().getCastsResolver()
                .cast(sourceInstance, targetInstance);
            if (tcast == null)
                throw new NoSuchCastException(sourceInstance, targetInstance);
            tcontext = new TExecutionContext(Collections.singletonList(sourceInstance),
View Full Code Here

     */
    public void decodeValue(byte[] encoded, ServerType type, boolean binary,
                            QueryBindings bindings, int index,
                            QueryContext queryContext, TypesRegistryService typesRegistryService) {
      
        TInstance targetType = type != null ? type.getType() : null;
        if (targetType == null && encoded != null) {
            throw new UnknownDataTypeException(null);
        }
        ValueSource source;
        if (encoded == null) {
View Full Code Here

            JsonResultColumn resultColumn = resultColumns.get(i);
            encoder.appendString((i == 0) ? "\"" : ",\"");
            Quote.DOUBLE_QUOTE.append(appender, resultColumn.getName());
            encoder.appendString("\":");
            ValueSource value = row.value(i);
            TInstance columnTInstance = resultColumn.getType();
            if (columnTInstance.typeClass() instanceof AkResultSet) {
                outputNestedResultSet((Cursor)value.getObject(),
                                      resultColumn.getNestedResultColumns());
            }
            else {
                FormatOptions options = context.getServer().getFormatOptions();
                columnTInstance.formatAsJson(value, appender, options);
            }
        }
        encoder.appendString("}");
    }
View Full Code Here

        appendValue(source, type, binary);
    }

    public ValueSource valuefromObject(Object value, ServerType type) {
        if (value instanceof Date) {
            TInstance dateType = javaDateTInstance(value);
            Value dateValue = new Value(dateType);
            typesTranslator.setTimestampMillisValue(dateValue, ((Date)value).getTime(),
                                                    (value instanceof java.sql.Timestamp) ?
                                                    ((java.sql.Timestamp)value).getNanos() : 0);
            TInstance targetType = type.getType();
            if (dateType.equals(targetType))
                return dateValue;
            TExecutionContext context =
                new TExecutionContext(Collections.singletonList(dateType),
                                      targetType, null);
            Value result = new Value(targetType);
            targetType.typeClass().fromObject(context, dateValue, result);
            return result;
        }
        else {
            // TODO this is inefficient, but I want to get it working.
            return ValueSources.valuefromObject(value, type.getType());
View Full Code Here

            case NodeTypes.MODIFY_COLUMN_CONSTRAINT_NOT_NULL_NODE: // Type only comes from NOT NULL
                column.setType(column.getType().withNullable(false));
            break;
            case NodeTypes.MODIFY_COLUMN_TYPE_NODE: // All but [NOT] NULL comes from type
                {
                    TInstance type = typesTranslator
                        .typeForSQLType(modNode.getType())
                        .withNullable(column.getNullable());
                    if (false) {
                        // TODO: Determine whether compatible, does affect sequence, etc.
                        column.setType(type);
View Full Code Here

TOP

Related Classes of com.foundationdb.server.types.TInstance

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.