Esempio n. 1
0
 @Override
 public <T> QueryRunner<T> getQueryRunnerForSegments(
     final Query<T> query, Iterable<SegmentDescriptor> specs) {
   final QueryRunnerFactory<T, Query<T>> factory = conglomerate.findFactory(query);
   final List<String> names = query.getDataSource().getNames();
   return new UnionQueryRunner<>(
       Iterables.transform(
           names,
           new Function<String, QueryRunner>() {
             @Override
             public QueryRunner<T> apply(String input) {
               Iterable<FireChief> chiefsOfDataSource = chiefs.get(input);
               return chiefsOfDataSource == null
                   ? new NoopQueryRunner()
                   : factory
                       .getToolchest()
                       .mergeResults(
                           factory.mergeRunners(
                               MoreExecutors
                                   .sameThreadExecutor(), // Chaining query runners which wait on
                               // submitted chain query runners can make
                               // executor pools deadlock
                               Iterables.transform(
                                   chiefsOfDataSource,
                                   new Function<FireChief, QueryRunner<T>>() {
                                     @Override
                                     public QueryRunner<T> apply(FireChief input) {
                                       return input.getQueryRunner(query);
                                     }
                                   })));
             }
           }),
       conglomerate.findFactory(query).getToolchest());
 }
Esempio n. 2
0
  @Override
  public <T> QueryRunner<T> getQueryRunner(Query<T> query) {
    if (plumber != null) {
      QueryRunnerFactory<T, Query<T>> factory = queryRunnerFactoryConglomerate.findFactory(query);
      QueryToolChest<T, Query<T>> toolChest = factory.getToolchest();

      return new FinalizeResultsQueryRunner<T>(plumber.getQueryRunner(query), toolChest);
    } else {
      return null;
    }
  }
Esempio n. 3
0
 @SuppressWarnings("unchecked")
 public static QueryRunnerFactory findFactory(Query query) {
   return conglomerate.findFactory(query);
 }