Package com.foundationdb.server.rowdata

Examples of com.foundationdb.server.rowdata.RowData


        // Insert longs, not integers, because Persistit stores all ints as 8-byte.
        original.put(cId, 100);
        original.put(cA, 200);
        original.put(cB, null);
        RowDef rowDef = getRowDef(t);
        RowData rowData = original.toRowData();
        NiceRow reconstituted = (NiceRow) NiceRow.fromRowData(rowData, rowDef);
        assertEquals(original, reconstituted);
    }
View Full Code Here


    }

    @Override
    public ValueSource uncheckedValue(int i) {
        FieldDef fieldDef = rowDef().getFieldDef(i);
        RowData rowData = rowData();
        RowDataValueSource valueSource = ValueSource(i);
        valueSource.bind(fieldDef, rowData);
        return valueSource;
    }
View Full Code Here

        RowDef rowDef = oldRow.rowType().table().rowDef();
        RowDef rowDefNewRow = newRow.rowType().table().rowDef();
        if (rowDef.getRowDefId() != rowDefNewRow.getRowDefId()) {
            throw new IllegalArgumentException(String.format("%s != %s", rowDef, rowDefNewRow));
        }
        RowData oldRowData = rowData(rowDef, oldRow, new RowDataCreator());
        RowData newRowData = rowData(rowDefNewRow, newRow, new RowDataCreator());
        try {
            store.updateRow(getSession(), rowDef, oldRowData, rowDefNewRow, newRowData, null);
        } catch(InvalidOperationException e) {
            rollbackIfNeeded(getSession(), e);
            throw e;
View Full Code Here

    }

    @Override
    public void writeRow(Row newRow, Collection<TableIndex> indexes, Collection<GroupIndex> groupIndexes) {
        RowDef rowDef = newRow.rowType().table().rowDef();
        RowData newRowData = rowData(rowDef, newRow, new RowDataCreator());
        try {
            store.writeRow(getSession(), rowDef, newRowData, indexes, groupIndexes);
        } catch(InvalidOperationException e) {
            rollbackIfNeeded(getSession(), e);
            throw e;
View Full Code Here

    }

    @Override
    public void deleteRow(Row oldRow, boolean cascadeDelete) {
        RowDef rowDef = oldRow.rowType().table().rowDef();
        RowData oldRowData = rowData(rowDef, oldRow, new RowDataCreator());
        try {
            store.deleteRow(getSession(), rowDef, oldRowData, cascadeDelete);
        } catch(InvalidOperationException e) {
            rollbackIfNeeded(getSession(), e);
            throw e;
View Full Code Here

    protected void encodeDecode(AkibanInformationSchema ais,
                                ProtobufRowDataConverter converter,
                                RowDef rowDef,
                                Object... values)
            throws Exception {
        RowData rowDataIn = new RowData(new byte[128]);
        rowDataIn.createRow(rowDef, values, true);
        DynamicMessage msg = converter.encode(rowDataIn);
        if (false) {
            System.out.println(converter.shortFormat(msg));
        }
        RowData rowDataOut = new RowData(new byte[128]);
        converter.decode(msg, rowDataOut);
        assertEquals("rows match", rowDataIn.toString(ais), rowDataOut.toString(ais));
    }
View Full Code Here

    RowDataValueCoder() {
    }

    @Override
    public void put(final Value value, final Object object, final CoderContext context) throws ConversionException {
        final RowData rowData = (RowData) object;
        final int start = rowData.getInnerStart();
        final int size = rowData.getInnerSize();
        value.ensureFit(size);
        final int at = value.getEncodedSize();
        System.arraycopy(rowData.getBytes(), start, value.getEncodedBytes(), at, size);
        value.setEncodedSize(at + size);
    }
View Full Code Here

        value.setEncodedSize(at + size);
    }

    @Override
    public Object get(final Value value, final Class<?> clazz, final CoderContext context) throws ConversionException {
        final RowData rowData = new RowData(new byte[INITIAL_BUFFER_SIZE]);
        render(value, rowData, RowData.class, null);
        return rowData;
    }
View Full Code Here

    }

    @Override
    public void render(final Value value, final Object target, final Class<?> clazz, final CoderContext context)
            throws ConversionException {
        final RowData rowData = (RowData) target;
        final int at = value.getCursor();
        final int end = value.getEncodedSize();
        final int size = end - at;

        final int rowDataSize = size + RowData.ENVELOPE_SIZE;
        final byte[] valueBytes = value.getEncodedBytes();
        byte[] rowDataBytes = rowData.getBytes();

        if (rowDataSize < RowData.MINIMUM_RECORD_LENGTH || rowDataSize > RowData.MAXIMUM_RECORD_LENGTH) {
            throw new CorruptRowDataException("RowData is too short or too long: " + rowDataSize);
        }

        if (rowDataBytes == null || rowDataSize > rowDataBytes.length) {
            rowDataBytes = new byte[rowDataSize + INITIAL_BUFFER_SIZE];
            rowData.reset(rowDataBytes);
        }

        //
        // Assemble the Row in a byte array
        //
        AkServerUtil.putInt(rowDataBytes, RowData.O_LENGTH_A, rowDataSize);
        AkServerUtil.putShort(rowDataBytes, RowData.O_SIGNATURE_A, RowData.SIGNATURE_A);
        System.arraycopy(valueBytes, at, rowDataBytes, RowData.O_FIELD_COUNT, size);
        AkServerUtil.putShort(rowDataBytes, RowData.O_SIGNATURE_B + rowDataSize, RowData.SIGNATURE_B);
        AkServerUtil.putInt(rowDataBytes, RowData.O_LENGTH_B + rowDataSize, rowDataSize);
        rowData.prepareRow(0);

        value.setCursor(end);
    }
View Full Code Here

    @Override
    public void display(final Value value, final StringBuilder target, final Class<?> clazz, final CoderContext context)
            throws ConversionException {
        final Object object = get(value, clazz, context);
        if (object instanceof RowData) {
            final RowData rowData = (RowData) object;
            target.append(rowData.toString());
        } else {
            target.append(object);
        }
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.server.rowdata.RowData

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.