Search in sources :

Example 51 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestUnionSuite method testUnionAll.

/**
     * Three table Union ALL - A.PKEY, B.I and C.I
     * @throws NoConnectionsException
     * @throws IOException
     * @throws ProcCallException
     */
public void testUnionAll() throws NoConnectionsException, IOException, ProcCallException {
    Client client = this.getClient();
    VoltTable vt;
    //In the final result set
    client.callProcedure("InsertA", 0, 1);
    //In the final result set
    client.callProcedure("InsertB", 1, 1);
    //In the final result set
    client.callProcedure("InsertB", 2, 1);
    //In the final result set
    client.callProcedure("InsertC", 1, 2);
    //In the final result set
    client.callProcedure("InsertC", 2, 3);
    vt = client.callProcedure("@AdHoc", "SELECT PKEY FROM A UNION ALL SELECT I FROM B " + "UNION ALL SELECT I FROM C order by pkey;").getResults()[0];
    assertEquals(5, vt.getRowCount());
    validateTableOfScalarLongs(vt, new long[] { 0, 1, 1, 2, 3 });
    vt = client.callProcedure("@AdHoc", "(SELECT PKEY FROM A UNION ALL SELECT I FROM B) " + "UNION ALL SELECT I FROM C order by pkey;").getResults()[0];
    assertEquals(5, vt.getRowCount());
    validateTableOfScalarLongs(vt, new long[] { 0, 1, 1, 2, 3 });
    vt = client.callProcedure("@AdHoc", "SELECT PKEY FROM A UNION ALL " + "(SELECT I FROM B UNION ALL SELECT I FROM C) order by pkey;").getResults()[0];
    assertEquals(5, vt.getRowCount());
    validateTableOfScalarLongs(vt, new long[] { 0, 1, 1, 2, 3 });
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Example 52 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestUnionSuite method testStoredProcUnionWithParams.

public void testStoredProcUnionWithParams() throws NoConnectionsException, IOException, ProcCallException {
    // Test that parameterized query with union can be invoked.
    Client client = getClient();
    client.callProcedure("InsertB", 2, 2);
    client.callProcedure("InsertC", 3, 3);
    client.callProcedure("InsertD", 4, 4);
    VoltTable vt;
    vt = client.callProcedure("UnionBCD", 2, "XYZ", 4).getResults()[0];
    assertEquals(3, vt.getRowCount());
    vt = client.callProcedure("UnionBCD", 4, "ABC", 2).getResults()[0];
    assertEquals(1, vt.getRowCount());
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Example 53 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestSystemCatalogSuite method testProcedureColumnsSelector.

public void testProcedureColumnsSelector() throws IOException, ProcCallException {
    Client client = getClient();
    VoltTable[] results = client.callProcedure("@SystemCatalog", "PROCEDURECOLUMNS").getResults();
    assertEquals(20, results[0].getColumnCount());
    System.out.println(results[0]);
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Example 54 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestSystemProcedureSuite method testSwapTables.

public void testSwapTables() throws Exception {
    Client client = getClient();
    for (int ii = 0; ii < SWAPPY_TABLES.length; ++ii) {
        String theTable = SWAPPY_PREFIX_PAIR[0] + SWAPPY_TABLES[ii][0];
        for (int jj = 0; jj < SWAPPY_TABLES.length; ++jj) {
            // Allow swapping only for identically defined tables
            // or those with minor variations in syntax.
            String otherTable = SWAPPY_PREFIX_PAIR[1] + SWAPPY_TABLES[jj][0];
            // verified for reasonableness.
            if ((ii == jj) || (ii == 2 && jj == 3) || (ii == 3 && jj == 2) || (ii == 2 && jj == 4) || (ii == 4 && jj == 2) || (ii == 3 && jj == 4) || (ii == 4 && jj == 3) || (ii == 5 && jj == 6) || (ii == 6 && jj == 5) || (ii == 5 && jj == 7) || (ii == 7 && jj == 5) || (ii == 6 && jj == 7) || (ii == 7 && jj == 6) || (ii == 9 && jj == 10) || (ii == 10 && jj == 9) || (ii == 9 && jj == 11) || (ii == 11 && jj == 9) || (ii == 10 && jj == 11) || (ii == 11 && jj == 10) || (ii == 15 && jj == 16) || (ii == 16 && jj == 15) || (ii == 17 && jj == 18) || (ii == 18 && jj == 17)) {
                VoltTable[] results;
                populateSwappyTables(client, theTable, otherTable);
                results = client.callProcedure("@SwapTables", theTable, otherTable).getResults();
                //*enable to debug*/ System.out.println(results[0]);
                assertNotNull(results);
                assertEquals(1, results.length);
                assertEquals(3, results[0].asScalarLong());
                VoltTable contents = client.callProcedure("@AdHoc", "select * from " + theTable + " order by id").getResults()[0];
                assertContentOfTable(OTHER_SWAP_CONTENTS, contents);
                contents = client.callProcedure("@AdHoc", "select * from " + otherTable + " order by id").getResults()[0];
                assertContentOfTable(THE_SWAP_CONTENTS, contents);
                // Swap again to restore the baseline populations.
                results = client.callProcedure("@SwapTables", otherTable, theTable).getResults();
                //*enable to debug*/ System.out.println(results[0]);
                assertNotNull(results);
                assertEquals(1, results.length);
                assertEquals(3, results[0].asScalarLong());
                // Verify that baseline is restored
                contents = client.callProcedure("@AdHoc", "select * from " + theTable + " order by id").getResults()[0];
                assertContentOfTable(THE_SWAP_CONTENTS, contents);
                contents = client.callProcedure("@AdHoc", "select * from " + otherTable + " order by id").getResults()[0];
                assertContentOfTable(OTHER_SWAP_CONTENTS, contents);
                results = client.callProcedure("@AdHoc", "TRUNCATE TABLE " + theTable).getResults();
                assertEquals(1, results[0].asScalarLong());
                // Try a swap with one empty table.
                results = client.callProcedure("@SwapTables", otherTable, theTable).getResults();
                assertNotNull(results);
                assertEquals(1, results.length);
                assertEquals(2, results[0].asScalarLong());
                contents = client.callProcedure("@AdHoc", "select * from " + theTable + " order by id").getResults()[0];
                assertContentOfTable(OTHER_SWAP_CONTENTS, contents);
                contents = client.callProcedure("@AdHoc", "select * from " + otherTable + " order by id").getResults()[0];
                assertContentOfTable(new Object[][] {}, contents);
                results = client.callProcedure("@AdHoc", "TRUNCATE TABLE " + theTable).getResults();
                assertEquals(2, results[0].asScalarLong());
                contents = client.callProcedure("@AdHoc", "select * from " + theTable + " order by id").getResults()[0];
                assertContentOfTable(new Object[][] {}, contents);
                contents = client.callProcedure("@AdHoc", "select * from " + otherTable + " order by id").getResults()[0];
                assertContentOfTable(new Object[][] {}, contents);
                // Try a swap with both empty tables.
                results = client.callProcedure("@SwapTables", otherTable, theTable).getResults();
                assertNotNull(results);
                assertEquals(1, results.length);
                assertEquals(0, results[0].asScalarLong());
                continue;
            }
            try {
                client.callProcedure("@SwapTables", theTable, otherTable);
                fail("Swap should have conflicted on table definitions " + ii + " and " + jj + " : " + theTable + " with " + otherTable);
            } catch (ProcCallException ex) {
                if (!ex.getMessage().contains("Swapping")) {
                    System.out.println("sup w/ incompatible tables " + ii + " and " + jj + ":" + ex);
                }
                assertTrue("Expected message about swapping but got " + ex.getMessage(), ex.getMessage().contains("Swapping"));
            }
        }
    }
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 55 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestSystemProcedureSuite method testProfCtl.

// verify that these commands don't blow up
public void testProfCtl() throws Exception {
    Client client = getClient();
    //
    // SAMPLER_START
    //
    ClientResponse resp = client.callProcedure("@ProfCtl", "SAMPLER_START");
    VoltTable vt = resp.getResults()[0];
    boolean foundResponse = false;
    while (vt.advanceRow()) {
        String profCtlResult = vt.getString("Result");
        if ("SAMPLER_START".equalsIgnoreCase(profCtlResult)) {
            foundResponse = true;
        } else {
            fail("Was not expecting @ProfCtl result: " + profCtlResult);
        }
    }
    assertTrue(foundResponse);
    //
    // GPERF_ENABLE
    //
    resp = client.callProcedure("@ProfCtl", "GPERF_ENABLE");
    vt = resp.getResults()[0];
    foundResponse = false;
    while (vt.advanceRow()) {
        String profCtlResult = vt.getString("Result");
        if ("GPERF_ENABLE".equalsIgnoreCase(profCtlResult)) {
            foundResponse = true;
        } else {
            assertTrue("GPERF_NOOP".equalsIgnoreCase(profCtlResult));
        }
    }
    assertTrue(foundResponse);
    //
    // GPERF_DISABLE
    //
    resp = client.callProcedure("@ProfCtl", "GPERF_DISABLE");
    vt = resp.getResults()[0];
    foundResponse = false;
    while (vt.advanceRow()) {
        String profCtlResult = vt.getString("Result");
        if ("GPERF_DISABLE".equalsIgnoreCase(profCtlResult)) {
            foundResponse = true;
        } else {
            assertTrue("GPERF_NOOP".equalsIgnoreCase(profCtlResult));
        }
    }
    assertTrue(foundResponse);
    //
    // garbage
    //
    resp = client.callProcedure("@ProfCtl", "MakeAPony");
    vt = resp.getResults()[0];
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Aggregations

VoltTable (org.voltdb.VoltTable)887 Client (org.voltdb.client.Client)497 ClientResponse (org.voltdb.client.ClientResponse)193 ProcCallException (org.voltdb.client.ProcCallException)144 IOException (java.io.IOException)100 VoltTableRow (org.voltdb.VoltTableRow)57 NoConnectionsException (org.voltdb.client.NoConnectionsException)52 ColumnInfo (org.voltdb.VoltTable.ColumnInfo)42 TimestampType (org.voltdb.types.TimestampType)37 BigDecimal (java.math.BigDecimal)30 ArrayList (java.util.ArrayList)27 Test (org.junit.Test)26 File (java.io.File)25 HashMap (java.util.HashMap)21 ClientResponseImpl (org.voltdb.ClientResponseImpl)20 Timestamp (java.sql.Timestamp)15 Date (java.util.Date)15 VoltDB (org.voltdb.VoltDB)15 DependencyPair (org.voltdb.DependencyPair)14 Configuration (org.voltdb.VoltDB.Configuration)14