@Override public Sequence<Row> process( final GroupByQuery query, final StorageAdapter storageAdapter ) { return engine.process(query, storageAdapter); } }
private static GroupByQueryRunnerFactory getGroupByQueryRunnerFactory() { ObjectMapper mapper = new DefaultObjectMapper(); GroupByQueryConfig config = new GroupByQueryConfig(); config.setMaxIntermediateRows(10000); Supplier<GroupByQueryConfig> configSupplier = Suppliers.ofInstance(config); GroupByQueryEngine engine = new GroupByQueryEngine(configSupplier, Utils.getBufferPool()); GroupByQueryRunnerFactory factory = new GroupByQueryRunnerFactory(engine, Utils.NOOP_QUERYWATCHER, configSupplier, new GroupByQueryQueryToolChest(configSupplier, mapper, engine, Utils.getBufferPool(), Utils.NoopIntervalChunkingQueryRunnerDecorator()), Utils.getBufferPool()); return factory; }
@Override public Sequence<Row> run(Query<Row> input) { if (!(input instanceof GroupByQuery)) { throw new ISE("Got a [%s] which isn't a %s", input.getClass(), GroupByQuery.class); } return engine.process((GroupByQuery) input, adapter); } }
private Sequence<Row> mergeGroupByResults(final GroupByQuery query, QueryRunner<Row> runner) { Sequence<Row> result; // If there's a subquery, merge subquery results and then apply the aggregator DataSource dataSource = query.getDataSource(); if (dataSource instanceof QueryDataSource) { GroupByQuery subquery; try { subquery = (GroupByQuery) ((QueryDataSource) dataSource).getQuery(); } catch (ClassCastException e) { throw new UnsupportedOperationException("Subqueries must be of type 'group by'"); } Sequence<Row> subqueryResult = mergeGroupByResults(subquery, runner); IncrementalIndexStorageAdapter adapter = new IncrementalIndexStorageAdapter(makeIncrementalIndex(subquery, subqueryResult)); result = engine.process(query, adapter); } else { result = runner.run(query); } return postAggregate(query, makeIncrementalIndex(query, result)); }