Search in sources :

Example 16 with DeletedTuple

use of org.bboxdb.storage.entity.DeletedTuple in project bboxdb by jnidzwetzki.

the class TestMemtable method testNewestOldest.

/**
 * Test newest and oldest timestamp
 * @throws StorageManagerException
 */
@Test(timeout = 60000)
public void testNewestOldest() throws StorageManagerException {
    final Tuple createdTuple1 = new Tuple("1", null, "abc".getBytes(), 60);
    memtable.put(createdTuple1);
    final Tuple createdTuple2 = new Tuple("2", null, "def".getBytes(), 1);
    memtable.put(createdTuple2);
    Assert.assertEquals(1, memtable.getOldestTupleVersionTimestamp());
    Assert.assertEquals(60, memtable.getNewestTupleVersionTimestamp());
    final DeletedTuple deletedTuple = new DeletedTuple("3", 500);
    memtable.put(deletedTuple);
    Assert.assertEquals(1, memtable.getOldestTupleVersionTimestamp());
    Assert.assertEquals(500, memtable.getNewestTupleVersionTimestamp());
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 17 with DeletedTuple

use of org.bboxdb.storage.entity.DeletedTuple in project bboxdb by jnidzwetzki.

the class TestMemtable method testTupleDelete.

/**
 * Test the deletion of a tuple
 * @throws Exception
 */
@Test(timeout = 60000)
public void testTupleDelete() throws Exception {
    final Tuple createdTuple = new Tuple("1", null, "abc".getBytes());
    memtable.put(createdTuple);
    Assert.assertEquals(createdTuple, memtable.get("1").get(0));
    memtable.delete("1", MicroSecondTimestampProvider.getNewTimestamp());
    Assert.assertTrue(memtable.get("1").get(1) instanceof DeletedTuple);
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 18 with DeletedTuple

use of org.bboxdb.storage.entity.DeletedTuple in project bboxdb by jnidzwetzki.

the class TestTupleSink method testTupleRedistribution2.

/**
 * Test the tuple redistribution
 * @throws Exception
 */
@Test(timeout = 60000)
public void testTupleRedistribution2() throws Exception {
    final DistributionRegion distributionRegion1 = new DistributionRegion(TEST_GROUP, DistributionRegion.ROOT_NODE_ROOT_POINTER, new BoundingBox(0.0, 1.0, 0.0, 1.0, 0.0, 1.0), 1);
    final DistributionRegion distributionRegion2 = new DistributionRegion(TEST_GROUP, DistributionRegion.ROOT_NODE_ROOT_POINTER, new BoundingBox(5.0, 6.0, 5.0, 6.0, 5.0, 6.0), 1);
    final TupleRedistributor tupleRedistributor = createTupleRedistributor();
    final AbstractTupleSink tupleSink1 = Mockito.mock(AbstractTupleSink.class);
    tupleRedistributor.registerRegion(distributionRegion1, Arrays.asList(tupleSink1));
    final AbstractTupleSink tupleSink2 = Mockito.mock(AbstractTupleSink.class);
    tupleRedistributor.registerRegion(distributionRegion2, Arrays.asList(tupleSink2));
    final Tuple tuple1 = new Tuple("abc", new BoundingBox(0.0, 1.0, 0.0, 1.0, 0.0, 1.0), "".getBytes());
    tupleRedistributor.redistributeTuple(tuple1);
    (Mockito.verify(tupleSink1, Mockito.times(1))).sinkTuple(Mockito.any(Tuple.class));
    (Mockito.verify(tupleSink2, Mockito.never())).sinkTuple(Mockito.any(Tuple.class));
    final Tuple tuple2 = new Tuple("abc", new BoundingBox(5.0, 6.0, 5.0, 6.0, 5.0, 6.0), "".getBytes());
    tupleRedistributor.redistributeTuple(tuple2);
    (Mockito.verify(tupleSink1, Mockito.times(1))).sinkTuple(Mockito.any(Tuple.class));
    (Mockito.verify(tupleSink2, Mockito.times(1))).sinkTuple(Mockito.any(Tuple.class));
    final Tuple tuple3 = new Tuple("abc", new BoundingBox(0.0, 6.0, 0.0, 6.0, 0.0, 6.0), "".getBytes());
    tupleRedistributor.redistributeTuple(tuple3);
    (Mockito.verify(tupleSink1, Mockito.atLeast(2))).sinkTuple(Mockito.any(Tuple.class));
    (Mockito.verify(tupleSink2, Mockito.atLeast(2))).sinkTuple(Mockito.any(Tuple.class));
    final Tuple tuple4 = new DeletedTuple("abc");
    tupleRedistributor.redistributeTuple(tuple4);
    (Mockito.verify(tupleSink1, Mockito.atLeast(3))).sinkTuple(Mockito.any(Tuple.class));
    (Mockito.verify(tupleSink2, Mockito.atLeast(3))).sinkTuple(Mockito.any(Tuple.class));
    System.out.println(tupleRedistributor.getStatistics());
}
Also used : TupleRedistributor(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) DistributionRegion(org.bboxdb.distribution.region.DistributionRegion) BoundingBox(org.bboxdb.commons.math.BoundingBox) AbstractTupleSink(org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 19 with DeletedTuple

use of org.bboxdb.storage.entity.DeletedTuple in project bboxdb by jnidzwetzki.

the class TestSSTableMetadataBuilder method testSSTableIndexBuilder8.

/**
 * Build index with multiple tuples - check timestamps
 */
@Test(timeout = 60000)
public void testSSTableIndexBuilder8() {
    final SSTableMetadataBuilder ssTableIndexBuilder = new SSTableMetadataBuilder();
    final Tuple tuple1 = new Tuple("0", BoundingBox.FULL_SPACE, "".getBytes(), 6);
    ssTableIndexBuilder.addTuple(tuple1);
    Assert.assertEquals(6, ssTableIndexBuilder.getMetaData().getNewestTupleVersionTimestamp());
    Assert.assertEquals(6, ssTableIndexBuilder.getMetaData().getOldestTupleVersionTimestamp());
    Assert.assertEquals(tuple1.getReceivedTimestamp(), ssTableIndexBuilder.getMetaData().getNewestTupleInsertedTimstamp());
    final Tuple tuple2 = new Tuple("0", BoundingBox.FULL_SPACE, "".getBytes(), 7);
    ssTableIndexBuilder.addTuple(tuple2);
    Assert.assertEquals(7, ssTableIndexBuilder.getMetaData().getNewestTupleVersionTimestamp());
    Assert.assertEquals(6, ssTableIndexBuilder.getMetaData().getOldestTupleVersionTimestamp());
    Assert.assertEquals(tuple2.getReceivedTimestamp(), ssTableIndexBuilder.getMetaData().getNewestTupleInsertedTimstamp());
    final Tuple tuple3 = new Tuple("0", BoundingBox.FULL_SPACE, "".getBytes(), 2);
    ssTableIndexBuilder.addTuple(tuple3);
    Assert.assertEquals(7, ssTableIndexBuilder.getMetaData().getNewestTupleVersionTimestamp());
    Assert.assertEquals(2, ssTableIndexBuilder.getMetaData().getOldestTupleVersionTimestamp());
    Assert.assertEquals(tuple3.getReceivedTimestamp(), ssTableIndexBuilder.getMetaData().getNewestTupleInsertedTimstamp());
    final Tuple tuple4 = new DeletedTuple("0", 22);
    ssTableIndexBuilder.addTuple(tuple4);
    Assert.assertEquals(22, ssTableIndexBuilder.getMetaData().getNewestTupleVersionTimestamp());
    Assert.assertEquals(2, ssTableIndexBuilder.getMetaData().getOldestTupleVersionTimestamp());
    Assert.assertEquals(tuple4.getReceivedTimestamp(), ssTableIndexBuilder.getMetaData().getNewestTupleInsertedTimstamp());
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) SSTableMetadataBuilder(org.bboxdb.storage.sstable.SSTableMetadataBuilder) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Tuple(org.bboxdb.storage.entity.Tuple) Test(org.junit.Test)

Example 20 with DeletedTuple

use of org.bboxdb.storage.entity.DeletedTuple in project bboxdb by jnidzwetzki.

the class TestStorageManager method testTupleDelete.

@Test(timeout = 60000)
public void testTupleDelete() throws Exception {
    final Tuple createdTuple = new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes());
    storageManager.put(createdTuple);
    Assert.assertEquals(createdTuple, storageManager.get("1").get(0));
    storageManager.delete("1", MicroSecondTimestampProvider.getNewTimestamp());
    Assert.assertTrue(storageManager.get("1").get(0) instanceof DeletedTuple);
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Aggregations

DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)25 Tuple (org.bboxdb.storage.entity.Tuple)24 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)7 BoundingBox (org.bboxdb.commons.math.BoundingBox)6 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)5 ByteBuffer (java.nio.ByteBuffer)4 SSTableKeyIndexReader (org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader)4 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)3 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)3 List (java.util.List)2 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)2 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)2 JoinedTupleResponse (org.bboxdb.network.packages.response.JoinedTupleResponse)2 TupleResponse (org.bboxdb.network.packages.response.TupleResponse)2 RoutingHop (org.bboxdb.network.routing.RoutingHop)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 AbstractTupleSink (org.bboxdb.distribution.partitioner.regionsplit.tuplesink.AbstractTupleSink)1 TupleRedistributor (org.bboxdb.distribution.partitioner.regionsplit.tuplesink.TupleRedistributor)1 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)1