Package org.voltdb

Examples of org.voltdb.VoltTable


        }
        return repl_table;
    }

    private VoltTable createPartitionedTable(int numberOfItems, int indexBase) {
        VoltTable partition_table = new VoltTable(new ColumnInfo("PT_ID", VoltType.INTEGER), new ColumnInfo("PT_NAME", VoltType.STRING), new ColumnInfo("PT_INTVAL", VoltType.INTEGER), new ColumnInfo(
                "PT_FLOATVAL", VoltType.FLOAT));

        for (int i = indexBase; i < numberOfItems + indexBase; i++) {
            Object[] row = new Object[] { i, "name_" + i, i, new Double(i) };
            partition_table.addRow(row);
        }

        return partition_table;
    }
View Full Code Here


        loadLargeReplicatedTable(client, tableName, itemsPerChunk, numChunks, false, null);
    }

    private void loadLargeReplicatedTable(Client client, String tableName, int itemsPerChunk, int numChunks, boolean generateCSV, StringBuilder sb) {
        for (int i = 0; i < numChunks; i++) {
            VoltTable repl_table = createReplicatedTable(itemsPerChunk, i * itemsPerChunk, sb, generateCSV);
            loadTable(client, tableName, repl_table);
        }
        if (sb != null) {
            sb.trimToSize();
        }
View Full Code Here

        }
    }

    private void loadLargePartitionedTable(Client client, String tableName, int itemsPerChunk, int numChunks) {
        for (int i = 0; i < numChunks; i++) {
            VoltTable part_table = createPartitionedTable(itemsPerChunk, i * itemsPerChunk);
            loadTable(client, tableName, part_table);
        }
    }
View Full Code Here

    private void checkTable(Client client, String tableName, String orderByCol, int expectedRows) {
        if (expectedRows > 200000) {
            System.out.println("Table too large to retrieve with select *");
            System.out.println("Skipping integrity check");
        }
        VoltTable result = null;
        try {
            result = client.callProcedure("SaveRestoreSelect", tableName).getResults()[0];

        } catch (Exception e) {
            e.printStackTrace();
        }
        final int rowCount = result.getRowCount();
        assertEquals(expectedRows, rowCount);

        // System.out.println("Check table :: \n"+result);

        int i = 0;
        while (result.advanceRow()) {
            assertEquals(i, result.getLong(0));
            assertEquals("name_" + i, result.getString(1));
            assertEquals(i, result.getLong(2));
            assertEquals(new Double(i), result.getDouble(3));
            ++i;
        }
    }
View Full Code Here

                // can also fail due to "SNAPSHOT IN PROGRESS"
                // assertTrue(results[0].getString("ERR_MSG").contains("SAVE FILE ALREADY EXISTS"));
            }
        }

        VoltTable deleteResults[] = client.callProcedure("@SnapshotDelete", new String[] { TMPDIR }, new String[] { TESTNONCE }).getResults();

        assertNotNull(deleteResults);
        assertEquals(1, deleteResults.length);
        System.out.println(deleteResults[0]);
        assertEquals(9, deleteResults[0].getColumnCount());
View Full Code Here

        Client client = this.getClient();
        TestSmallBankSuite.initializeSmallBankDatabase(catalogContext, client);
        long acctIds[] = { 1l, 2l };
        double balances[] = { 100d, 0d };
        ClientResponse cresponse;
        VoltTable results[];

        Table catalog_tbl = catalogContext.getTableByName(SmallBankConstants.TABLENAME_ACCOUNTS);
        long num_rows = RegressionSuiteUtil.getRowCount(client, catalog_tbl);
        assert(num_rows > acctIds[acctIds.length-1]);
        // System.err.println("# of Rows: " + num_rows);
View Full Code Here

        // Make sure that we set it correctly
        String query = String.format("SELECT * FROM %s WHERE custid = %d",
                              SmallBankConstants.TABLENAME_CHECKING, acctId);
        ClientResponse cresponse = client.callProcedure("@AdHoc", query);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
       
        if (results[0].getRowCount() == 0) {
            System.err.println(VoltTableUtil.format(results[0]));
        }
