use of org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader in project bboxdb by jnidzwetzki.
the class TestTableCompactor method testCompactTestSameKey.
@Test(timeout = 60000)
public void testCompactTestSameKey() throws StorageManagerException {
final List<Tuple> tupleList1 = new ArrayList<Tuple>();
tupleList1.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes(), 1));
final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
final List<Tuple> tupleList2 = new ArrayList<Tuple>();
tupleList2.add(new Tuple("1", BoundingBox.FULL_SPACE, "def".getBytes(), 2));
final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, false);
int counter = 0;
for (final Tuple tuple : ssTableIndexReader) {
Assert.assertTrue(tuple.getKey().equals("1"));
counter++;
}
Assert.assertEquals(1, counter);
}
use of org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader in project bboxdb by jnidzwetzki.
the class TestTableCompactor method testCompactationMinor.
/**
* Test a minor compactation
* @throws StorageManagerException
*/
@Test(timeout = 60000)
public void testCompactationMinor() 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);
boolean containsDeletedTuple = false;
int counter = 0;
for (final Tuple tuple : ssTableIndexReader) {
counter++;
if (tuple instanceof DeletedTuple) {
containsDeletedTuple = true;
}
}
Assert.assertEquals(2, counter);
Assert.assertTrue(containsDeletedTuple);
}
use of org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader in project bboxdb by jnidzwetzki.
the class TestTableCompactor method testCompactTestFileCreation.
@Test(timeout = 60000)
public void testCompactTestFileCreation() 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 Tuple("2", BoundingBox.FULL_SPACE, "def".getBytes()));
final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
storageRegistry.deleteTable(TEST_RELATION, true);
storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
final SSTableCompactor compactor = new SSTableCompactor(storageManager, Arrays.asList(reader1, reader2));
compactor.executeCompactation();
final List<SSTableWriter> resultWriter = compactor.getResultList();
Assert.assertEquals(1, resultWriter.size());
Assert.assertEquals(2, compactor.getReadTuples());
Assert.assertEquals(2, compactor.getWrittenTuples());
for (final SSTableWriter writer : resultWriter) {
Assert.assertTrue(writer.getSstableFile().exists());
Assert.assertTrue(writer.getSstableIndexFile().exists());
writer.close();
}
}
use of org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader in project bboxdb by jnidzwetzki.
the class SSTableExaminer method run.
@Override
public void run() {
try {
final SSTableFacade sstableFacade = new SSTableFacade(baseDirectory, relationname, tableNumber, 0);
sstableFacade.init();
if (!sstableFacade.acquire()) {
throw new StorageManagerException("Unable to acquire sstable reader");
}
final SSTableReader ssTableReader = sstableFacade.getSsTableReader();
final SSTableKeyIndexReader ssTableIndexReader = sstableFacade.getSsTableKeyIndexReader();
fullTableScan(ssTableReader);
if (!WILDCARD_KEY.equals(examineKey)) {
internalScan(ssTableReader);
seachViaIndex(ssTableReader, ssTableIndexReader);
}
sstableFacade.release();
sstableFacade.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations