Skip to content

Instantly share code, notes, and snippets.

@ifesdjeen
Created June 13, 2018 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifesdjeen/4caf84423fa321ceca79d9b8c041fe0c to your computer and use it in GitHub Desktop.
Save ifesdjeen/4caf84423fa321ceca79d9b8c041fe0c to your computer and use it in GitHub Desktop.
public class CompactionIteratorTest
{
@Test
public void transformTest()
{
UnfilteredRowsGenerator generator = new UnfilteredRowsGenerator(metadata.comparator, false);
List<List<Unfiltered>> inputLists = parse(new String[] {"10[100] 11[100] 12[100]"}, generator);
List<List<Unfiltered>> tombstoneLists = parse(new String[] {}, generator);
List<Iterable<UnfilteredRowIterator>> content = ImmutableList.copyOf(Iterables.transform(inputLists, list -> ImmutableList.of(listToIterator(list, kk))));
Map<DecoratedKey, Iterable<UnfilteredRowIterator>> transformedSources = new TreeMap<>();
transformedSources.put(kk, Iterables.transform(tombstoneLists, list -> listToIterator(list, kk)));
try (CompactionController controller = new Controller(Keyspace.openAndGetStore(metadata), transformedSources, GC_BEFORE);
CompactionIterator iter = new CompactionIterator(OperationType.COMPACTION,
Lists.transform(content, x -> new Scanner(x)),
controller, NOW, null))
{
assertTrue(iter.hasNext());
UnfilteredRowIterator rows = iter.next();
assertTrue(rows.hasNext());
assertNotNull(rows.next());
iter.stop();
try
{
// Will call Transformation#applyToRow
rows.hasNext();
fail("Should have thrown CompactionInterruptedException");
}
catch (CompactionInterruptedException e)
{
// ignore
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment