use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestRollbackSuite method testSinglePartitionJavaFailure.
public void testSinglePartitionJavaFailure() throws IOException {
Client client = getClient();
try {
client.callProcedure("SinglePartitionJavaError", 2);
fail();
} catch (ProcCallException e) {
} catch (IOException e) {
e.printStackTrace();
fail();
}
try {
VoltTable[] results = client.callProcedure("SelectAll").getResults();
assertEquals(results.length, 9);
// get the new order table
VoltTable table = results[7];
assertTrue(table.getRowCount() == 0);
// check the mat view
results = client.callProcedure("ReadMatView", (byte) 2).getResults();
assertEquals(results.length, 1);
assertTrue(results[0].getRowCount() == 0);
} catch (ProcCallException e) {
e.printStackTrace();
fail();
} catch (IOException e) {
e.printStackTrace();
fail();
}
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestRollbackSuite method testTooLargeStringInsertAndUpdate.
public void testTooLargeStringInsertAndUpdate() throws IOException {
final java.util.Random r = new java.util.Random();
StringBuilder sb = new StringBuilder(300);
for (int ii = 0; ii < 300; ii++) {
sb.append(r.nextInt(9));
}
final String insertQuery = "INSERT INTO CUSTOMER_NAME VALUES ( 0, 0, 0, 'foo','" + sb.toString() + "')";
final String updateQuery = "UPDATE CUSTOMER_NAME SET C_ID = 0, C_D_ID = 0, C_W_ID = 0, C_FIRST = 'foo', C_LAST ='" + sb.toString() + "'";
final Client client = getClient();
boolean threwException = false;
try {
client.callProcedure("@AdHoc", insertQuery);
} catch (ProcCallException e) {
threwException = true;
}
assertTrue(threwException);
VoltTable[] results = null;
try {
results = client.callProcedure("@AdHoc", "SELECT * FROM CUSTOMER_NAME").getResults();
} catch (ProcCallException e) {
fail();
}
assertNotNull(results);
assertEquals(1, results.length);
assertEquals(0, results[0].getRowCount());
try {
client.callProcedure("@AdHoc", "INSERT INTO CUSTOMER_NAME VALUES ( 0, 0, 0, 'foo', 'bar')");
} catch (ProcCallException e) {
fail();
}
threwException = false;
try {
client.callProcedure("@AdHoc", updateQuery);
} catch (ProcCallException e) {
e.printStackTrace();
threwException = true;
}
assertTrue(threwException);
results = null;
try {
results = client.callProcedure("@AdHoc", "SELECT * FROM CUSTOMER_NAME").getResults();
} catch (ProcCallException e) {
fail();
}
assertNotNull(results);
assertEquals(1, results.length);
assertEquals(1, results[0].getRowCount());
VoltTable result = results[0];
result.advanceRow();
assertEquals(0, result.getLong(0));
assertEquals(0, result.getLong(1));
assertEquals(0, result.getLong(2));
assertTrue("foo".equals(result.getString(3)));
assertTrue("bar".equals(result.getString(4)));
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestRollbackSuite method testMultiPartitionConstraintFailure.
public void testMultiPartitionConstraintFailure() throws IOException {
Client client = getClient();
try {
System.out.println("Calling MultiPartitionConstraintError");
System.out.flush();
client.callProcedure("MultiPartitionConstraintError", 2);
System.out.println("Called MultiPartitionConstraintError");
System.out.flush();
fail();
} catch (ProcCallException e) {
} catch (IOException e) {
e.printStackTrace();
fail();
}
try {
System.out.println("Calling SelectAll");
System.out.flush();
VoltTable[] results = client.callProcedure("SelectAll").getResults();
System.out.println("Called SelectAll");
System.out.flush();
assertEquals(results.length, 9);
// get the new order table
VoltTable table = results[2];
System.out.println(table.toString());
assertTrue(table.getRowCount() == 0);
} catch (ProcCallException e) {
e.printStackTrace();
fail();
} catch (IOException e) {
e.printStackTrace();
fail();
}
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestMaterializedViewSuite method subtestNullMinMaxSinglePartition.
private void subtestNullMinMaxSinglePartition() throws IOException, ProcCallException {
Client client = getClient();
truncateBeforeTest(client);
VoltTable[] results = null;
VoltTable t;
results = client.callProcedure("@AdHoc", "SELECT * FROM MATPEOPLE2").getResults();
assert (results != null);
assertEquals(1, results.length);
assertEquals(0, results[0].getRowCount());
results = client.callProcedure("AddPerson", 1, 1L, 31L, 1000.0, 3, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 1, 2L, 31L, 900.0, 5, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 1, 3L, 31L, 900.0, 1, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 1, 4L, 31L, 2500.0, 5, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 1, 5L, 31L, null, null, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("@AdHoc", "SELECT * FROM MATPEOPLE2").getResults();
assert (results != null);
assertEquals(1, results.length);
t = results[0];
assertEquals(1, t.getRowCount());
System.out.println(t.toString());
t.advanceRow();
assertEquals(5, t.getLong(2));
assertEquals(900, (int) (t.getDouble(3)));
assertEquals(5, t.getLong(4));
results = client.callProcedure("DeletePerson", 1, 2L, NORMALLY).getResults();
results = client.callProcedure("@AdHoc", "SELECT * FROM MATPEOPLE2").getResults();
assert (results != null);
assertEquals(1, results.length);
t = results[0];
assertEquals(1, t.getRowCount());
System.out.println(t.toString());
t.advanceRow();
assertEquals(4, t.getLong(2));
assertEquals(900, (int) (t.getDouble(3)));
assertEquals(5, t.getLong(4));
results = client.callProcedure("UpdatePerson", 1, 3L, 31L, 200, 9).getResults();
results = client.callProcedure("@AdHoc", "SELECT * FROM MATPEOPLE2").getResults();
assert (results != null);
assertEquals(1, results.length);
t = results[0];
assertEquals(1, t.getRowCount());
System.out.println(t.toString());
t.advanceRow();
assertEquals(4, t.getLong(2));
assertEquals(200, (int) (t.getDouble(3)));
assertEquals(9, t.getLong(4));
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestMaterializedViewSuite method subtestIndexed.
private void subtestIndexed() throws IOException, ProcCallException {
Client client = getClient();
truncateBeforeTest(client);
VoltTable[] results = null;
results = client.callProcedure("AggAges", 1).getResults();
assertEquals(1, results.length);
assertEquals(0, results[0].getRowCount());
assert (results != null);
results = client.callProcedure("AddPerson", 1, 1L, 31L, 1000.0, 3, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 1, 2L, 31L, 1000.0, 3, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 1, 3L, 33L, 28920.99, 3, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 2, 4L, 23L, 1000.0, 3, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 2, 5L, 35L, 1000.0, 3, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 2, 6L, 35L, 1000.0, 3, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 2, 7L, 23L, 1000.0, 3, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("AddPerson", 2, 8L, 31L, 2222.22, 3, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("UpdatePerson", 1, 2L, 32L, 1000.0, 3).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
results = client.callProcedure("DeletePerson", 2, 6L, NORMALLY).getResults();
assertEquals(1, results.length);
assertEquals(1L, results[0].asScalarLong());
int totalRows;
// INDEXED_FIRST_GROUP AS SELECT AGE, SALARIES LIMIT 1;
results = client.callProcedure("INDEXED_FIRST_GROUP").getResults();
assert (results != null);
assertEquals(1, results.length);
totalRows = results[0].getRowCount();
assertEquals(1, totalRows);
results[0].advanceRow();
assertEquals(33L, results[0].getLong(0));
assertEquals(28920.99, results[0].getDouble(1), 0.001);
// INDEXED_MAX_GROUP AS SELECT MAX(SALARIES);
results = client.callProcedure("INDEXED_MAX_GROUP").getResults();
assert (results != null);
assertEquals(1, results.length);
totalRows = results[0].getRowCount();
assertEquals(1, totalRows);
results[0].advanceRow();
assertEquals(28920.99, results[0].getDouble(0), 0.001);
// INDEXED_MAX_IN_GROUPS AS SELECT MAX(SALARIES) WHERE AGE = ?;
results = client.callProcedure("INDEXED_MAX_IN_GROUPS", 31L).getResults();
assert (results != null);
assertEquals(1, results.length);
totalRows = results[0].getRowCount();
assertEquals(1, totalRows);
results[0].advanceRow();
assertEquals(2222.22, results[0].getDouble(0), 0.001);
// INDEXED_GROUPS: AGE, SALARIES, PARTITION, NUM, KIDS ORDER BY AGE, SALARIES */
results = client.callProcedure("INDEXED_GROUPS").getResults();
assert (results != null);
totalRows = results[0].getRowCount();
assertEquals(6, totalRows);
results[0].advanceRow();
assertEquals(23L, results[0].getLong(0));
assertEquals(2000.0, results[0].getDouble(1), 0.001);
results[0].advanceRow();
assertEquals(31L, results[0].getLong(0));
assertEquals(1000.0, results[0].getDouble(1), 0.001);
results[0].advanceRow();
assertEquals(31L, results[0].getLong(0));
assertEquals(2222.22, results[0].getDouble(1), 0.001);
results[0].advanceRow();
assertEquals(32L, results[0].getLong(0));
assertEquals(1000.00, results[0].getDouble(1), 0.001);
long timestampInitializer;
int ii;
// keeps the clock moving forward.
int delay = 0;
// +1 V_TEAM_MEMBERSHIP, +1 V_TEAM_TIMES
timestampInitializer = (System.currentTimeMillis() + (++delay)) * 1000;
insertRow(client, "CONTEST", "Senior", timestampInitializer, "Boston", "Jack");
// +1 V_TEAM_MEMBERSHIP, +4 V_TEAM_TIMES
for (ii = 0; ii < 4; ++ii) {
timestampInitializer = (System.currentTimeMillis() + (++delay)) * 1000;
insertRow(client, "CONTEST", "Senior", timestampInitializer, "Cambridge", "anonymous " + ii);
}
// +0 V_TEAM_MEMBERSHIP, +1 V_TEAM_TIMES
timestampInitializer = (System.currentTimeMillis() + (++delay)) * 1000;
for (ii = 0; ii < 3; ++ii) {
insertRow(client, "CONTEST", "Senior", timestampInitializer, "Boston", "not Jack " + ii);
}
// +1 V_TEAM_MEMBERSHIP, +1 V_TEAM_TIMES
timestampInitializer = (System.currentTimeMillis() + (++delay)) * 1000;
for (ii = 0; ii < 3; ++ii) {
insertRow(client, "CONTEST", "Senior", timestampInitializer, "Concord", "Emerson " + ii);
}
// +1 V_TEAM_MEMBERSHIP, +2 V_TEAM_TIMES
for (ii = 0; ii < 2; ++ii) {
timestampInitializer = (System.currentTimeMillis() + (++delay)) * 1000;
insertRow(client, "CONTEST", "Senior", timestampInitializer, "Lexington", "Luis " + ii);
}
if (!isHSQL()) {
results = client.callProcedure("@AdHoc", "SELECT team, total, finish FROM V_TEAM_TIMES " + "ORDER BY total DESC, 0-SINCE_EPOCH(MILLISECOND, finish) DESC").getResults();
assertEquals(1, results.length);
System.out.println(results[0]);
assertEquals(9, results[0].getRowCount());
results[0].advanceRow();
assertEquals("Boston", results[0].getString(0));
assertEquals(3, results[0].getLong(1));
results[0].advanceRow();
assertEquals("Concord", results[0].getString(0));
assertEquals(3, results[0].getLong(1));
results[0].advanceToRow(8);
assertEquals("Lexington", results[0].getString(0));
assertEquals(1, results[0].getLong(1));
}
/**
* Current data in MV table: V_TEAM_MEMBERSHIP.
* header size: 39
* status code: -128 column count: 3
* cols (RUNNER_CLASS:STRING), (TEAM:STRING), (TOTAL:INTEGER),
* rows -
* Senior,Boston,4
* Senior,Cambridge,4
* Senior,Concord,3
* Senior,Lexington,2
*/
results = client.callProcedure("@AdHoc", "SELECT count(*) FROM V_TEAM_MEMBERSHIP where team > 'Cambridge' order by total").getResults();
assertEquals(1, results.length);
System.out.println(results[0]);
assertEquals(2L, results[0].asScalarLong());
results = client.callProcedure("@AdHoc", "SELECT count(*) FROM V_TEAM_MEMBERSHIP where total > 3 ").getResults();
assertEquals(1, results.length);
System.out.println(results[0]);
assertEquals(2L, results[0].asScalarLong());
results = client.callProcedure("@AdHoc", "SELECT team, finish FROM V_TEAM_TIMES ORDER BY finish DESC limit 3").getResults();
assertEquals(1, results.length);
System.out.println(results[0]);
assertEquals(3, results[0].getRowCount());
results[0].advanceRow();
assertEquals("Lexington", results[0].getString(0));
results[0].advanceRow();
assertEquals("Lexington", results[0].getString(0));
results[0].advanceRow();
assertEquals("Concord", results[0].getString(0));
}
Aggregations