Package com.foundationdb.server.types.value

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


        else
            return new Date(getTypesTranslator().getTimestampMillisValue(value));
    }

    public Time getTime(int index) {
        ValueSource value = value(index);
        if (wasNull)
            return null;
        else {
            return new Time(getTypesTranslator().getTimestampMillisValue(value));
        }
View Full Code Here


            return new Time(getTypesTranslator().getTimestampMillisValue(value));
        }
    }

    public Timestamp getTimestamp(int index) {
        ValueSource value = value(index);
        if (wasNull)
            return null;
        else {
            Timestamp result = new Timestamp(getTypesTranslator().getTimestampMillisValue(value));
            result.setNanos(getTypesTranslator().getTimestampNanosValue(value));
View Full Code Here

    public Timestamp getTimestamp(int index, Calendar cal) {
        return getTimestamp(index);
    }

    public ResultSet getResultSet(int index) {
        ValueSource value = value(index);
        if (wasNull)
            return null;
        else
            return toResultSet(index, value.getObject());
    }
View Full Code Here

    public void setArray(int index, Array x) {
        throw new UnsupportedOperationException();
    }

    public void formatAsJson(int index, AkibanAppender appender, FormatOptions options) {
        ValueSource value = getValue(index);
        value.getType().formatAsJson(value, appender, options);
    }
View Full Code Here

      
        TInstance targetType = type != null ? type.getType() : null;
        if (targetType == null && encoded != null) {
            throw new UnknownDataTypeException(null);
        }
        ValueSource source;
        if (encoded == null) {
            Value value = new Value(targetType);
            value.putNull();
            bindings.setValue(index, value);
            return;
        }
        else if (!binary) {
            try {
                source = new Value(MString.varchar(), new String(encoded, encoding));
            }
            catch (UnsupportedEncodingException ex) {
                throw new UnsupportedCharsetException(encoding);
            }
        }
        else {
            try {
                switch (type.getBinaryEncoding()) {
                case BINARY_OCTAL_TEXT:
                    source = new Value(MBinary.VARBINARY.instance(false), encoded);
                    break;
                case INT_8:
                case INT_16:
                case INT_32:
                case INT_64: // Types.BIGINT
                    // Go by the length sent rather than the implied type.
                    source = decodeIntegerType(encoded);
                    break;
                case FLOAT_32:

                    source = new Value(MApproximateNumber.FLOAT.instance(false), getDataStream(encoded).readFloat());
                    break;
                case FLOAT_64:
                    source = new Value(MApproximateNumber.DOUBLE.instance(false), getDataStream(encoded).readDouble());
                    break;
                case BOOLEAN_C:
                    source = new Value(AkBool.INSTANCE.instance(false), encoded[0] != 0);
                    break;
                case TIMESTAMP_INT64_MICROS_2000_NOTZ: // Types.TIMESTAMP
                    source = decodeTimestampInt64Micros2000NoTZ(encoded);
                    break;
                case UUID:
                    Value value = new Value(AkGUID.INSTANCE.instance(false));
                    value.putObject(AkGUID.bytesToUUID(encoded, 0));
                    source = value;
                    break;
                // Note: these types had previous implementations, but I couldn't exercise them in tests to verify
                // either with jdbc or pg8000. If you run into them, try looking at the log for this file, it most
                // likely has a correct starting point
                case STRING_BYTES:
                case TIMESTAMP_FLOAT64_SECS_2000_NOTZ: // Types.TIMESTAMP
                case DAYS_2000: // DATE
                case TIME_FLOAT64_SECS_NOTZ: // TIME
                case TIME_INT64_MICROS_NOTZ: // TIME
                case DECIMAL_PG_NUMERIC_VAR:
                default:
                    throw new UnknownDataTypeException(type.toString());
                }
            }
            catch (UnsupportedEncodingException ex) {
                throw new UnsupportedCharsetException(encoding);
            }
            catch (IOException ex) {
                throw new AkibanInternalException("IO error reading from byte array", ex);
            }
        }
        TCast cast = typesRegistryService.getCastsResolver().cast(source.getType(), targetType);
        TExecutionContext context =
                new TExecutionContext(Collections.singletonList(source.getType()),
                        targetType,
                        queryContext);
        Value target = new Value(targetType);
        cast.evaluate(context, source, target);
        bindings.setValue(index, target);
View Full Code Here

     * @return the b column of this id (used to make the lower and upper bound.
     *         This is to avoid confusion as to what 'b' values correspond to what id
     */
    private Integer b_of(long id)
    {
        ValueSource val = indexRowWithIdMap.get(id).value(1);
        return (val.isNull() ? null : val.getInt32());
    }
View Full Code Here

        for (int i = 0; i < ncols; i++) {
            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);
View Full Code Here

            // Optimize the common case of directly encoding a string.
            printWriter.write((String)value);
            return;
        }

        ValueSource source = valuefromObject(value, type);
        appendValue(source, type, binary);
    }
View Full Code Here

    
    @Override
    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;
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

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.