コード例 #1
0
  @SuppressWarnings("unchecked")
  @Parameterized.Parameters(name = "{0}")
  public static Iterable<Object[]> constructorFeeder() throws IOException {
    GroupByQueryConfig config = new GroupByQueryConfig();
    config.setMaxIntermediateRows(10000);

    final GroupByQueryRunnerFactory factory = GroupByQueryRunnerTest.makeQueryRunnerFactory(config);
    return QueryRunnerTestHelper.transformToConstructionFeeder(
        Lists.transform(
            QueryRunnerTestHelper.makeQueryRunners(factory),
            new Function<QueryRunner<Row>, Object>() {
              @Nullable
              @Override
              public Object apply(final QueryRunner<Row> input) {
                return new QueryRunner() {
                  @Override
                  public Sequence run(Query query, Map responseContext) {
                    TimeseriesQuery tsQuery = (TimeseriesQuery) query;

                    return Sequences.map(
                        input.run(
                            GroupByQuery.builder()
                                .setDataSource(tsQuery.getDataSource())
                                .setQuerySegmentSpec(tsQuery.getQuerySegmentSpec())
                                .setGranularity(tsQuery.getGranularity())
                                .setDimFilter(tsQuery.getDimensionsFilter())
                                .setAggregatorSpecs(tsQuery.getAggregatorSpecs())
                                .setPostAggregatorSpecs(tsQuery.getPostAggregatorSpecs())
                                .build(),
                            responseContext),
                        new Function<Row, Result<TimeseriesResultValue>>() {
                          @Override
                          public Result<TimeseriesResultValue> apply(final Row input) {
                            MapBasedRow row = (MapBasedRow) input;

                            return new Result<TimeseriesResultValue>(
                                row.getTimestamp(), new TimeseriesResultValue(row.getEvent()));
                          }
                        });
                  }

                  @Override
                  public String toString() {
                    return input.toString();
                  }
                };
              }
            }));
  }
コード例 #2
0
  @SuppressWarnings("unchecked")
  @Parameterized.Parameters
  public static Iterable<Object[]> constructorFeeder() throws IOException {
    GroupByQueryConfig config = new GroupByQueryConfig();
    config.setMaxIntermediateRows(10000);

    final Supplier<GroupByQueryConfig> configSupplier = Suppliers.ofInstance(config);
    final GroupByQueryEngine engine =
        new GroupByQueryEngine(
            configSupplier,
            new StupidPool<ByteBuffer>(
                new Supplier<ByteBuffer>() {
                  @Override
                  public ByteBuffer get() {
                    return ByteBuffer.allocate(1024 * 1024);
                  }
                }));

    final GroupByQueryRunnerFactory factory =
        new GroupByQueryRunnerFactory(
            engine,
            QueryRunnerTestHelper.NOOP_QUERYWATCHER,
            configSupplier,
            new GroupByQueryQueryToolChest(
                configSupplier,
                new DefaultObjectMapper(),
                engine,
                TestQueryRunners.pool,
                QueryRunnerTestHelper.NoopIntervalChunkingQueryRunnerDecorator()),
            TestQueryRunners.pool);
    return QueryRunnerTestHelper.transformToConstructionFeeder(
        Lists.transform(
            QueryRunnerTestHelper.makeQueryRunners(factory),
            new Function<QueryRunner<Row>, Object>() {
              @Nullable
              @Override
              public Object apply(final QueryRunner<Row> input) {
                return new QueryRunner() {
                  @Override
                  public Sequence run(Query query, Map responseContext) {
                    TimeseriesQuery tsQuery = (TimeseriesQuery) query;

                    return Sequences.map(
                        input.run(
                            GroupByQuery.builder()
                                .setDataSource(tsQuery.getDataSource())
                                .setQuerySegmentSpec(tsQuery.getQuerySegmentSpec())
                                .setGranularity(tsQuery.getGranularity())
                                .setDimFilter(tsQuery.getDimensionsFilter())
                                .setAggregatorSpecs(tsQuery.getAggregatorSpecs())
                                .setPostAggregatorSpecs(tsQuery.getPostAggregatorSpecs())
                                .build(),
                            responseContext),
                        new Function<Row, Result<TimeseriesResultValue>>() {
                          @Override
                          public Result<TimeseriesResultValue> apply(final Row input) {
                            MapBasedRow row = (MapBasedRow) input;

                            return new Result<TimeseriesResultValue>(
                                row.getTimestamp(), new TimeseriesResultValue(row.getEvent()));
                          }
                        });
                  }
                };
              }
            }));
  }