use of org.bboxdb.storage.sstable.duplicateresolver.TTLTupleDuplicateResolver in project bboxdb by jnidzwetzki.
the class TestTupleHelper method testTupleDuplicateResolverTTL.
/**
* Test the tuple resolver
*/
@Test(timeout = 60000)
public void testTupleDuplicateResolverTTL() {
final Tuple tupleA = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 1);
final Tuple tupleB = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 2);
final Tuple tupleC = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 1);
final Tuple tupleD = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 4);
final Tuple tupleE = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 3);
final Tuple tupleF = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 1);
final List<Tuple> tupleList = new ArrayList<>(Arrays.asList(tupleA, tupleB, tupleC, tupleD, tupleE, tupleF));
// basetime = 6, ttl = 3 / tuple older than 3 are removed
final DuplicateResolver<Tuple> resolver = new TTLTupleDuplicateResolver(3, TimeUnit.MICROSECONDS, 6);
resolver.removeDuplicates(tupleList);
Assert.assertEquals(2, tupleList.size());
Assert.assertTrue(tupleList.contains(tupleD));
Assert.assertTrue(tupleList.contains(tupleE));
}
Aggregations