private void testClient4(String cubeName) throws IOException, HblException {
Deque<Closeable> closeables = new ArrayDeque<Closeable>();
try {
AggregateQuery query = queryClient.createQuery();
query.setCube(cubeName);
for (int i = 0; i < 5; i++) {
byte ids[][] = new byte[2][];
ids[0] = new byte[16];
ids[1] = new byte[16];
HblUtil.incrementKey(ids[1], 0, 16);
/*
* will try to also constrain for half-open [1:00am,3:00am)
*/
GregorianCalendar startTime = IOUtil.tryClone(START_BASE);
GregorianCalendar endTime = IOUtil.tryClone(START_BASE);
/*
* this will be in local time, whereas example was generated in
* UTC. So for PST we get actually normally hours from 9,10 am.
* which would result in impression count of 17 for key 00000,
* and 21 ifor key 000001.
*/
startTime.add(Calendar.HOUR_OF_DAY, 1);
endTime.add(Calendar.HOUR_OF_DAY, 3);
// recalculate the calendars
startTime.getTimeInMillis();
endTime.getTimeInMillis();
/*
* same as client2 but print the summaries separately (no
* grouping).
*/
query.addMeasure("impCnt").addMeasure("click");
query.addClosedSlice("dim1", ids[0], ids[1]).addGroupBy("dim1");
query.addHalfOpenSlice("impressionTime", startTime, endTime);
long ms = System.currentTimeMillis();
AggregateResultSet rs = query.execute();
closeables.addFirst(rs);
while (rs.hasNext()) {
rs.next();
AggregateResult ar = rs.current();
System.out.printf("%032X sum/cnt: impCnt %.4f/%d, click %.4f/%d\n",