use of org.bboxdb.storage.entity.Tuple 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));
}
use of org.bboxdb.storage.entity.Tuple 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));
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestTupleHelper method testConvertMultiTuple.
/**
* Test the convert method of multiple tuples
*/
@Test(expected = IllegalArgumentException.class)
public void testConvertMultiTuple() {
final Tuple tuple1 = new Tuple("abc", new BoundingBox(1d, 2d), "".getBytes());
final Tuple tuple2 = new Tuple("def", new BoundingBox(1d, 2d), "".getBytes());
final JoinedTuple joinedTuple1 = new JoinedTuple(Arrays.asList(tuple1, tuple2), Arrays.asList("abc", "def"));
joinedTuple1.convertToSingleTupleIfPossible();
}
use of org.bboxdb.storage.entity.Tuple 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));
}
use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.
the class TestTupleHelper method testTupleKeyComparator3.
/**
* Test the tuple key comparator
*/
@Test(timeout = 60000)
public void testTupleKeyComparator3() {
final Tuple tupleA = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 4);
final Tuple tupleB = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 1);
final Tuple tupleC = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 5);
final Tuple tupleD = new Tuple("abc", BoundingBox.FULL_SPACE, "abc".getBytes(), 2);
final List<Tuple> tupleList = new ArrayList<>(Arrays.asList(tupleA, tupleB, tupleC, tupleD));
tupleList.sort(TupleHelper.TUPLE_KEY_AND_VERSION_COMPARATOR);
Assert.assertEquals(tupleB, tupleList.get(0));
Assert.assertEquals(tupleD, tupleList.get(1));
Assert.assertEquals(tupleA, tupleList.get(2));
Assert.assertEquals(tupleC, tupleList.get(3));
}
Aggregations