Search in sources :

Example 11 with SSTableKeyIndexReader

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

Example 12 with SSTableKeyIndexReader

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

Example 13 with SSTableKeyIndexReader

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

Example 14 with SSTableKeyIndexReader

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();
    }
}
Also used : SSTableReader(org.bboxdb.storage.sstable.reader.SSTableReader) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) SSTableFacade(org.bboxdb.storage.sstable.reader.SSTableFacade) StorageManagerException(org.bboxdb.storage.StorageManagerException) IOException(java.io.IOException) StorageManagerException(org.bboxdb.storage.StorageManagerException) BufferUnderflowException(java.nio.BufferUnderflowException)

Aggregations

SSTableKeyIndexReader (org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader)14 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)11 Tuple (org.bboxdb.storage.entity.Tuple)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 SSTableWriter (org.bboxdb.storage.sstable.SSTableWriter)4 SSTableReader (org.bboxdb.storage.sstable.reader.SSTableReader)4 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)2 SSTableCompactor (org.bboxdb.storage.sstable.compact.SSTableCompactor)2 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)2 File (java.io.File)1 IOException (java.io.IOException)1 BufferUnderflowException (java.nio.BufferUnderflowException)1 StorageManagerException (org.bboxdb.storage.StorageManagerException)1 SSTableFacade (org.bboxdb.storage.sstable.reader.SSTableFacade)1