Search in sources :

Example 41 with VoltTableRow

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

the class ostatByCustomerName method run.

public VoltTable[] run(short w_id, byte d_id, String c_last) {
    voltQueueSQL(getCustomersByLastName, w_id, d_id, c_last);
    VoltTable customers = voltExecuteSQL()[0];
    // Get the midpoint customer's id
    final int namecnt = customers.getRowCount();
    final int index = (namecnt - 1) / 2;
    final VoltTableRow customer = customers.fetchRow(index);
    final long c_id = customer.getLong(C_ID_IDX);
    // Build an VoltTable with a single customer row
    final VoltTable customerResultTable = result_template.clone(1024);
    customerResultTable.addRow(c_id, customer.getStringAsBytes(1), customer.getStringAsBytes(2), customer.getStringAsBytes(3), customer.getDouble(4));
    // Do the rest of the work
    return getOrderStatus(w_id, d_id, c_id, customerResultTable);
}
Also used : VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow)

Example 42 with VoltTableRow

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

the class paymentByCustomerIdC method run.

public VoltTable[] run(short w_id, byte d_id, double h_amount, short c_w_id, byte c_d_id, int c_id, TimestampType timestamp) {
    // assert (w_id == c_w_id); cross partition should be supported (at least in future)
    voltQueueSQL(getCustomersByCustomerId, c_id, c_d_id, c_w_id);
    final VoltTableRow customer = voltExecuteSQL()[0].fetchRow(0);
    return processPayment(w_id, d_id, c_w_id, c_d_id, c_id, h_amount, customer, timestamp);
}
Also used : VoltTableRow(org.voltdb.VoltTableRow)

Example 43 with VoltTableRow

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

the class TestJoinsSuite method subtestIndexOuterJoin.

/**
     * Two table left and right NLIJ
     * @throws NoConnectionsException
     * @throws IOException
     * @throws ProcCallException
     */
