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