Search in sources :

Example 6 with DeletedTuple

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

the class TestTableCompactor method testCompactationMajor1.

/**
 * Test a major compactation
 * @throws StorageManagerException
 */
@Test(timeout = 60000)
public void testCompactationMajor1() throws StorageManagerException {
    final List<Tuple> tupleList1 = new ArrayList<Tuple>();
    tupleList1.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes()));
    final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
    final List<Tuple> tupleList2 = new ArrayList<Tuple>();
    tupleList2.add(new DeletedTuple("2"));
    final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
    final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, true);
    boolean containsDeletedTuple = false;
    int counter = 0;
    for (final Tuple tuple : ssTableIndexReader) {
        counter++;
        if (tuple instanceof DeletedTuple) {
            containsDeletedTuple = true;
        }
    }
    Assert.assertEquals(1, counter);
    Assert.assertFalse(containsDeletedTuple);
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 7 with DeletedTuple

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

the class TestTableCompactor method testCompactTestWithDeletedTuple.

/**
 * Run the compactification with one deleted tuple
 * @throws StorageManagerException
 */
@Test(timeout = 60000)
public void testCompactTestWithDeletedTuple() throws StorageManagerException {
    final List<Tuple> tupleList1 = new ArrayList<Tuple>();
    tupleList1.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes()));
    final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
    final List<Tuple> tupleList2 = new ArrayList<Tuple>();
    tupleList2.add(new DeletedTuple("2"));
    final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
    final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, false);
    int counter = 0;
    for (@SuppressWarnings("unused") final Tuple tuple : ssTableIndexReader) {
        counter++;
    }
    Assert.assertEquals(2, counter);
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 8 with DeletedTuple

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

the class TestTableCompactor method testCompactationMajor2.

/**
 * Test a major compactation
 * @throws StorageManagerException
 */
@Test(timeout = 60000)
public void testCompactationMajor2() throws StorageManagerException {
    final List<Tuple> tupleList1 = new ArrayList<>();
    final Tuple nonDeletedTuple = new Tuple("KEY", BoundingBox.FULL_SPACE, "abc".getBytes());
    tupleList1.add(nonDeletedTuple);
    for (int i = 0; i < 1000; i++) {
        tupleList1.add(new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, "abc".getBytes()));
    }
    final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
    final List<Tuple> tupleList2 = new ArrayList<Tuple>();
    for (int i = 0; i < 1000; i++) {
        tupleList2.add(new DeletedTuple(Integer.toString(i)));
    }
    final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
    final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, true);
    final Iterator<Tuple> iterator = ssTableIndexReader.iterator();
    List<Tuple> tupes = Lists.newArrayList(iterator);
    Assert.assertEquals(1, tupes.size());
    Assert.assertTrue(tupes.contains(nonDeletedTuple));
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 9 with DeletedTuple

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

the class TestSampling method createDummyTable.

/**
 * Create a dummy table
 * @throws StorageManagerException
 * @throws RejectedException
 */
private void createDummyTable() throws StorageManagerException, RejectedException {
    final TupleStoreManager table = storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
    for (int i = 0; i < 100; i++) {
        table.put(new Tuple(Integer.toString(i), new BoundingBox(1d, 2d, 1d, 20d), "".getBytes()));
        table.put(new DeletedTuple(Integer.toString(i + 10000)));
    }
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) BoundingBox(org.bboxdb.commons.math.BoundingBox) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager)

Example 10 with DeletedTuple

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

the class TestNetworkClasses method encodeAndDecodeDeletedTuple1.

/**
 * The the encoding and decoding of an insert tuple package
 * @throws IOException
 * @throws PackageEncodeException
 */
@Test(timeout = 60000)
public void encodeAndDecodeDeletedTuple1() throws IOException, PackageEncodeException {
    final Tuple tuple = new DeletedTuple("key", 12);
    final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
    final InsertTupleRequest insertPackage = new InsertTupleRequest(sequenceNumber, ROUTING_HEADER_UNROUTED, new TupleStoreName("test"), tuple);
    byte[] encodedVersion = networkPackageToByte(insertPackage);
    Assert.assertNotNull(encodedVersion);
    final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
    final InsertTupleRequest decodedPackage = InsertTupleRequest.decodeTuple(bb);
    Assert.assertEquals(insertPackage.getTuple(), decodedPackage.getTuple());
    Assert.assertEquals(insertPackage.getTable(), decodedPackage.getTable());
    Assert.assertEquals(insertPackage.getRoutingHeader(), new RoutingHeader(false));
    Assert.assertEquals(insertPackage, decodedPackage);
    Assert.assertEquals(insertPackage.hashCode(), decodedPackage.hashCode());
    Assert.assertEquals(insertPackage.toString(), decodedPackage.toString());
    Assert.assertTrue(TupleHelper.isDeletedTuple(decodedPackage.getTuple()));
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) ByteBuffer(java.nio.ByteBuffer) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) InsertTupleRequest(org.bboxdb.network.packages.request.InsertTupleRequest) 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