Package com.foundationdb.server.api.dml.scan

Examples of com.foundationdb.server.api.dml.scan.NiceRow


    protected NewRow row() {
        return row;
    }

    protected NewRow newRow() {
        row = new NiceRow(tableId, rowDef);
        fieldIndex = fieldLength = 0;
        return row;
    }
View Full Code Here


        return session;
    }

    public RowData rowData(RowDef rowDef, Row row, RowDataCreator creator) {
        // Generic conversion, subclasses should override to check for known group rows
        NewRow niceRow = new NiceRow(rowDef.getRowDefId(), rowDef);
        int fields = rowDef.table().getColumnsIncludingInternal().size();
        for(int i = 0; i < fields; ++i) {
            creator.put(row.value(i), niceRow, i);
        }
        return niceRow.toRowData();
    }
View Full Code Here

            }
        }
    }

    private void trackChange(Session session, Table table, Key hKey) {
        NiceRow row = null;
        for(Index index : table.getFullTextIndexes()) {
            if(row == null) {
                AkibanInformationSchema ais = getAIS(session);
                Table changeTable = ais.getTable(CHANGES_TABLE);
                row = new NiceRow(changeTable.getTableId(), changeTable.rowDef());
            }
            row.put(0, index.getIndexName().getSchemaName());
            row.put(1, index.getIndexName().getTableName());
            row.put(2, index.getIndexName().getName());
            row.put(3, index.getIndexId());
            row.put(4, Arrays.copyOf(hKey.getEncodedBytes(), hKey.getEncodedSize()));
            store.writeNewRow(session, row);
        }
    }
View Full Code Here

                                "t",
                                "id int not null primary key",
                                "a int",
                                "b int",
                                "c int");
        NewRow niceRow = new NiceRow(t, getRowDef(t));
        int cId = 0;
        int cA = 1;
        int cB = 2;
        int cC = 3;
        // Insert longs, not integers, because Persistit stores all ints as 8-byte.
        niceRow.put(cId, 100);
        niceRow.put(cA, 200);
        niceRow.put(cB, 300);
        niceRow.put(cC, null);
        LegacyRowWrapper legacyRow = new LegacyRowWrapper(niceRow.getRowDef(), niceRow.toRowData());
        assertEquals(100, legacyRow.get(cId));
        assertEquals(200, legacyRow.get(cA));
        assertEquals(300, legacyRow.get(cB));
        assertNull(legacyRow.get(cC));
        legacyRow.put(cA, 222);
View Full Code Here

                                "t",
                                "id int not null primary key",
                                "a int",
                                "b int",
                                "c int");
        NewRow niceRow = new NiceRow(t, getRowDef(t));
        int cId = 0;
        int cA = 1;
        int cB = 2;
        int cC = 3;
        // Insert longs, not integers, because Persistit stores all ints as 8-byte.
        niceRow.put(cId, 0);
        niceRow.put(cA, 0);
        niceRow.put(cB, 0);
        niceRow.put(cC, 0);
        // Create initial legacy row
        LegacyRowWrapper legacyRow = new LegacyRowWrapper(niceRow.getRowDef(), niceRow.toRowData());
        assertEquals(0, legacyRow.get(cA));
        assertEquals(0, legacyRow.get(cB));
        assertEquals(0, legacyRow.get(cC));
        // Apply a few updates
        legacyRow.put(cA, 1);
        legacyRow.put(cB, 1);
        legacyRow.put(cC, 1);
        // Check the updates (should be a NiceRow)
        assertEquals(1, legacyRow.get(cA));
        assertEquals(1, legacyRow.get(cB));
        assertEquals(1, legacyRow.get(cC));
        // Convert to LegacyRow and check NiceRow created from the legacy row's RowData
        RowDef rowDef = getRowDef(t);
        niceRow = (NiceRow) NiceRow.fromRowData(legacyRow.toRowData(), rowDef);
        assertEquals(1, niceRow.get(cA));
        assertEquals(1, niceRow.get(cB));
        assertEquals(1, niceRow.get(cC));
        // Convert back to NiceRow and check state again
        legacyRow.put(cA, 2);
        legacyRow.put(cB, 2);
        legacyRow.put(cC, 2);
        assertEquals(2, legacyRow.get(cA));
View Full Code Here

        int t = createTable("s",
                                "t",
                                "id int not null primary key",
                                "a int not null",
                                "b int not null");
        NewRow original = new NiceRow(t, getRowDef(t));
        int cId = 0;
        int cA = 1;
        int cB = 2;
        // Insert longs, not integers, because Persistit stores all ints as 8-byte.
        original.put(cId, 100);
        original.put(cA, 200);
        original.put(cB, 300);
        RowDef rowDef = getRowDef(t);
        RowData rowData = original.toRowData();
        NiceRow reconstituted = (NiceRow) NiceRow.fromRowData(rowData, rowDef);
        assertEquals(original, reconstituted);
    }
View Full Code Here

        int t = createTable("s",
                                "t",
                                "id int not null primary key",
                                "a int not null",
                                "b int");
        NewRow original = new NiceRow(t, getRowDef(t));
        int cId = 0;
        int cA = 1;
        int cB = 2;
        // 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

                                "t",
                                "id int not null primary key",
                                "a int",
                                "b int",
                                "c int");
        NewRow row = new NiceRow(t, getRowDef(t));
        int cId = 0;
        int cA = 1;
        int cB = 2;
        int cC = 3;
        // Insert longs, not integers, because Persistit stores all ints as 8-byte.
        row.put(cId, 100);
        row.put(cA, 200);
        row.put(cB, 300);
        row.put(cC, null);
        assertEquals(100, row.get(cId));
        assertEquals(200, row.get(cA));
        assertEquals(300, row.get(cB));
        assertNull(row.get(cC));
        row.put(cA, 222);
        row.put(cB, null);
        row.put(cC, 444);
        assertEquals(100, row.get(cId));
        assertEquals(222, row.get(cA));
        assertNull(row.get(cB));
        assertEquals(444, row.get(cC));
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.server.api.dml.scan.NiceRow

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.