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);
}
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));
}
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]));
}
}
}
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);
}
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]));
}
}
}
}
Aggregations