final double EPSILON = 0.00001;
final BigDecimal moneyOne = new BigDecimal(BigInteger.valueOf(7700000000000L), 12);
final BigDecimal moneyTwo = new BigDecimal(BigInteger.valueOf(1100000000000L), 12);
try {
client.callProcedure("InsertAllTypes", 1, 2, 3, 4, new TimestampType(5),
0.6, moneyOne, "inlined", "uninlined");
client.callProcedure("InsertAllTypes", 7, 6, 5, 4, new TimestampType(3),
0.2, moneyTwo, "INLINED", "UNINLINED");
} catch (ProcCallException e1) {
System.err.printf(">>> %s UNEXPECTED[0] %s\n", procName, e1);
e1.printStackTrace();
fail();
}
try {
if (procName.contains("MultiOps"))
client.callProcedure("AllTypesMultiOpsJavaError", order, id);
else if (procName.contains("Update"))
client.callProcedure(procName, 7);
else
client.callProcedure(procName);
System.err.printf(">>> %s DID NOT FAIL!\n", procName);
fail();
}
catch (ProcCallException e) {}
catch (IOException e) {
System.err.printf(">>> %s UNEXPECTED[1] %s\n", procName, e);
e.printStackTrace();
fail();
}
try {
VoltTable[] results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES ORDER BY ID ASC;").getResults();
// get the table
VoltTable table = results[0];
assertTrue(table.getRowCount() == 2);
table.advanceRow();
assertEquals(1, table.getLong(0));
assertEquals(2, table.getLong(1));
assertEquals(3, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(5), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.6 - table.getDouble(5)) < EPSILON);
assertEquals(moneyOne, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("inlined"));
assertTrue(table.getString(8).equals("uninlined"));
table.advanceRow();
assertEquals(7, table.getLong(0));
assertEquals(6, table.getLong(1));
assertEquals(5, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("INLINED"));
assertTrue(table.getString(8).equals("UNINLINED"));
// Check by using the indexes
results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES WHERE ID > 3;").getResults();
// get the table
table = results[0];
assertTrue(table.getRowCount() == 1);
table.advanceRow();
assertEquals(7, table.getLong(0));
assertEquals(6, table.getLong(1));
assertEquals(5, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("INLINED"));
assertTrue(table.getString(8).equals("UNINLINED"));
// unique hash index
results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES WHERE ID = 1;").getResults();
// get the table
table = results[0];
assertTrue(table.getRowCount() == 1);
table.advanceRow();
assertEquals(1, table.getLong(0));
assertEquals(2, table.getLong(1));
assertEquals(3, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(5), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.6 - table.getDouble(5)) < EPSILON);
assertEquals(moneyOne, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("inlined"));
assertTrue(table.getString(8).equals("uninlined"));
// multimap tree index
results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES ORDER BY TINY, SMALL, BIG, T, RATIO, MONEY, INLINED DESC;").getResults();
// get the table
table = results[0];
assertTrue(table.getRowCount() == 2);
table.advanceRow();
assertEquals(1, table.getLong(0));
assertEquals(2, table.getLong(1));
assertEquals(3, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(5), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.6 - table.getDouble(5)) < EPSILON);
assertEquals(moneyOne, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("inlined"));
assertTrue(table.getString(8).equals("uninlined"));
table.advanceRow();
assertEquals(7, table.getLong(0));
assertEquals(6, table.getLong(1));
assertEquals(5, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("INLINED"));
assertTrue(table.getString(8).equals("UNINLINED"));
// multimap hash index
results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES WHERE TINY = 6 AND SMALL = 5 AND BIG = 4;").getResults();
// get the table
table = results[0];
assertTrue(table.getRowCount() == 1);
table.advanceRow();
assertEquals(7, table.getLong(0));
assertEquals(6, table.getLong(1));
assertEquals(5, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("INLINED"));
assertTrue(table.getString(8).equals("UNINLINED"));