@Test
  public void whenCalculatingSetIntersection_thenCorrect() {
    final Set<Character> first = ImmutableSet.of('a', 'b', 'c');
    final Set<Character> second = ImmutableSet.of('b', 'c', 'd');

    final Set<Character> intersection = Sets.intersection(first, second);
    assertThat(intersection, containsInAnyOrder('b', 'c'));
  }
Exemplo n.º 2
0
  @Test
  public void shouldReturnTheSetIntersectionOfTheSuppliedIterables() throws Exception {
    // Given
    Iterable<String> firstIterable = setWith("a", "b", "c", "q");
    Iterable<String> secondIterable = listWith("c", "c", "d", "q", "e");
    Iterable<String> thirdIterable = multisetWith("a", "c", "f", "f", "q");
    Set<String> expectedIntersectionSet = setWith("c", "q");

    // When
    Set<String> actualIntersectionSet =
        Sets.intersection(firstIterable, secondIterable, thirdIterable);

    // Then
    assertThat(actualIntersectionSet, is(expectedIntersectionSet));
  }
  /**
   * @param gcBefore
   * @return
   */
  private List<SSTableReader> getNextBackgroundSSTables(final int gcBefore) {
    if (!isEnabled() || cfs.getSSTables().isEmpty()) return Collections.emptyList();

    Set<SSTableReader> uncompacting = Sets.intersection(sstables, cfs.getUncompactingSSTables());

    // Find fully expired SSTables. Those will be included no matter what.
    Set<SSTableReader> expired =
        CompactionController.getFullyExpiredSSTables(
            cfs, uncompacting, cfs.getOverlappingSSTables(uncompacting), gcBefore);
    Set<SSTableReader> candidates = Sets.newHashSet(filterSuspectSSTables(uncompacting));

    List<SSTableReader> compactionCandidates =
        new ArrayList<>(getNextNonExpiredSSTables(Sets.difference(candidates, expired), gcBefore));
    if (!expired.isEmpty()) {
      logger.debug("Including expired sstables: {}", expired);
      compactionCandidates.addAll(expired);
    }
    return compactionCandidates;
  }