View Full Code Here

                                     SmallBankConstants.TABLENAME_CHECKING,
                                     balance, acctId);
        String procName = VoltSystemProcedure.procCallName(AdHoc.class);
        ClientResponse cresponse = client.callProcedure(procName, query);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        assertTrue(results[0].advanceRow());
    }
View Full Code Here

        } catch (ProcCallException e) {
            threwException = true;
            assertTrue(e.getMessage().contains("CONSTRAINT VIOLATION"));
            assertTrue(e.getCause().getMessage().toUpperCase().contains("UNIQUE"));
            if (!isHSQL()) {
                VoltTable table = ((ConstraintFailureException)e.getCause()).getTuples();
                table.resetRowPosition();
                assertTrue(table.advanceRow());
                assertTrue(java.util.Arrays.equals(stringData, table.getStringAsBytes(2)));
            }
        }
        assertTrue(threwException);
    }
View Full Code Here

    private VoltTable createReplicatedTable(int numberOfItems, int indexBase, StringBuilder sb) {
        return createReplicatedTable(numberOfItems, indexBase, sb, false);
    }

    private VoltTable createReplicatedTable(int numberOfItems, int indexBase, StringBuilder sb, boolean generateCSV) {
        VoltTable repl_table = new VoltTable(new ColumnInfo("RT_ID", VoltType.INTEGER), new ColumnInfo("RT_NAME", VoltType.STRING), new ColumnInfo("RT_INTVAL", VoltType.INTEGER), new ColumnInfo(
                "RT_FLOATVAL", VoltType.FLOAT));
        char delimeter = generateCSV ? ',' : '\t';
        for (int i = indexBase; i < numberOfItems + indexBase; i++) {
            String stringVal = null;
            String escapedVal = null;

            if (sb != null) {
                if (generateCSV) {
                    int escapable = i % 5;
                    switch (escapable) {
                        case 0:
                            stringVal = "name_" + i;
                            escapedVal = "name_" + i;
                            break;
                        case 1:
                            stringVal = "na,me_" + i;
                            escapedVal = "\"na,me_" + i + "\"";
                            break;
                        case 2:
                            stringVal = "na\"me_" + i;
                            escapedVal = "\"na\"\"me_" + i + "\"";
                            break;
                        case 3:
                            stringVal = "na\rme_" + i;
                            escapedVal = "\"na\rme_" + i + "\"";
                            break;
                        case 4:
                            stringVal = "na\nme_" + i;
                            escapedVal = "\"na\nme_" + i + "\"";
                            break;
                    }
                } else {
                    int escapable = i % 5;
                    switch (escapable) {
                        case 0:
                            stringVal = "name_" + i;
                            escapedVal = "name_" + i;
                            break;
                        case 1:
                            stringVal = "na\tme_" + i;
                            escapedVal = "na\\tme_" + i;
                            break;
                        case 2:
                            stringVal = "na\nme_" + i;
                            escapedVal = "na\\nme_" + i;
                            break;
                        case 3:
                            stringVal = "na\rme_" + i;
                            escapedVal = "na\\rme_" + i;
                            break;
                        case 4:
                            stringVal = "na\\me_" + i;
                            escapedVal = "na\\\\me_" + i;
                            break;
                    }
                }
            } else {
                stringVal = "name_" + i;
            }

            Object[] row = new Object[] { i, stringVal, i, new Double(i) };
            if (sb != null) {
                sb.append(i).append(delimeter).append(escapedVal).append(delimeter);
                sb.append(i).append(delimeter).append(new Double(i).toString()).append('\n');
            }
            repl_table.addRow(row);
        }
        return repl_table;
    }
View Full Code Here

TOP

Related Classes of org.voltdb.VoltTable

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.