Package com.foundationdb.server.types.value

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


        // Get and checking each field should work
        assertEquals(Long.valueOf(11L), getLong(row, 0));
        assertEquals(Long.valueOf(1L), getLong(row, 1));
        assertEquals("ori", row.value(2).getString());
        // Getting all value sources and then using them should also work
        ValueSource v0 = row.value(0);
        ValueSource v1 = row.value(1);
        ValueSource v2 = row.value(2);
        assertEquals(11L, v0.getInt64());
        assertEquals(1L, v1.getInt64());
        assertEquals("ori", v2.getString());
    }
View Full Code Here


        IndexBound zMax = new IndexBound(zMaxRow, indexColumnSelector);
        IndexBound zMin = new IndexBound(zMinRow, indexColumnSelector);
        // Take care of any equality restrictions before the spatial fields
        zPosition = latColumn;
        for (int f = 0; f < zPosition; f++) {
            ValueSource eqValueSource = loExpressions.value(f);
            zForwardRow.value(f, eqValueSource);
            zBackwardRow.value(f, eqValueSource);
            zMaxRow.value(f, eqValueSource);
            zMinRow.value(f, eqValueSource);
        }
View Full Code Here

                SpatialIndexValueRecord zHiRow = new SpatialIndexValueRecord(indexRowFields);
                IndexBound zLo = new IndexBound(zLoRow, indexColumnSelector);
                IndexBound zHi = new IndexBound(zHiRow, indexColumnSelector);
                // Take care of any equality restrictions before the spatial fields
                for (int f = 0; f < latColumn; f++) {
                    ValueSource eqValueSource = loExpressions.value(f);
                    zLoRow.value(f, eqValueSource);
                    zHiRow.value(f, eqValueSource);
                }
                // lo and hi bounds
                Value loValue = new Value(InternalIndexTypes.LONG.instance(false));
View Full Code Here

                if (tFieldTypes[i] == null) {
                    size += 1;
                } else if (tFieldTypes[i].typeClass().hasFixedSerializationSize()) {
                    size += tFieldTypes[i].typeClass().fixedSerializationSize() + 2;
                } else {
                    ValueSource src = row.value(i);
                    if (!src.isNull()) {
                        switch (TInstance.underlyingType(src.getType())) {
                        case STRING:
                            size += AkCollator.getDebugString(src, collators[i]).length() * 2 + 3;
                            break;
                        case BYTES:
                            size += src.getBytes().length;
                            break;
                        default:
                            throw new IllegalArgumentException("Unexpected UnderlyingType: " + src.getType());
                        }
                    } else {
                        size += 1;
                    }
                }
            }
            size = ((size  + SIZE_GRANULARITY - 1) / SIZE_GRANULARITY) * SIZE_GRANULARITY;
           
            // Create a new conversion value
            Value convertValue =  new Value ((Persistit)null,
                        Math.max(size, Value.INITIAL_SIZE),
                        Math.max(size, Value.DEFAULT_MAXIMUM_SIZE));
            valueTarget.attach(convertValue);           
            // Covert the row to the Value for storage in the SortKey
            while(true) {
                try {
                    convertValue.clear();
                    convertValue.setStreamMode(true);
                    for (int i = 0; i < rowFields; i++) {
                        ValueSource field = row.value(i);
                        if (field.isNull()) {
                            valueTarget.putNull();
                        } else {
                            tFieldTypes[i].writeCanonical(field, valueTarget);
                        }
                    }
View Full Code Here

    public void checkConstraints(ValueRecord loExpressions,
                                 ValueRecord hiExpressions,
                                 int f,
                                 AkCollator[] collators,
                                 TInstance[] types) {
        ValueSource loValueSource = loExpressions.value(f);
        ValueSource hiValueSource = hiExpressions.value(f);
        if (loValueSource.isNull() && hiValueSource.isNull()) {
            // OK, they're equal
        } else if (loValueSource.isNull() || hiValueSource.isNull()) {
            throw new IllegalArgumentException(String.format("lo: %s, hi: %s", loValueSource, hiValueSource));
        } else {
            TInstance type = types[f];
            TPreparedExpression loEQHi =
                    new TComparisonExpression(
View Full Code Here

    }

    public RowsBuilder row(ValueSource... values) {
        ArgumentValidation.isEQ("values.length", values.length, tinsts.length);
        for (int i=0; i < values.length; ++i) {
            ValueSource value = values[i];
            TInstance valueType = value.getType();
            TInstance requiredType = tinsts[i];
            if (!valueType.equalsExcludingNullable(requiredType)) {
                throw new IllegalArgumentException("type at " + i + " must be " + requiredType + ", is " + valueType);
            }
        }
View Full Code Here

        @Override
        public void open() {
            TAP_OPEN.in();
            try {
                if (isSkipBinding()) {
                    ValueSource value = bindings.getValue(skip());
                    if (!value.isNull())
                        this.skipLeft = value.getInt32();
                }
                else {
                    this.skipLeft = skip();
                }
                if (skipLeft < 0)
                    throw new NegativeLimitException("OFFSET", skipLeft);
                if (isLimitBinding()) {
                    ValueSource value = bindings.getValue(limit());
                    if (value.isNull())
                        this.limitLeft = Integer.MAX_VALUE;
                    else {
                        TInstance type = MNumeric.INT.instance(true);
                        TExecutionContext executionContext =
                            new TExecutionContext(null, type, context);
View Full Code Here

        @Override
        public void open() {
            String currentSchema = context.getCurrentSchema();
            String schemaName, tableName;
            ValueSource value = valueNotNull(0);
            if (value == null)
                schemaName = currentSchema;
            else
                schemaName = value.getString();
            tableName = bindings.getValue(1).getString();
            rootTable = context.getStore().schema().ais()
                .getTable(schemaName, tableName);
            if (rootTable == null)
                throw new NoSuchTableException(schemaName, tableName);
            int commitFrequency;
            value = valueNotNull(3);
            if (value != null)
                commitFrequency = value.getInt32();
            else if (context.getTransactionPeriodicallyCommit() != ServerTransaction.PeriodicallyCommit.OFF)
                commitFrequency = StoreAdapter.COMMIT_FREQUENCY_PERIODICALLY;
            else
                commitFrequency = 0;
            cursor = context.getStore(rootTable)
                .newDumpGroupCursor(rootTable.getGroup(), commitFrequency);
            cursor.open();
            tableSizes = new HashMap<>();
            buffer = new StringBuilder();
            int insertMaxRowCount;
            value = valueNotNull(2);
            if (value == null)
                insertMaxRowCount = 1;
            else
                insertMaxRowCount = value.getInt32();
            formatter = new SQLRowFormatter(buffer, currentSchema, insertMaxRowCount);
            messagesSent = 0;
        }
View Full Code Here

            messagesSent = 0;
        }

        protected ValueSource valueNotNull(int index) {
            try {
                ValueSource value = bindings.getValue(index);
                if (value.isNull())
                    return null;
                else
                    return value;
            }
            catch (BindingNotSetException ex) {
View Full Code Here

            builder.setExact(2, true);
    }

    @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

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.