endTime.add(Calendar.HOUR_OF_DAY, 3);
// recalculate the calendars
startTime.getTimeInMillis();
endTime.getTimeInMillis();
PreparedAggregateQuery query = queryClient.createPreparedQuery();
/*
* test reuse of the prepared query. Should speedup stuff exactly as
* prepared query is supposed to do. we also have an option of
* re-preparing query at any time, but we still need to run reset()
* to clean out stuff like parameters initialized and execution.
* reset() does not necessarily cancel previously existing AST tree
* of the query, only prepare() updates that. but prepare does
* reset() implicitly, so if we re-prepared the query, the previous
* parameter set cannot be used.
*/
long ms = System.currentTimeMillis();
query.prepare("select dim1, SUM(impCnt) as ?, COUNT(impCnt) as ?, SUM(click) as clickSum, "
+ "COUNT(click) as clickCnt, cannyAvg7d(clickTimeSeries) as ctr " +
"from Example1 where dim1 in [?] " + ", impressionTime in [?,?) " + ", dim2 in [ '1' ]"
+ "group by dim1");
System.out.printf("query prepared in %d ms\n", System.currentTimeMillis() - ms);
for (int i = 0; i < 5; i++) {
/**
* same as client2 but print the summaries separately (no
* grouping).
*
*/
ms = System.currentTimeMillis();
// demo: can parameterize aliases
// or measure names in the select expression.
query.setHblParameter(0, "impSum");
query.setHblParameter(1, "impCnt");
query.setHblParameter(2, ids[1]);
// query.setHblParameter(3, ids[1]);
query.setHblParameter(3, startTime);
query.setHblParameter(4, endTime);
// query.addMeasure("impCnt").addMeasure("click");
// query.addClosedSlice("dim1",ids[0],ids[1]).addGroupBy("dim1");
// query.addHalfOpenSlice("impressionTime", startTime, endTime);
AggregateResultSet rs = query.execute();
closeables.addFirst(rs);
while (rs.hasNext()) {
rs.next();
PreparedAggregateResult ar = (PreparedAggregateResult) rs.current();