private void subtestIndexOuterJoin(Client client, String joinOp) throws Exception {
    client.callProcedure("R2.INSERT", 1, 1);
    client.callProcedure("R2.INSERT", 2, 2);
    client.callProcedure("R2.INSERT", 3, 3);
    client.callProcedure("R2.INSERT", 4, 4);
    String query;
    VoltTable result;
    // R2 1st joined with R3 null
    // R2 2nd joined with R3 null
    // R2 3rd joined with R3 null
    // R2 4th joined with R3 null
    query = "SELECT * FROM R2 LEFT JOIN R3 " + "ON R3.A " + joinOp + " R2.A " + "ORDER BY R2.A";
    result = client.callProcedure("@AdHoc", query).getResults()[0];
    assertEquals(4, result.getRowCount());
    VoltTableRow row = result.fetchRow(2);
    assertEquals(3, row.getLong(1));
    client.callProcedure("R3.INSERT", 1, 1);
    client.callProcedure("R3.INSERT", 2, 2);
    client.callProcedure("R3.INSERT", 5, 5);
    // R2 1st joined with R3 1st
    // R2 2nd joined with R3 2nd
    // R2 3rd joined with R3 null
    // R2 4th joined with R3 null
    query = "SELECT * FROM R2 LEFT JOIN R3 " + "ON R3.A " + joinOp + " R2.A";
    validateRowCount(client, query, 4);
    query = "SELECT * FROM R3 RIGHT JOIN R2 " + "ON R3.A " + joinOp + " R2.A";
    validateRowCount(client, query, 4);
    // Same as above but with partitioned table
    client.callProcedure("P2.INSERT", 1, 1);
    client.callProcedure("P2.INSERT", 2, 2);
    client.callProcedure("P2.INSERT", 3, 3);
    client.callProcedure("P2.INSERT", 4, 4);
    query = "SELECT * FROM P2 LEFT JOIN R3 " + "ON R3.A = P2.A";
    validateRowCount(client, query, 4);
    // R2 1st joined with R3 NULL R2.C < 0
    // R2 2nd joined with R3 null R2.C < 0
    // R2 3rd joined with R3 null R2.C < 0
    // R2 4th joined with R3 null R2.C < 0
    query = "SELECT * FROM R2 LEFT JOIN R3 " + "ON R3.A " + joinOp + " R2.A AND R2.C < 0";
    validateRowCount(client, query, 4);
    query = "SELECT * FROM R3 RIGHT JOIN R2 " + "ON R3.A " + joinOp + " R2.A AND R2.C < 0";
    validateRowCount(client, query, 4);
    // Same as above but with partitioned table
    query = "SELECT * FROM P2 LEFT JOIN R3 " + "ON R3.A " + joinOp + " P2.A AND P2.E < 0";
    // R2 1st joined with R3 null eliminated by R3.A > 1
    // R2 2nd joined with R3 2nd
    // R2 3rd joined with R3 null
    // R2 4th joined with R3 null
    query = "SELECT * FROM R2 LEFT JOIN R3 " + "ON R3.A " + joinOp + " R2.A AND R3.A > 1";
    validateRowCount(client, query, 4);
    query = "SELECT * FROM R3 RIGHT JOIN R2 " + "ON R3.A " + joinOp + " R2.A AND R3.A > 1";
    validateRowCount(client, query, 4);
    // R2 1st joined with R3 1st  but eliminated by  R3.A IS NULL
    // R2 2nd joined with R3 2nd  but eliminated by  R3.A IS NULL
    // R2 3rd joined with R3 null
    // R2 4th joined with R3 null
    query = "SELECT * FROM R2 LEFT JOIN R3 " + "ON R3.A " + joinOp + " R2.A WHERE R3.A IS NULL";
    if (joinOp.equals("=") || !isHSQL()) {
        //// PENDING HSQL flaw investigation
        validateRowCount(client, query, 2);
    } else {
        result = client.callProcedure("@AdHoc", query).getResults()[0];
        System.out.println("Ignoring erroneous(?) HSQL baseline: " + result);
        if (2 == result.getRowCount()) {
            System.out.println("The HSQL error MAY have been solved. Consider simplifying this test.");
        }
    }
    query = "SELECT * FROM R3 RIGHT JOIN R2 " + "ON R3.A " + joinOp + " R2.A WHERE R3.A IS NULL";
    if (isHSQL()) {
        //// PENDING HSQL flaw investigation
        result = client.callProcedure("@AdHoc", query).getResults()[0];
        System.out.println("Ignoring erroneous(?) HSQL baseline: " + result);
        if (2 == result.getRowCount()) {
            System.out.println("The HSQL error MAY have been solved. Consider simplifying this test.");
        }
    } else {
        validateRowCount(client, query, 2);
    }
    // Same as above but with partitioned table
    query = "SELECT * FROM R3 RIGHT JOIN P2 " + "ON R3.A " + joinOp + " P2.A WHERE R3.A IS NULL";
    if (isHSQL()) {
        //// PENDING HSQL flaw investigation
        result = client.callProcedure("@AdHoc", query).getResults()[0];
        System.out.println("Ignoring erroneous(?) HSQL baseline: " + result);
        if (2 == result.getRowCount()) {
            System.out.println("The HSQL error MAY have been solved. Consider simplifying this test.");
        }
    } else {
        validateRowCount(client, query, 2);
    }
    // R2 1st eliminated by R2.C < 0
    // R2 2nd eliminated by R2.C < 0
    // R2 3rd eliminated by R2.C < 0
    // R2 4th eliminated by R2.C < 0
    query = "SELECT * FROM R2 LEFT JOIN R3 " + "ON R3.A " + joinOp + " R2.A WHERE R2.C < 0";
    validateRowCount(client, query, 0);
    // Same as above but with partitioned table
    query = "SELECT * FROM P2 LEFT JOIN R3 " + "ON R3.A " + joinOp + " P2.A WHERE P2.E < 0";
    validateRowCount(client, query, 0);
    // Outer table index scan
    // R3 1st eliminated by R3.A > 0 where filter
    // R3 2nd joined with R3 2
    // R3 3rd joined with R2 null
    query = "select * FROM R3 LEFT JOIN R2 " + "ON R3.A " + joinOp + " R2.A WHERE R3.A > 1";
    validateRowCount(client, query, 2);
}
Also used : VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow)

