Package com.foundationdb.server.types.value

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


        return false;
    }

    public Object getValue() {
        if (value == null) {
            ValueSource valueSource = getPreptimeValue().value();
            if (valueSource == null || valueSource.isNull())
                return null;
            value = ValueSources.toObject(valueSource);
        }
        return value;
    }
View Full Code Here


        return v.visit(this);
    }

    @Override
    public String toString() {
        ValueSource valueSource = getPreptimeValue().value();
        if (valueSource == null || valueSource.isNull())
            return "NULL";

        StringBuilder sb = new StringBuilder();
        getType().format(valueSource, AkibanAppender.of(sb));
        return sb.toString();
View Full Code Here

        @Override
        protected ValueSource getValue(int index) {
            TInstance type = getType(index);
            TClass tclass = type.typeClass();
            ValueSource source;
            if (parameterArgs[index] < 0) {
                source = ValueSources.valuefromObject(constantArgs[index], type);
                if (source.getType().typeClass().equals(tclass))
                    return source; // Literal value matches.
            }
            else {
                source = bindings.getValue(parameterArgs[index]);
            }
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 unixTime = inputs.get(0).value();
                   
                    // if the unix time value is not literal, get the length
                    // from the format string
                    length = computeLength(format.getString());
                   
                    // if the unix time is available, get the actual length
                    if (unixTime != null)
                    {
                        Object prepObjects[] = computeResult(unixTime.getInt64(),
                                                            format.getString(),
                                                            context.getCurrentTimezone());
                        context.set(RET_INDEX, prepObjects[RET_INDEX]);
                        context.set(ERROR_INDEX, prepObjects[ERROR_INDEX]);
                       
View Full Code Here

    }

    @Override
    protected void doEvaluate(TExecutionContext context, LazyList<? extends ValueSource> inputs, ValueTarget output)
    {
        ValueSource condition = inputs.get(0);
        int whichSource = (!condition.isNull() && condition.getBoolean()) ? 1 : 2;
        ValueSource source = inputs.get(whichSource);
        ValueTargets.copyFrom(source, output);
    }
View Full Code Here

        return TOverloadResult.custom(new TCustomOverloadResult()
        {
            @Override
            public TInstance resultInstance(List<TPreptimeValue> inputs, TPreptimeContext context)
            {
                ValueSource string = inputs.get(0).value();
                int strLen;
                if (string == null || string.isNull()) {
                    strLen = 0;
                } else {
                    strLen = string.getString().length();
                }
                ValueSource length = inputs.get(1).value();
                int count;
                if (length == null || length.isNull() || (count = length.getInt32()) <= 0) {
                    return stringType.instance(0, anyContaminatingNulls(inputs));
                } else {
                    return stringType.instance(count * strLen, anyContaminatingNulls(inputs));
                }
            }
View Full Code Here

    }

    protected void addFields(Row row, List<IndexedField> fields) throws IOException {
        if (fields == null) return;
        for (IndexedField indexedField : fields) {
            ValueSource value = row.value(indexedField.getPosition());
            Field field = indexedField.getField(value);
            currentDocument.add(field);
        }
    }
View Full Code Here

    @Override
    public TOverloadResult resultType() {
        return TOverloadResult.custom(new TCustomOverloadResult() {
            @Override
            public TInstance resultInstance(List<TPreptimeValue> inputs, TPreptimeContext context) {
                ValueSource incomingScale = signatureStrategy.getScaleOperand(inputs);
                int resultScale = (incomingScale == null)
                        ? inputs.get(0).type().attribute(DoubleAttribute.SCALE)
                        : incomingScale.getInt32();
                int resultPrecision = 17 + resultScale;
                return MApproximateNumber.DOUBLE.instance(resultPrecision, resultScale, anyContaminatingNulls(inputs));
            }
        });
    }
View Full Code Here

    {
        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);
        }

        // Pattern (and any optional escape) are constant: can precompile the matcher.
View Full Code Here

    @Override
    protected Constantness constness(TPreptimeContext context, int inputIndex, LazyList<? extends TPreptimeValue> values) {
        // The expression is const iff either argument is a const whose value is equal to op.contaminant.
        // The first argument can never make the expression non-const (though it can make it const), and the second
        // argument can never leave the constness unknown.
        ValueSource preptimeValue = constSource(values, inputIndex);
        if ((preptimeValue != null) && Objects.equal(op.contaminant, getBoolean(preptimeValue)))
        {
            context.set(OUT_VAL, op.contaminant);
            return Constantness.CONST;
        }
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.