Search in sources :

Example 6 with SSTableKeyIndexReader

use of org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader in project bboxdb by jnidzwetzki.

the class TestTableCompactor method testCompactTestWithDeletedTuple.

/**
 * Run the compactification with one deleted tuple
 * @throws StorageManagerException
 */
@Test(timeout = 60000)
public void testCompactTestWithDeletedTuple() 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);
    int counter = 0;
    for (@SuppressWarnings("unused") final Tuple tuple : ssTableIndexReader) {
        counter++;
    }
    Assert.assertEquals(2, counter);
}
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 7 with SSTableKeyIndexReader

use of org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader in project bboxdb by jnidzwetzki.

the class TestTableCompactor method testCompactTestMerge.

@Test(timeout = 60000)
public void testCompactTestMerge() 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);
    final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, false);
    int counter = 0;
    for (@SuppressWarnings("unused") final Tuple tuple : ssTableIndexReader) {
        counter++;
    }
    Assert.assertEquals(tupleList1.size() + tupleList2.size(), 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 8 with SSTableKeyIndexReader

use of org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader in project bboxdb by jnidzwetzki.

the class TestTableCompactor method testCompactationMajor2.

/**
 * Test a major compactation
 * @throws StorageManagerException
 */
@Test(timeout = 60000)
public void testCompactationMajor2() throws StorageManagerException {
    final List<Tuple> tupleList1 = new ArrayList<>();
    final Tuple nonDeletedTuple = new Tuple("KEY", BoundingBox.FULL_SPACE, "abc".getBytes());
    tupleList1.add(nonDeletedTuple);
    for (int i = 0; i < 1000; i++) {
        tupleList1.add(new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, "abc".getBytes()));
    }
    final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
    final List<Tuple> tupleList2 = new ArrayList<Tuple>();
    for (int i = 0; i < 1000; i++) {
        tupleList2.add(new DeletedTuple(Integer.toString(i)));
    }
    final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
    final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, true);
    final Iterator<Tuple> iterator = ssTableIndexReader.iterator();
    List<Tuple> tupes = Lists.newArrayList(iterator);
    Assert.assertEquals(1, tupes.size());
    Assert.assertTrue(tupes.contains(nonDeletedTuple));
}
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 9 with SSTableKeyIndexReader

use of org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader in project bboxdb by jnidzwetzki.

the class TestTableCompactor method testCompactTestFileOneEmptyfile2.

@Test(timeout = 60000)
public void testCompactTestFileOneEmptyfile2() throws StorageManagerException {
    final List<Tuple> tupleList1 = new ArrayList<Tuple>();
    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);
    final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, false);
    int counter = 0;
    for (@SuppressWarnings("unused") final Tuple tuple : ssTableIndexReader) {
        counter++;
    }
    Assert.assertEquals(tupleList1.size() + tupleList2.size(), 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 10 with SSTableKeyIndexReader

use of org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader in project bboxdb by jnidzwetzki.

the class TestTableCompactor method testCompactTestMergeBig.

@Test(timeout = 60000)
public void testCompactTestMergeBig() throws StorageManagerException {
    SSTableKeyIndexReader reader1 = null;
    SSTableKeyIndexReader reader2 = null;
    final List<Tuple> tupleList = new ArrayList<Tuple>();
    for (int i = 0; i < 500; i = i + 2) {
        tupleList.add(new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, "abc".getBytes()));
    }
    reader1 = addTuplesToFileAndGetReader(tupleList, 5);
    tupleList.clear();
    for (int i = 1; i < 500; i = i + 2) {
        tupleList.add(new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, "def".getBytes()));
    }
    reader2 = addTuplesToFileAndGetReader(tupleList, 2);
    final SSTableKeyIndexReader ssTableIndexReader = exectuteCompactAndGetReader(reader1, reader2, false);
    // Check the amount of tuples
    int counter = 0;
    for (@SuppressWarnings("unused") final Tuple tuple : ssTableIndexReader) {
        counter++;
    }
    Assert.assertEquals(500, counter);
    // Check the consistency of the index
    for (int i = 1; i < 500; i++) {
        final List<Integer> positions = ssTableIndexReader.getPositionsForTuple(Integer.toString(i));
        Assert.assertTrue(positions.size() == 1);
    }
}
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)

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