Package com.foundationdb.server.types

Examples of com.foundationdb.server.types.TPreptimeValue


    public static ExpressionGenerator literal(final Object value)
    {
        return new ExpressionGenerator() {
            @Override
            public TPreparedExpression getTPreparedExpression() {
                TPreptimeValue tpv = ValueSources.fromObject(value, (TInstance) null);
               
                //FromObjectValueSource valueSource = new FromObjectValueSource().setReflectively(value);
                //TPreptimeValue tpv = ValueSources.fromObject(value, valueSource.getConversionType());
                return new TPreparedLiteral(tpv.type(), tpv.value());
            }
        };
    }
View Full Code Here


    public static ExpressionGenerator literal (final Object value, final TInstance type)
    {
        return new ExpressionGenerator() {
            @Override
            public TPreparedExpression getTPreparedExpression() {
                TPreptimeValue tpv = ValueSources.fromObject(value, type);
                return new TPreparedLiteral(tpv.type(), tpv.value());
            }
        };
    }
View Full Code Here

        if(fields.length < rowType.nFields()) {
            QueryContext context = new SimpleQueryContext(newStoreAdapter(rowType.schema()));
            List<TPreparedExpression> expressions = new ArrayList<>();
            for(int i = 0; i < fields.length; ++i) {
                TInstance type = rowType.typeAt(i);
                TPreptimeValue val = ValueSources.fromObject(fields[i], type);
                expressions.add(new TPreparedLiteral(type, val.value()));
            }
            for(int i = fields.length; i < rowType.nFields(); ++i) {
                Column col = getColumn(rowType, i);
                if(col == null) {
                    throw new IllegalArgumentException("Column " + i + "not specified and no default: " + rowType);
View Full Code Here

        return TOverloadResult.custom(new TCustomOverloadResult()
        {
            @Override
            public TInstance resultInstance(List<TPreptimeValue> inputs, TPreptimeContext context)
            {
                TPreptimeValue on = inputs.get(1);
                TPreptimeValue off = inputs.get(2);

                boolean nullable = anyContaminatingNulls(inputs);
               
                if (on == null
                        || off == null
                        || on.value().isNull()
                        || off.value().isNull()
                   )
                    return stringType.instance(255, nullable); // if not literal, the length would just be 255
               
                // get the digits length
                int digitLength = Math.max((on.value().getString()).length(),
                                            (off.value().getString()).length());
                int length = DEFAULT_LENGTH; // number of digits
                int delimLength = DEFAULT_DELIM.length();
               
                switch(inputs.size())
                {
View Full Code Here

    }

    @Override
    public TPreptimeValue evaluateConstant(TPreptimeContext context, LazyList<? extends TPreptimeValue> inputs)
    {
        TPreptimeValue result = super.evaluateConstant(context, inputs);
        if (result != null) return result; // Whole thing is constant.

        TPreptimeValue patternPrep = inputs.get(1);
        ValueSource patternValue = patternPrep.value();
        if (patternValue == null) return result; // Pattern not constant
        String pattern = patternValue.getString();

        char esca = '\\';
        if (inputs.size() >= 3) {
            TPreptimeValue escapePrep = inputs.get(2);
            ValueSource escapeValue = escapePrep.value();
            if (escapeValue == null) return result; // Escape not constant
            String escapeString = escapeValue.getString();
            if (escapeString.length() != 1) return result;
            esca = escapeString.charAt(0);
        }
View Full Code Here

    protected BaseExpression(DataTypeDescriptor sqlType, ValueNode sqlSource,
                             TInstance type) {
        this.sqlType = sqlType;
        this.sqlSource = sqlSource;
        if (type != null)
            this.preptimeValue = new TPreptimeValue(type);
    }
View Full Code Here

    public TPreptimeValue evaluateConstant(QueryContext context) {
        List<TPreptimeValue> values = new ArrayList<>(inputs.size());
        boolean allConstant = true, anyNull = false;
        ValueSource constantSource = null;
        for (TPreparedExpression input : inputs) {
            TPreptimeValue value = input.evaluateConstant(context);
            values.add(value);
            if (value.value() == null) {
                allConstant = false;
            }
            else if (value.value().isNull()) {
                anyNull = true;
            }
            if (allConstant && routine.isDeterministic()) {
                ValueRoutineInvocation invocation = new TPreptimeValueRoutineInvocation(routine, values);
                ServerJavaRoutine javaRoutine = javaRoutine((ServerQueryContext)context, null, invocation);
                evaluate(javaRoutine);
                constantSource = invocation.getReturnValue();
            }
            if (anyNull && !routine.isCalledOnNullInput()) {
                constantSource = ValueSources.getNullSource(resultType());
            }
        }
        return new TPreptimeValue(resultType(), constantSource);
    }
View Full Code Here

    private Object value;

    public static ConstantExpression typedNull(DataTypeDescriptor sqlType, ValueNode sqlSource, TInstance type) {
        if (sqlType == null) {
            ValueSource nullSource = ValueSources.getNullSource(null);
            ConstantExpression result = new ConstantExpression(new TPreptimeValue(nullSource));
            return result;
        }
        ConstantExpression result = new ConstantExpression((Object)null, sqlType, sqlSource, null);
        if (type != null) {
            ValueSource nullSource = ValueSources.getNullSource(type);
            result.setPreptimeValue(new TPreptimeValue(type, nullSource));
        } else {
            result.setPreptimeValue(new TPreptimeValue());
        }
        return result;
    }
View Full Code Here

        return TOverloadResult.custom(new TCustomOverloadResult()
        {
            @Override
            public TInstance resultInstance(List<TPreptimeValue> inputs, TPreptimeContext context)
            {
                TPreptimeValue formatArg = inputs.get(1);
               
                ValueSource format = formatArg.value();
               
                int length;
               
                // format is not literal
                // the length is format's precision * 10
                if (format == null)
                    length = formatArg.type().attribute(StringAttribute.MAX_LENGTH) * 10;
                else
                {
                    ValueSource unixTime = inputs.get(0).value();
                   
                    // if the unix time value is not literal, get the length
View Full Code Here

            // String, pvalue will be a its VARCHAR, and pvalue2
            // will be a BigDecimalWrapper, which only
            // TBigDecimal.writeCollating knows how to unwrap into
            // a Key.
           
            TPreptimeValue pvalue = null;
            if (value == null)
                pvalue = ValueSources.fromObject(value, type);
            else
                pvalue = ValueSources.fromObject(value, (TInstance) null);
            TExecutionContext context = new TExecutionContext(null,
                                                              Collections.singletonList(pvalue.type()),
                    type,
                                                              null, null, null, null);
            Value pvalue2 = new Value(type);
            type.typeClass().fromObject(context, pvalue.value(), pvalue2);
            type.writeCollating(pvalue2, keyTarget);
        }
        return key;
    }
View Full Code Here

TOP

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

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.