Search in sources :

Example 1 with QueryEvent

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);
}
Also used : QueryId(org.apache.drill.exec.proto.UserBitShared.QueryId) QueryState(org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState) QueryEvent(org.apache.drill.test.BufferingQueryEventListener.QueryEvent)

Aggregations

QueryId (org.apache.drill.exec.proto.UserBitShared.QueryId)1 QueryState (org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState)1 QueryEvent (org.apache.drill.test.BufferingQueryEventListener.QueryEvent)1