Package com.foundationdb.server.types.value

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


            super(context, input);

            nfields = distinctType.nFields();
            currentValues = new Value[nfields];
            for (int i = 0; i < nfields; ++i) {
                currentValues[i] = new Value(distinctType.typeAt(i));
            }
        }
View Full Code Here


                Row output;
                checkQueryCancelation();
                if (isActive()) {
                    long rowCount = adapter().rowCount(adapter().getSession(), tableType);
                    setIdle();
                    output = new ValuesRow(resultType, new Value(MNumeric.BIGINT.instance(false), rowCount));
                }
                else {
                    output = null;
                }
                if (LOG_EXECUTION) {
View Full Code Here

                            @Override
                            public void with(QueryBindings bindings) {
                                eval.with(bindings);
                            }

                            private final Value value = new Value(MString.VARCHAR.instance(255, true));
                        };
                    }

                    @Override
                    public CompoundExplainer getExplainer(ExplainContext context) {
View Full Code Here

    // Do random accesses instead of sequential. Nearby random accesses are potentially faster.
    private void runRandom(int runs, int sequentialAccessesPerRandom, String label)
    {
        ValuesHolderRow boundRow = new ValuesHolderRow(idxRowType);
        Value valueHolder = boundRow.valueAt(0);
        queryBindings.setRow(0, boundRow);
        IndexBound bound = new IndexBound(boundRow, new SetColumnSelector(0));
        IndexKeyRange keyRange = IndexKeyRange.bounded(idxRowType, bound, true, bound, true);
        Ordering ordering = new Ordering();
        ordering.append(field(idxRowType, 0), true);
        Operator plan = indexScan_Default(idxRowType, keyRange, ordering);
        Cursor cursor = cursor(plan, queryContext, queryBindings);
        long startTime = System.nanoTime();
        for (int r = 0; r < runs; r++) {
            for (int s = 0; s < sequentialAccessesPerRandom; s++) {
                Object key = keys[s];
                if (key instanceof Integer) {
                    valueHolder.putInt64((long) ((Integer) key).intValue());
                } else {
                    valueHolder.putString((String) key, null);
                }
                cursor.openTopLevel();
                Row row = cursor.next();
                assert row != null;
                cursor.closeTopLevel();
View Full Code Here

       
        UpdateGenerator updateGenerator = getGenerator(CACHED_UPDATE_GENERATOR, context);

        List<Column> pkList = context.table.getPrimaryKey().getColumns();
        List<Column> upList = new ArrayList<>();
        Value value = new Value(context.typesTranslator.typeForString());
        int i = pkList.size();
        for (Column column : context.table.getColumns()) {
            if (!pkList.contains(column) && context.allValues.containsKey(column)) {
                if (context.allValues.get(column) == null) {
                    value.putNull();
                } else {
                    value.putString(context.allValues.get(column), null);
                }
                context.queryBindings.setValue(i, value);
                upList.add(column);
                i++;
            }
View Full Code Here

        }
        this.evalColumns = new int[functionColumns.size()];
        for (int i = 0; i < evalColumns.length; i++) {
            evalColumns[i] = functionColumns.get(i).getPosition();
        }
        this.vstring = new Value(typesTranslator.typeForString());
        this.values = new Value[rowDef.getFieldCount()];
        this.executionContexts = new TExecutionContext[values.length];
        List<TInstance> inputs = Collections.singletonList(vstring.getType());
        for (int fi = 0; fi < fieldColumns.length; fi++) {
            int ci = fieldColumns[fi];
            TInstance output = columns.get(fi).getType();
            values[ci] = new Value(output);
            // TODO: Only needed until every place gets type from
            // ValueTarget, when there can just be one
            // TExecutionContext wrapping the QueryContext.
            executionContexts[ci] = new TExecutionContext(null,
                                                          inputs, output, queryContext,
                                                          ErrorHandlingMode.WARN,
                                                          ErrorHandlingMode.WARN,
                                                          ErrorHandlingMode.WARN);
        }
        for (int fi = 0; fi < constColumns.length; fi++) {
            int ci = constColumns[fi];
            Column column = defaultColumns.get(fi);
            TInstance output = column.getType();
            Value value = new Value(output);
            TExecutionContext te = new TExecutionContext(null,
                                                         inputs, output, queryContext,
                                                         ErrorHandlingMode.WARN,
                                                         ErrorHandlingMode.WARN,
                                                         ErrorHandlingMode.WARN);
            vstring.putString(column.getDefaultValue(), null);
            value.getType().typeClass().fromObject(te, vstring, value);
            values[ci] = value;
        }
        this.expressions = new TEvaluatableExpression[evalColumns.length];
        TypesRegistryService registry = null;
        if (evalColumns.length > 0) {
View Full Code Here

        }
        int columnIndex = fieldColumns[fieldIndex];
        // bytes -> string -> parsed typed value -> Java object.
        String string = decodeField();
        vstring.putString(string, null);
        Value value = values[columnIndex];
        value.getType().typeClass()
            .fromObject(executionContexts[columnIndex], vstring, value);
        rowCreator.put(value, row, columnIndex);
        fieldIndex++;
        fieldLength = 0;
    }
View Full Code Here

            }
            if (sourceDepth <= 0|| source.isNull(true)) {
                values.get(i).putNull();
            } else {
                sourceDepth--;
                Value valueTarget = values.get(i);
                UnderlyingType underlyingType = TInstance.underlyingType(valueTarget.getType());
                Class<?> expected = underlyingExpectedClasses.get(underlyingType);
                if (source.decodeType() == expected) {
                    switch (underlyingType) {
                        case BOOL:      valueTarget.putBool(source.decodeBoolean());        break;
                        case INT_8:     valueTarget.putInt8((byte)source.decodeLong());     break;
                        case INT_16:    valueTarget.putInt16((short)source.decodeLong());   break;
                        case UINT_16:   valueTarget.putUInt16((char)source.decodeLong());   break;
                        case INT_32:    valueTarget.putInt32((int)source.decodeLong());     break;
                        case INT_64:    valueTarget.putInt64(source.decodeLong());          break;
                        case FLOAT:     valueTarget.putFloat(source.decodeFloat());         break;
                        case DOUBLE:    valueTarget.putDouble(source.decodeDouble());       break;
                        case BYTES:     valueTarget.putBytes(source.decodeByteArray());     break;
                        case STRING:    valueTarget.putString(source.decodeString(), null); break;
                        default: throw new UnsupportedOperationException(valueTarget.getType() + " with " + underlyingType);
                    }
                }
                else {
                    valueTarget.putObject(source.decode());
                }
                // the following assumes that the TClass' readCollating expects the same UnderlyingType for in and out
                valueTarget.getType().readCollating(valueTarget, valueTarget);
            }
            columnsInSegment++;
        }       
    }
View Full Code Here

    public void setBytes(int index, byte x[]) {
        setValue(index, new WrappingByteSource(x), jdbcInstance(Types.VARBINARY));
    }

    public void setDate(int index, Date x) {
        Value value = new Value(jdbcInstance(Types.DATE));
        getTypesTranslator().setTimestampMillisValue(value, x.getTime(), 0);
        setValue(index, value);
    }
View Full Code Here

        getTypesTranslator().setTimestampMillisValue(value, x.getTime(), 0);
        setValue(index, value);
    }

    public void setTime(int index, Time x) {
        Value value = new Value(jdbcInstance(Types.TIME));
        getTypesTranslator().setTimestampMillisValue(value, x.getTime(), 0);
        setValue(index, value);
    }
View Full Code Here

TOP

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

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.