Examples of TPreptimeValue


Examples of com.foundationdb.server.types.TPreptimeValue

                        intermediateTInstance,
                        null // TODO is this null a problem?
                );
                try {
                    first.evaluate(context, firstValue, intermediateValue);
                    result = second.preferredTarget(new TPreptimeValue(intermediateTInstance, intermediateValue));
                } catch (Exception e) {
                    logger.error("while evaluating intermediate value for " + source + " in " + this, e);
                    result = second.preferredTarget(new TPreptimeValue(intermediateTInstance));
                }
            }
            else {
                result = second.preferredTarget(new TPreptimeValue(intermediateTInstance));
            }
            return result;
        }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

        return TOverloadResult.fixed(AkBool.INSTANCE);
    }

    @Override
    public TPreptimeValue evaluateConstant(TPreptimeContext context, LazyList<? extends TPreptimeValue> inputs) {
        TPreptimeValue result = super.evaluateConstant(context, inputs);
        if (result != null) {
            // Already constant
            return result;
        }
        ValueSource pattern = inputs.get(1).value();
        if(pattern == null) {
            return null; // Dynamic pattern
        }
        int flags = caseSensitive ? 0 : Pattern.CASE_INSENSITIVE;
        if(covering.length == 3) {
            ValueSource opts = inputs.get(2).value();
            if(opts == null) {
                return null; // Dynamic opts
            }
            flags |= parseOptionFlags(opts.getString());
        }
        Pattern p = Pattern.compile(pattern.getString(), flags);
        context.set(CACHE_INDEX, p);
        ValueSource inputValue = inputs.get(0).value();
        if(inputValue != null) {
            // Constant input
            boolean matches = p.matcher(inputValue.getString()).find();
            Value value = new Value(context.getOutputType(), matches);
            return new TPreptimeValue(value);
        }

        return null;
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

        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 date = inputs.get(0).value();
                   
                    // if the date string is not literal, get the length
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

        return TOverloadResult.custom(new TCustomOverloadResult()
        {
            @Override
            public TInstance resultInstance(List<TPreptimeValue> inputs, TPreptimeContext context)
            {
                TPreptimeValue fromBase = inputs.get(1);
                TPreptimeValue toBase = inputs.get(2);
               
                int strPre = context.inputTypeAt(0).attribute(StringAttribute.MAX_LENGTH);

                // if toBase and fromBase are not available yet,
                // use the default value of ratio
                if (isNull(fromBase) || isNull(toBase))
                    return stringType.instance((int)(strPre * MAX_RATIO + 1), anyContaminatingNulls(inputs));

                // compute the exact length of the converted string
                strPre = (int)(strPre * Math.log(toBase.value().getInt32())
                                        / Math.log(fromBase.value().getInt32()));
                return stringType.instance(strPre, anyContaminatingNulls(inputs));
            }
           
        });
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

        for (int i = 0; i < inputs.size(); ++i) {
            if (nullContaminates(i)) {
                ValueSource constSource = constSource(inputs, i);
                if ((constSource != null) && constSource.isNull()) {
                    // Const null source on contaminating operand. Result is null.
                    return new TPreptimeValue(context.getOutputType(),
                                              ValueSources.getNullSource(context.getOutputType()));
                }
            }
        }
        for (int i = 0; i < inputs.size(); ++i) {
            if (constnessMatters(i)) {
                Constantness constness = constness(context, i, inputs);
                if (constness == Constantness.NOT_CONST)
                    return null;
                if (constness == Constantness.CONST)
                    break;
                assert constness == Constantness.UNKNOWN : constness;
            }
        }

        // at this point, assume there's a constant value and we can evaluate it

        finishPreptimePhase(context);

        TExecutionContext execContext = context.createExecutionContext();
        LazyList<ValueSource> inputValues = new LazyListBase<ValueSource>() {
            @Override
            public ValueSource get(int i) {
                TPreptimeValue ptValue = inputs.get(i);
                ValueSource source = ptValue.value();
                assert allowNonConstsInEvaluation() || source != null
                        : "non-constant value where constant value expected";
                return source;
            }

            @Override
            public int size() {
                return inputs.size();
            }
        };
        Value outputValue = new Value(execContext.outputType());
        evaluate(execContext, inputValues, outputValue);
        return new TPreptimeValue(execContext.outputType(), outputValue);
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

    public int[] getPriorities() {
        return new int[1];
    }

    protected static ValueSource constSource(LazyList<? extends TPreptimeValue> inputs, int index) {
        TPreptimeValue tpv = inputs.get(index);
        return tpv == null ? null : tpv.value();
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

public final class TPreparedBoundField implements TPreparedExpression {
   
    @Override
    public TPreptimeValue evaluateConstant(QueryContext queryContext) {
        return new TPreptimeValue(resultType());
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

public final class TCastExpression implements TPreparedExpression {

    @Override
    public TPreptimeValue evaluateConstant(QueryContext queryContext) {
        TPreptimeValue inputValue = input.evaluateConstant(queryContext);
        Value value;
        if (inputValue == null || inputValue.value() == null) {
            value = null;
        }
        else {
            value = new Value(targetInstance);

            TExecutionContext context = new TExecutionContext(
                    new SparseArray<>(),
                    Collections.singletonList(input.resultType()),
                    targetInstance,
                    queryContext,
                    null,
                    null,
                    null
            );
            cast.evaluate(context, inputValue.value(), value);
        }
        return new TPreptimeValue(targetInstance, value);
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

import com.foundationdb.util.ArgumentValidation;

abstract class SubqueryTExpression implements TPreparedExpression {
    @Override
    public TPreptimeValue evaluateConstant(QueryContext queryContext) {
        return new TPreptimeValue(resultType());
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

                                   TInstance rightInstance, ValueSource right);

    @Override
    public TPreptimeValue evaluateConstant(QueryContext queryContext) {
        // First check both sides. If either is a constant null, the result is null
        TPreptimeValue leftPrep = left.evaluateConstant(queryContext);
        ValueSource oneVal = leftPrep.value();
        if (oneVal != null && oneVal.isNull()) {
            TInstance type = AkBool.INSTANCE.instance(true);
            return new TPreptimeValue(ValueSources.getNullSource(type));
        }

        TPreptimeValue rightPrep = right.evaluateConstant(queryContext);
        ValueSource twoVal = rightPrep.value();
        if (twoVal != null && twoVal.isNull()) {
            TInstance type = AkBool.INSTANCE.instance(true);
            return new TPreptimeValue(ValueSources.getNullSource(type));
        }

        // Neither side is constant null. If both sides are constant, evaluate
        ValueSource resultSource = null;
        boolean nullable;
        if (oneVal != null && twoVal != null) {
            final boolean result = doEval(leftPrep.type(), oneVal, rightPrep.type(), twoVal);
            resultSource = new Value(AkBool.INSTANCE.instance(false), result);
            nullable = resultSource.isNull();
        }
        else {
            nullable = left.resultType().nullability() || right.resultType().nullability();
        }
        return new TPreptimeValue(MNumeric.INT.instance(nullable), resultSource);
    }
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.