@Test
public void testMMRquery1 () throws IOException, ProcCallException {
//int num_partitions = this.getServerConfig().getPartitionCount();
Client client = this.getClient();
final VoltTable vt = this.loadTable_ORDER_LINE(client);
assertEquals(vt.getColumnCount(), 10);
// Computer Query1 information
/* MapReduce OLAP Experimental Queries
addStmtProcedure("OLAPQuery1",
"SELECT ol_number, SUM(ol_quantity), SUM(ol_amount), " +
" AVG(ol_quantity), AVG(ol_amount), COUNT(*)" +
" FROM ORDER_LINE " +
" GROUP BY ol_number order by ol_number");*/
// 0:ol_number,1:sum(ol_quantity),2:SUM(ol_amount),3:weight(ol_quantity),4:weight(ol_amount),5:sum
List< List<Object>> rtLists = new ArrayList< List< Object >>();
vt.resetRowPosition();
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
//Set <Integer> keyset = new HashSet <Integer>();
Integer ct = 0;
while(vt.advanceRow()) {
Integer key = new Integer ((int) vt.getLong(3));
if (!map.containsKey(key)) {
map.put(new Integer ((int) vt.getLong(3)),ct);
List <Object> cont = new ArrayList<Object>();
rtLists.add(ct,cont);
cont.add(0,key);
//rtLists.get(ct).add(0, vt.getLong(3));
if (cont.size() < 2) cont.add(1, vt.getLong(7));
else cont.set(1, vt.getLong(7) + ((Long)cont.get(1)).longValue());
if (cont.size() < 3) cont.add(2, vt.getDouble(8));
else cont.set(2, vt.getDouble(8) + ((Double)cont.get(2)).doubleValue());
if (cont.size() < 4) cont.add(3, 1);
else cont.set(3, ((Integer)cont.get(3)).intValue() + 1);
ct++;
} else {
int index = map.get(key);
assertEquals(key, rtLists.get(index).get(0));
//rtLists.get(ct).set(0, vt.getLong(3));
rtLists.get(index).set(1, vt.getLong(7) + ((Long)rtLists.get(index).get(1)).longValue());
rtLists.get(index).set(2, vt.getDouble(8) + ((Double)rtLists.get(index).get(2)).doubleValue());
rtLists.get(index).set(3, ((Integer)rtLists.get(index).get(3) ).intValue()+ 1);
}
}
// execute MapReduce Transaction to check the result