public MetricSampleCompleteness<G, E> completeness(long from, long to, AggregationOptions<G, E> options) {
    _windowRollingLock.lock();
    try {
      long fromWindowIndex = Math.max(windowIndex(from), _oldestWindowIndex);
      long toWindowIndex = Math.min(windowIndex(to), _currentWindowIndex - 1);
      if (fromWindowIndex > _currentWindowIndex || toWindowIndex < _oldestWindowIndex) {
        return new MetricSampleCompleteness<>(generation(), _windowMs);
      }
      maybeUpdateAggregatorState();
      return _aggregatorState.completeness(fromWindowIndex,
                                           toWindowIndex,
                                           interpretAggregationOptions(options),
                                           generation());
    } finally {
      _windowRollingLock.unlock();
    }
  }
@Test
  public void testAggregationOption2() {
    MetricSampleAggregator<String, IntegerEntity> aggregator = prepareCompletenessTestEnv();
    // Change the group coverage requirement to 0, window 3, 4, 20 will be excluded because minValidEntityRatio is not met.
    AggregationOptions<String, IntegerEntity> options =
        new AggregationOptions<>(0.5, 0.0, NUM_WINDOWS, 5,
                                 new HashSet<>(Arrays.asList(ENTITY1, ENTITY2, ENTITY3)),
                                 AggregationOptions.Granularity.ENTITY, true);
    MetricSampleCompleteness<String, IntegerEntity> completeness = aggregator.completeness(-1, Long.MAX_VALUE, options);
    assertEquals(17, completeness.validWindowIndices().size());
    assertFalse(completeness.validWindowIndices().contains(3L));
    assertFalse(completeness.validWindowIndices().contains(4L));
    assertFalse(completeness.validWindowIndices().contains(20L));
    assertEquals(2, completeness.validEntities().size());
    assertTrue(completeness.validEntities().contains(ENTITY1));
    assertTrue(completeness.validEntities().contains(ENTITY3));
    assertEquals(1, completeness.validEntityGroups().size());
    assertTrue(completeness.validEntityGroups().contains(ENTITY3.group()));
    assertCompletenessByWindowIndex(completeness);
  }