Search in sources :

Example 1 with SSTableCompactor

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;
}
Also used : SSTableReader(org.bboxdb.storage.sstable.reader.SSTableReader) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) SSTableWriter(org.bboxdb.storage.sstable.SSTableWriter) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) SSTableCompactor(org.bboxdb.storage.sstable.compact.SSTableCompactor)

Example 2 with SSTableCompactor

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();
    }
}
Also used : SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) SSTableWriter(org.bboxdb.storage.sstable.SSTableWriter) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) TupleStoreManager(org.bboxdb.storage.tuplestore.manager.TupleStoreManager) SSTableCompactor(org.bboxdb.storage.sstable.compact.SSTableCompactor) Test(org.junit.Test)

Aggregations

TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)2 SSTableWriter (org.bboxdb.storage.sstable.SSTableWriter)2 SSTableCompactor (org.bboxdb.storage.sstable.compact.SSTableCompactor)2 SSTableKeyIndexReader (org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader)2 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)2 ArrayList (java.util.ArrayList)1 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)1 Tuple (org.bboxdb.storage.entity.Tuple)1 SSTableReader (org.bboxdb.storage.sstable.reader.SSTableReader)1 Test (org.junit.Test)1