Search in sources :

Example 21 with VoltTableRow

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

the class paymentByCustomerId 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 22 with VoltTableRow

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

the class TestSQLFeaturesSuite method testStringAsByteArrayParam.

public void testStringAsByteArrayParam() throws Exception {
    final int STRLEN = 5000;
    Client client = getClient();
    String longStringPart = "volt!";
    StringBuilder sb = new StringBuilder();
    while (sb.length() < STRLEN) sb.append(longStringPart);
    String longString = sb.toString();
    assertEquals(STRLEN, longString.length());
    VoltTable[] results = client.callProcedure("PassByteArrayArg", (byte) 1, 2, longString.getBytes("UTF-8")).getResults();
    assertEquals(1, results.length);
    VoltTableRow row = results[0].fetchRow(0);
    assertEquals(1, row.getLong(0));
    assertEquals(0, row.getString(2).compareTo(longString));
}
Also used : WorkWithBigString(org.voltdb_testprocs.regressionsuites.sqlfeatureprocs.WorkWithBigString) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow)

Example 23 with VoltTableRow

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

the class TestSQLTypesSuite method testMissingAttributeInsert_With_Defaults.

public void testMissingAttributeInsert_With_Defaults() throws NoConnectionsException, ProcCallException, IOException {
    Client client = this.getClient();
    Object[] params = new Object[COLS + 2];
    params[0] = "WITH_DEFAULTS";
    params[1] = pkey.incrementAndGet();
    for (int i = 0; i < COLS; i++) {
        params[i + 2] = m_defaultValues[i];
        assert (params[i + 2] != null);
    }
    try {
        client.callProcedure("Insert", params);
    } catch (ProcCallException e) {
        e.printStackTrace();
        fail();
    } catch (NoConnectionsException e) {
        e.printStackTrace();
        fail();
    }
    VoltTable[] result = client.callProcedure("Select", "WITH_DEFAULTS", pkey.get()).getResults();
    VoltTableRow row = result[0].fetchRow(0);
    for (int i = 0; i < COLS; ++i) {
        Object obj = row.get(i + 1, m_types[i]);
        if (m_types[i] == VoltType.GEOGRAPHY || m_types[i] == VoltType.GEOGRAPHY_POINT) {
            // Default values are not supported for these types (yet?)
            assertNull(obj);
        } else {
            assertTrue("Expected to be equal: (" + obj + ", " + params[i + 2] + ")", comparisonHelper(obj, params[i + 2], m_types[i]));
        }
    }
}
Also used : NoConnectionsException(org.voltdb.client.NoConnectionsException) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow) ProcCallException(org.voltdb.client.ProcCallException)

Example 24 with VoltTableRow

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

the class TestSQLFeaturesSuite method testSelfJoins.

public void testSelfJoins() throws Exception {
    Client client = getClient();
    client.callProcedure("NEW_ORDER.insert", (byte) 1, 3L, 1L);
    VoltTable[] results = client.callProcedure("SelfJoinTest", (byte) 1).getResults();
    assertEquals(results.length, 1);
    // get the new order table
    VoltTable table = results[0];
    assertTrue(table.getRowCount() == 1);
    VoltTableRow row = table.fetchRow(0);
    assertEquals(row.getLong("NO_D_ID"), 3);
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow)

Example 25 with VoltTableRow

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

the class TestSQLTypesSuite method testUpdateToNull.

public void testUpdateToNull() throws IOException, ProcCallException {
    final Client client = this.getClient();
    final Object[] params = new Object[COLS + 2];
    for (int k = 0; k < COLS; ++k) {
        // build the parameter list as described above
        // Fill the row with non-null data and insert
        params[0] = "";
        params[1] = pkey.incrementAndGet();
        for (int i = 0; i < COLS; i++) {
            params[i + 2] = m_midValues[i];
            assert (params[i + 2] != null);
        }
        params[0] = "ALLOW_NULLS";
        client.callProcedure("Insert", params);
        for (int i = 0; i < COLS; i++) {
            params[i + 2] = (i == k) ? m_nullValues[i] : m_midValues[i];
            assert (params[i + 2] != null);
        }
        try {
            client.callProcedure("Update", params);
        } catch (final ProcCallException e) {
            e.printStackTrace();
            fail(e.getMessage());
        } catch (final NoConnectionsException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
        // verify that the row was updated
        final VoltTable[] result = client.callProcedure("Select", "ALLOW_NULLS", pkey.get()).getResults();
        final VoltTableRow row = result[0].fetchRow(0);
        for (int i = 0; i < COLS; ++i) {
            final Object obj = row.get(i + 1, m_types[i]);
            if (i == k) {
                assertTrue(row.wasNull());
            } else {
                assertTrue(comparisonHelper(obj, params[i + 2], m_types[i]));
            }
        }
    }
}
Also used : NoConnectionsException(org.voltdb.client.NoConnectionsException) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow) ProcCallException(org.voltdb.client.ProcCallException)

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