use of org.bboxdb.storage.sstable.SSTableWriter in project bboxdb by jnidzwetzki.
the class SSTableServiceRunnable method openFacades.
/**
* Open the facades
*
* @param newTableWriter
* @param newFacades
* @throws StorageManagerException
*/
private void openFacades(final List<SSTableWriter> newTableWriter, final List<SSTableFacade> newFacades) throws StorageManagerException {
for (final SSTableWriter writer : newTableWriter) {
final TupleStoreManagerRegistry tupleStoreManagerRegistry = storage.getTupleStoreManagerRegistry();
final BBoxDBConfiguration configuration = tupleStoreManagerRegistry.getConfiguration();
final int sstableKeyCacheEntries = configuration.getSstableKeyCacheEntries();
final SSTableFacade newFacade = new SSTableFacade(writer.getDirectory(), writer.getName(), writer.getTablenumber(), sstableKeyCacheEntries);
newFacades.add(newFacade);
}
}
use of org.bboxdb.storage.sstable.SSTableWriter in project bboxdb by jnidzwetzki.
the class TestSSTable method testWrittenFiles.
/**
* Test written files
* @throws Exception
*/
@Test(timeout = 60000)
public void testWrittenFiles() throws Exception {
final String relationDirectory = SSTableHelper.getSSTableDir(STORAGE_DIRECTORY, TEST_RELATION);
final File relationDirectoryFile = new File(relationDirectory);
FileUtil.deleteRecursive(relationDirectoryFile.toPath());
Assert.assertFalse(relationDirectoryFile.exists());
relationDirectoryFile.mkdirs();
final List<Tuple> tupleList = createTupleList();
final SSTableWriter ssTableWriter = new SSTableWriter(STORAGE_DIRECTORY, TEST_RELATION, 1, EXPECTED_TUPLES);
ssTableWriter.open();
ssTableWriter.addData(tupleList);
final File sstableFile = ssTableWriter.getSstableFile();
final File sstableIndexFile = ssTableWriter.getSstableIndexFile();
ssTableWriter.close();
Assert.assertTrue(sstableFile.exists());
Assert.assertTrue(sstableIndexFile.exists());
}
use of org.bboxdb.storage.sstable.SSTableWriter in project bboxdb by jnidzwetzki.
the class TestSSTable method testIndexIterator.
/**
* Test the tuple iterator
* @throws Exception
*/
@Test(timeout = 60000)
public void testIndexIterator() throws Exception {
final String relationDirectory = SSTableHelper.getSSTableDir(STORAGE_DIRECTORY, TEST_RELATION);
final File relationDirectoryFile = new File(relationDirectory);
FileUtil.deleteRecursive(relationDirectoryFile.toPath());
relationDirectoryFile.mkdirs();
final List<Tuple> tupleList = createTupleList();
final SSTableWriter ssTableWriter = new SSTableWriter(STORAGE_DIRECTORY, TEST_RELATION, 1, EXPECTED_TUPLES);
ssTableWriter.open();
ssTableWriter.addData(tupleList);
final File sstableIndexFile = ssTableWriter.getSstableIndexFile();
ssTableWriter.close();
final SSTableReader sstableReader = new SSTableReader(STORAGE_DIRECTORY, TEST_RELATION, 1);
sstableReader.init();
final SSTableKeyIndexReader ssTableIndexReader = new SSTableKeyIndexReader(sstableReader);
ssTableIndexReader.init();
Assert.assertEquals(1, sstableReader.getTablebumber());
Assert.assertEquals(1, ssTableIndexReader.getTablebumber());
Assert.assertEquals(sstableIndexFile, ssTableIndexReader.getFile());
Assert.assertTrue(sstableReader.getLastModifiedTimestamp() > 0);
Assert.assertTrue(ssTableIndexReader.getLastModifiedTimestamp() > 0);
Assert.assertTrue(ssTableIndexReader.getSize() > 0);
Assert.assertTrue(sstableReader.getSize() > 0);
int tupleCounter = 0;
for (Tuple tuple : ssTableIndexReader) {
Assert.assertEquals(tupleList.get(tupleCounter), tuple);
tupleCounter++;
}
Assert.assertEquals(tupleList.size(), tupleCounter);
}
use of org.bboxdb.storage.sstable.SSTableWriter in project bboxdb by jnidzwetzki.
the class TestTableCompactor method addTuplesToFileAndGetReader.
/**
* Write the tuplelist into a SSTable and return a reader for this table
*
* @param tupleList
* @param number
* @return
* @throws StorageManagerException
*/
protected SSTableKeyIndexReader addTuplesToFileAndGetReader(final List<Tuple> tupleList, int number) throws StorageManagerException {
Collections.sort(tupleList);
final SSTableWriter ssTableWriter = new SSTableWriter(STORAGE_DIRECTORY, TEST_RELATION, number, EXPECTED_TUPLES);
ssTableWriter.open();
ssTableWriter.addData(tupleList);
ssTableWriter.close();
final SSTableReader sstableReader = new SSTableReader(STORAGE_DIRECTORY, TEST_RELATION, number);
sstableReader.init();
final SSTableKeyIndexReader ssTableIndexReader = new SSTableKeyIndexReader(sstableReader);
ssTableIndexReader.init();
return ssTableIndexReader;
}
use of org.bboxdb.storage.sstable.SSTableWriter 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;
}
Aggregations