use of org.apache.drill.test.BufferingQueryEventListener.QueryEvent in project drill by apache.
the class QueryBuilder method produceSummary.
private QuerySummary produceSummary(BufferingQueryEventListener listener) throws Exception {
long start = System.currentTimeMillis();
int recordCount = 0;
int batchCount = 0;
QueryId queryId = null;
QueryState state = null;
loop: for (; ; ) {
QueryEvent event = listener.get();
switch(event.type) {
case BATCH:
batchCount++;
recordCount += event.batch.getHeader().getRowCount();
event.batch.release();
break;
case EOF:
state = event.state;
break loop;
case ERROR:
throw event.error;
case QUERY_ID:
queryId = event.queryId;
break;
default:
throw new IllegalStateException("Unexpected event: " + event.type);
}
}
long end = System.currentTimeMillis();
long elapsed = end - start;
return new QuerySummary(queryId, recordCount, batchCount, elapsed, state);
}
Aggregations