Example 44 with VoltTableRow

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

the class TestJoinsSuite method subtestSeqOuterJoin.

/**
     * Two table left and right NLJ
     * @throws NoConnectionsException
     * @throws IOException
     * @throws ProcCallException
     */
private void subtestSeqOuterJoin(Client client, String joinOp) throws Exception {
    client.callProcedure("R1.INSERT", 1, 1, 1);
    client.callProcedure("R1.INSERT", 1, 2, 1);
    client.callProcedure("R1.INSERT", 2, 2, 2);
    client.callProcedure("R1.INSERT", -1, 3, 3);
    // R1 1st joined with R2 null
    // R1 2nd joined with R2 null
    // R1 3rd joined with R2 null
    // R1 4th joined with R2 null
    String query;
    VoltTable result;
    query = "SELECT * FROM R1 LEFT JOIN R2 " + "ON R1.A " + joinOp + " R2.C";
    result = client.callProcedure("@AdHoc", query).getResults()[0];
    //* enable to debug */ System.out.println(result);
    assertEquals(4, result.getRowCount());
    VoltTableRow row = result.fetchRow(2);
    assertEquals(2, row.getLong(1));
    client.callProcedure("R2.INSERT", 1, 1);
    client.callProcedure("R2.INSERT", 1, 3);
    client.callProcedure("R2.INSERT", 3, null);
    // R1 1st joined with R2 1st
    // R1 2nd joined with R2 1st
    // R1 3rd joined with R2 null
    // R1 4th joined with R2 null
    query = "SELECT * FROM R1 LEFT JOIN R2 " + "ON R1.A " + joinOp + " R2.C";
    validateRowCount(client, query, 4);
    query = "SELECT * FROM R2 RIGHT JOIN R1 " + "ON R1.A " + joinOp + " R2.C";
    validateRowCount(client, query, 4);
    // Same as above but with partitioned table
    client.callProcedure("P1.INSERT", 1, 1);
    client.callProcedure("P1.INSERT", 1, 2);
    client.callProcedure("P1.INSERT", 2, 2);
    client.callProcedure("P1.INSERT", -1, 3);
    query = "SELECT * FROM P1 LEFT JOIN R2 " + "ON P1.A " + joinOp + " R2.C";
    validateRowCount(client, query, 4);
    // R1 1st joined with R2 with R2 1st
    // R1 2nd joined with R2 null (failed R1.C = 1)
    // R1 3rd joined with R2 null (failed  R1.A " + joinOp + " R2.C)
    // R1 4th3rd joined with R2 null (failed  R1.A " + joinOp + " R2.C)
    query = "SELECT * FROM R1 LEFT JOIN R2 " + "ON R1.A " + joinOp + " R2.C AND R1.C = 1";
    validateRowCount(client, query, 4);
    query = "SELECT * FROM R2 RIGHT JOIN R1 " + "ON R1.A " + joinOp + " R2.C AND R1.C = 1";
    validateRowCount(client, query, 4);
    // Same as above but with partitioned table
    query = "SELECT * FROM R2 RIGHT JOIN P1 " + "ON P1.A " + joinOp + " R2.C AND P1.C = 1";
    validateRowCount(client, query, 4);
    // R1 1st joined with R2 null - eliminated by the second join condition
    // R1 2nd joined with R2 null
    // R1 3rd joined with R2 null
    // R1 4th joined with R2 null
    query = "SELECT * FROM R1 LEFT JOIN R2 " + "ON R1.A " + joinOp + " R2.C AND R2.A = 100";
    validateRowCount(client, query, 4);
    // R1 1st - joined with R2 not null and eliminated by the filter condition
    // R1 2nd - joined with R2 not null and eliminated by the filter condition
    // R1 3rd - joined with R2 null
    // R1 4th - joined with R2 null
    query = "SELECT * FROM R1 LEFT JOIN R2 " + "ON R1.A " + joinOp + " R2.C WHERE R2.A IS NULL";
    validateRowCount(client, query, 2);
    // Same as above but with partitioned table
    query = "SELECT * FROM P1 LEFT JOIN R2 " + "ON P1.A " + joinOp + " R2.C WHERE R2.A IS NULL";
    validateRowCount(client, query, 2);
    // R1 1st - joined with R2 1st row
    // R1 2nd - joined with R2 null eliminated by the filter condition
    // R1 3rd - joined with R2 null eliminated by the filter condition
    // R1 4th - joined with R2 null eliminated by the filter condition
    query = "SELECT * FROM R1 LEFT JOIN R2 " + "ON R1.A " + joinOp + " R2.C WHERE R1.C = 1";
    validateRowCount(client, query, 1);
    // R1 1st - eliminated by the filter condition
    // R1 2nd - eliminated by the filter condition
    // R1 3rd - eliminated by the filter condition
    // R1 3rd - joined with the R2 null
    query = "SELECT * FROM R1 LEFT JOIN R2 " + "ON R1.A " + joinOp + " R2.C WHERE R1.A = -1";
    validateRowCount(client, query, 1);
    //* enable to debug */ System.out.println(result);
    // Same as above but with partitioned table
    query = "SELECT * FROM P1 LEFT JOIN R2 " + "ON P1.A " + joinOp + " R2.C WHERE P1.A = -1";
    validateRowCount(client, query, 1);
    //* enable to debug */ System.out.println(result);
    // R1 1st - joined with the R2
    // R1 1st - joined with the R2
    // R1 2nd - eliminated by the filter condition
    // R1 3rd - eliminated by the filter condition
    query = "SELECT * FROM R1 LEFT JOIN R2 " + "ON R1.A " + joinOp + " R2.C WHERE R1.A = 1";
    validateRowCount(client, query, 2);
    // R1 1st - eliminated by the filter condition
    // R1 2nd - eliminated by the filter condition
    // R1 3rd - joined with R2 null and pass the filter
    // R1 4th - joined with R2 null and pass the filter
    query = "SELECT * FROM R1 LEFT JOIN R2 " + "ON R1.A " + joinOp + " R2.C WHERE R2.A is NULL";
    validateRowCount(client, query, 2);
}
Also used : VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow)

