Search in sources :

Example 1 with TTLTupleDuplicateResolver

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));
}
Also used : TTLTupleDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.TTLTupleDuplicateResolver) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)1 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)1 Tuple (org.bboxdb.storage.entity.Tuple)1 TTLTupleDuplicateResolver (org.bboxdb.storage.sstable.duplicateresolver.TTLTupleDuplicateResolver)1 Test (org.junit.Test)1