Package com.foundationdb.server.types.value

Examples of com.foundationdb.server.types.value.ValueSource


    }

    @Override
    protected Constantness constness(TPreptimeContext context, int inputIndex, LazyList<? extends TPreptimeValue> values) {
        assert inputIndex == 0 : inputIndex; // should be fully resolved after the first call
        ValueSource condition = values.get(0).value();
        if (condition == null)
            return Constantness.NOT_CONST;
        int result = (!condition.isNull() && condition.getBoolean()) ? 1 : 2;
        return values.get(result).value() == null ? Constantness.NOT_CONST : Constantness.CONST;
    }
View Full Code Here


    }

    @Override
    protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output)
    {
        ValueSource arg0 = inputs.get(pos0);
        long ymd[] = firstArg.decode(arg0, context);
        if (ymd == null)
        {
            output.putNull();
            context.warnClient(new InvalidDateFormatException("DATE", arg0.toString()));
        }
        else
        {
            MutableDateTime dt = MDateAndTime.toJodaDateTime(ymd, "UTC");    // calculations should be done
            helper.compute(dt, secondArg.toMillis(inputs.get(pos1)));      // in UTC (to avoid daylight-saving side effects)
View Full Code Here

        }

        @Override
        public TInstance preferredTarget(TPreptimeValue source) {
            TInstance intermediateTInstance = first.preferredTarget(source);
            ValueSource firstValue = source.value();
            TInstance result;
            if (firstValue != null) {
                Value intermediateValue = new Value(first.targetClass().instance(true));
                TExecutionContext context = new TExecutionContext(
                        Collections.singletonList(source.type()),
View Full Code Here

        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

        builder.setExact(exact).vararg(targetClass, 0, 1);
    }

    @Override
    protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output) {
        ValueSource needle = inputs.get(0);
        int result = 0;
        if (!needle.isNull()) {
            TInstance needleInstance = context.inputTypeAt(0);
            for (int i = 1, size = inputs.size(); i < size; ++i) {
                ValueSource arg = inputs.get(i);
                if (!arg.isNull()) {
                    TInstance argInstance = context.inputTypeAt(i);
                    int cmp = TClass.compare(needleInstance, needle, argInstance, arg);
                    if (cmp == 0) {
                        result = i;
                        break;
View Full Code Here

        return false;
    }

    @Override
    protected Constantness constness(TPreptimeContext context, int inputIndex, LazyList<? extends TPreptimeValue> values) {
        ValueSource preptimeValue = constSource(values, inputIndex);
        if (preptimeValue == null)
            return Constantness.NOT_CONST;
        return preptimeValue.isNull() ? Constantness.UNKNOWN : Constantness.CONST;
    }
View Full Code Here

        String delim = inputs.get(0).getString();
        StringBuilder ret = new StringBuilder();

        for (int n = 1; n < inputs.size(); ++n)
        {
            ValueSource source = inputs.get(n);
            if (!source.isNull())
                ret.append(source.getString()).append(delim);
        }
        if (ret.length()!= 0)
            ret.delete(ret.length() - delim.length(),
                       ret.length());
View Full Code Here

        return TOverloadResult.custom(new TCustomOverloadResult()
        {
            @Override
            public TInstance resultInstance(List<TPreptimeValue> inputs, TPreptimeContext context)
            {
                ValueSource text = inputs.get(0).value();
               
                // if input is not literal
                // the return type is same as its type
                if (text == null)
                    return inputs.get(0).type();
                int len = text.isNull() ? 0 : (text.getBytes().length * ratio);
                return varbinType.instance(len, anyContaminatingNulls(inputs));
            }  
        });
    }
View Full Code Here

            @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
                    // from the format string
                    length = computeLength(format.getString());
                   
View Full Code Here

        builder.pickingCovers(targetClass, 0, 1);
    }

    @Override
    protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output) {
        ValueSource arg0 = inputs.get(0);
        ValueSource out = arg0.isNull() ? inputs.get(1) : arg0;
        ValueTargets.copyFrom(out, output);
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.server.types.value.ValueSource

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.