Example 45 with VoltTableRow

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

the class TRURTruncateTable method run.

public VoltTable[] run(long p, byte shouldRollback) {
    voltQueueSQL(truncate);
    voltQueueSQL(count);
    voltQueueSQL(scancount);
    VoltTable[] results = voltExecuteSQL(true);
    VoltTable data = results[1];
    VoltTableRow row = data.fetchRow(0);
    long optCount = row.getLong(0);
    if (optCount != 0) {
        throw new VoltAbortException("after truncate (opt) count not zero");
    }
    data = results[2];
    row = data.fetchRow(0);
    long scanCount = row.getLong(0);
    if (scanCount != 0) {
        throw new VoltAbortException("after truncate (scan) count not zero");
    }
    if (shouldRollback != 0) {
        throw new VoltAbortException("EXPECTED ROLLBACK");
    }
    return results;
}
Also used : VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow) VoltAbortException(org.voltdb.VoltProcedure.VoltAbortException)

Aggregations

VoltTableRow (org.voltdb.VoltTableRow)65 VoltTable (org.voltdb.VoltTable)57 Client (org.voltdb.client.Client)23 ProcCallException (org.voltdb.client.ProcCallException)11 TimestampType (org.voltdb.types.TimestampType)7 NoConnectionsException (org.voltdb.client.NoConnectionsException)6 IOException (java.io.IOException)5 VoltAbortException (org.voltdb.VoltProcedure.VoltAbortException)5 Date (java.util.Date)4 WorkWithBigString (org.voltdb_testprocs.regressionsuites.sqlfeatureprocs.WorkWithBigString)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 ClientResponse (org.voltdb.client.ClientResponse)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 ByteBuilder (org.voltdb.benchmark.tpcc.procedures.ByteBuilder)1