Search in sources :

Example 76 with Tuple

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));
}
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 77 with Tuple

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));
}
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 78 with Tuple

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();
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 79 with Tuple

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));
}
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)

Example 80 with Tuple

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));
}
Also used : 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

Tuple (org.bboxdb.storage.entity.Tuple)198 Test (org.junit.Test)123 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)104 BoundingBox (org.bboxdb.commons.math.BoundingBox)62 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)58 ArrayList (java.util.ArrayList)41 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)25 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)24 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)18 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)18 ByteBuffer (java.nio.ByteBuffer)17 BBoxDBException (org.bboxdb.misc.BBoxDBException)16 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)15 SSTableKeyIndexReader (org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader)13 IOException (java.io.IOException)11 List (java.util.List)11 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)11 InsertTupleRequest (org.bboxdb.network.packages.request.InsertTupleRequest)11 StorageManagerException (org.bboxdb.storage.StorageManagerException)11 TupleBuilder (org.bboxdb.tools.converter.tuple.TupleBuilder)11