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

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


        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


    }

    public void visit(Key key, RowData rowData) {
        RowDef rowDef = store.getAIS(session).getTable(rowData.getRowDefId()).rowDef();
        Object[] keyObjs = key(key, rowDef);
        NewRow newRow = new LegacyRowWrapper(rowDef, rowData);
        visit(keyObjs, newRow);
    }
View Full Code Here

        List<RowData> rowDatas = null;
        if (maxRetries > 0)
            rowDatas = new ArrayList<>();
        boolean transaction = false;
        try {
            NewRow row;
            RowData rowData = null;
            do {
                if (!transaction) {
                    // A transaction is needed, even to read rows, because of auto
                    // increment.
                    transactionService.beginTransaction(session);
                    transaction = true;
                }
                row = reader.nextRow();
                logger.trace("Read row: {}", row);
                if (row != null) {
                    rowData = row.toRowData().copy();
                    if (rowDatas != null) {
                        // Make a copy now so that what we keep is compacter.
                        rowDatas.add(rowData);
                    }
                    total++;
View Full Code Here

    protected static RowData mergeRows(RowDef oldRowDef, RowData currentRow, RowDef newRowDef, RowData newRowData, ColumnSelector selector) {
        if(selector == null || selector == ConstantColumnSelector.ALL_ON) {
            return newRowData;
        }
        NewRow mergedRow = NiceRow.fromRowData(currentRow, oldRowDef);
        NewRow newRow = new LegacyRowWrapper(newRowDef, newRowData);
        int fields = oldRowDef.getFieldCount();
        for(int i = 0; i < fields; i++) {
            if(selector.includesColumn(i)) {
                mergedRow.put(i, newRow.get(i));
            }
        }
        return mergedRow.toRowData();
    }
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

                                "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

        InputStream istr = new FileInputStream(DUMP_FILE);
        MysqlDumpRowReader reader = new MysqlDumpRowReader(t1, t1.getColumns(),
                                                           istr, "UTF-8",
                                                           null, MTypesTranslator.INSTANCE);
        List<NewRow> rows = new ArrayList<>();
        NewRow row;
        while ((row = reader.nextRow()) != null)
            rows.add(row);
        istr.close();
        assertEquals("number of rows", ROWS.length, rows.size());
        for (int i = 0; i < ROWS.length; i++) {
            Object[] orow = ROWS[i];
            row = rows.get(i);
            assertEquals("row " + i + " size", orow.length, row.getRowDef().getFieldCount());
            for (int j = 0; j < orow.length; j++) {
                assertEquals("row " + i + " col " + j, orow[j], row.get(j));
            }
        }
    }
View Full Code Here

TOP

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

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.