use of org.bboxdb.storage.sstable.compact.SSTableCompactor in project bboxdb by jnidzwetzki.
the class TestTableCompactor method exectuteCompactAndGetReader.
/**
* Execute a compactification and return the reader for the resulting table
*
* @param reader1
* @param reader2
* @param writer
* @param major
* @return
* @throws StorageManagerException
*/
protected SSTableKeyIndexReader exectuteCompactAndGetReader(final SSTableKeyIndexReader reader1, final SSTableKeyIndexReader reader2, final boolean majorCompaction) throws StorageManagerException {
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.setMajorCompaction(majorCompaction);
compactor.executeCompactation();
final List<SSTableWriter> resultWriter = compactor.getResultList();
Assert.assertEquals(1, resultWriter.size());
final SSTableWriter writer = resultWriter.get(0);
final SSTableReader reader = new SSTableReader(STORAGE_DIRECTORY, TEST_RELATION, writer.getTablenumber());
reader.init();
final SSTableKeyIndexReader ssTableIndexReader = new SSTableKeyIndexReader(reader);
ssTableIndexReader.init();
return ssTableIndexReader;
}
use of org.bboxdb.storage.sstable.compact.SSTableCompactor 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();
}
}
Aggregations