Search in sources :

Example 1 with TTLAndVersionTupleDuplicateResolver

use of org.bboxdb.storage.sstable.duplicateresolver.TTLAndVersionTupleDuplicateResolver in project bboxdb by jnidzwetzki.

the class TestTupleHelper method testTupleDuplicateResolverTTLAndVersion1.

/**
 * Test the tuple resolver
 */
@Test(timeout = 60000)
public void testTupleDuplicateResolverTTLAndVersion1() {
    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 2 are removed with 10 duplicates
    final DuplicateResolver<Tuple> resolver = new TTLAndVersionTupleDuplicateResolver(4, TimeUnit.MICROSECONDS, 10, 6);
    resolver.removeDuplicates(tupleList);
    Assert.assertEquals(3, tupleList.size());
    Assert.assertTrue(tupleList.contains(tupleD));
    Assert.assertTrue(tupleList.contains(tupleE));
    Assert.assertTrue(tupleList.contains(tupleB));
}
Also used : TTLAndVersionTupleDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.TTLAndVersionTupleDuplicateResolver) 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)

Example 2 with TTLAndVersionTupleDuplicateResolver

use of org.bboxdb.storage.sstable.duplicateresolver.TTLAndVersionTupleDuplicateResolver in project bboxdb by jnidzwetzki.

the class TestTupleHelper method testTupleDuplicateResolverTTLAndVersion2.

/**
 * Test the tuple resolver
 */
@Test(timeout = 60000)
public void testTupleDuplicateResolverTTLAndVersion2() {
    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 2 are removed with 10 duplicates
    final DuplicateResolver<Tuple> resolver = new TTLAndVersionTupleDuplicateResolver(4, TimeUnit.MICROSECONDS, 1, 6);
    resolver.removeDuplicates(tupleList);
    Assert.assertEquals(1, tupleList.size());
    Assert.assertTrue(tupleList.contains(tupleD));
}
Also used : TTLAndVersionTupleDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.TTLAndVersionTupleDuplicateResolver) 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)2 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)2 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)2 Tuple (org.bboxdb.storage.entity.Tuple)2 TTLAndVersionTupleDuplicateResolver (org.bboxdb.storage.sstable.duplicateresolver.TTLAndVersionTupleDuplicateResolver)2 Test (org.junit.Test)2