Пример #1
0
  /**
   * *Awesome* method name auto-generated by IntelliJ! I love IntelliJ!
   *
   * @param index
   * @return
   */
  private List<SegmentAnalysis> getSegmentAnalysises(Segment index) {
    final QueryRunner runner =
        QueryRunnerTestHelper.makeQueryRunner(
            (QueryRunnerFactory)
                new SegmentMetadataQueryRunnerFactory(
                    new SegmentMetadataQueryQueryToolChest(),
                    QueryRunnerTestHelper.NOOP_QUERYWATCHER),
            index);

    final SegmentMetadataQuery query =
        new SegmentMetadataQuery(
            new LegacyDataSource("test"), QuerySegmentSpecs.create("2011/2012"), null, null, null);
    HashMap<String, Object> context = new HashMap<String, Object>();
    return Sequences.toList(query.run(runner, context), Lists.<SegmentAnalysis>newArrayList());
  }
  @Override
  public <T extends LogicalSegment> List<T> filterSegments(
      SegmentMetadataQuery query, List<T> segments) {
    if (!query.isUsingDefaultInterval()) {
      return segments;
    }

    if (segments.size() <= 1) {
      return segments;
    }

    final T max = segments.get(segments.size() - 1);

    DateTime targetEnd = max.getInterval().getEnd();
    final Interval targetInterval = new Interval(config.getDefaultHistory(), targetEnd);

    return Lists.newArrayList(
        Iterables.filter(
            segments,
            new Predicate<T>() {
              @Override
              public boolean apply(T input) {
                return (input.getInterval().overlaps(targetInterval));
              }
            }));
  }