Search in sources :

Example 21 with Tuple

use of org.bboxdb.storage.entity.Tuple 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());
}
Also used : SSTableWriter(org.bboxdb.storage.sstable.SSTableWriter) File(java.io.File) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 22 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestSSTable method createTupleList.

/**
 * Helper method for creating some test tuples
 *
 * @return
 */
protected List<Tuple> createTupleList() {
    final List<Tuple> tupleList = new ArrayList<Tuple>();
    tupleList.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes()));
    tupleList.add(new Tuple("2", BoundingBox.FULL_SPACE, "def".getBytes()));
    tupleList.add(new Tuple("3", BoundingBox.FULL_SPACE, "geh".getBytes()));
    tupleList.add(new Tuple("4", BoundingBox.FULL_SPACE, "ijk".getBytes()));
    tupleList.add(new DeletedTuple("4"));
    return tupleList;
}
Also used : DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) ArrayList(java.util.ArrayList) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple)

Example 23 with Tuple

use of org.bboxdb.storage.entity.Tuple 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);
}
Also used : SSTableReader(org.bboxdb.storage.sstable.reader.SSTableReader) SSTableKeyIndexReader(org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader) SSTableWriter(org.bboxdb.storage.sstable.SSTableWriter) File(java.io.File) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 24 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestSSTableMetadataBuilder method testSSTableIndexBuilder2.

/**
 * Build index with one tuple
 */
@Test(timeout = 60000)
public void testSSTableIndexBuilder2() {
    final SSTableMetadataBuilder ssTableIndexBuilder = new SSTableMetadataBuilder();
    final BoundingBox boundingBox1 = new BoundingBox(1d, 2d);
    final Tuple tuple1 = new Tuple("abc", boundingBox1, "".getBytes());
    ssTableIndexBuilder.addTuple(tuple1);
    final TupleStoreMetaData metadata = ssTableIndexBuilder.getMetaData();
    Assert.assertArrayEquals(boundingBox1.toDoubleArray(), metadata.getBoundingBoxData(), 0.001d);
    Assert.assertEquals(metadata.getOldestTupleVersionTimestamp(), metadata.getNewestTupleVersionTimestamp());
    Assert.assertEquals(1, metadata.getTuples());
    Assert.assertEquals(tuple1.getReceivedTimestamp(), metadata.getNewestTupleInsertedTimstamp());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleStoreMetaData(org.bboxdb.storage.entity.TupleStoreMetaData) SSTableMetadataBuilder(org.bboxdb.storage.sstable.SSTableMetadataBuilder) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Tuple(org.bboxdb.storage.entity.Tuple) Test(org.junit.Test)

Example 25 with Tuple

use of org.bboxdb.storage.entity.Tuple in project bboxdb by jnidzwetzki.

the class TestSSTableMetadataBuilder method testSSTableIndexBuilder3.

/**
 * Build index with two tuples
 */
@Test(timeout = 60000)
public void testSSTableIndexBuilder3() {
    final SSTableMetadataBuilder ssTableIndexBuilder = new SSTableMetadataBuilder();
    final BoundingBox boundingBox1 = new BoundingBox(1d, 2d);
    final Tuple tuple1 = new Tuple("abc", boundingBox1, "".getBytes());
    final Tuple tuple2 = new Tuple("def", boundingBox1, "".getBytes());
    ssTableIndexBuilder.addTuple(tuple1);
    ssTableIndexBuilder.addTuple(tuple2);
    final TupleStoreMetaData metadata = ssTableIndexBuilder.getMetaData();
    Assert.assertArrayEquals(boundingBox1.toDoubleArray(), metadata.getBoundingBoxData(), 0.001d);
    Assert.assertEquals(2, metadata.getTuples());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleStoreMetaData(org.bboxdb.storage.entity.TupleStoreMetaData) SSTableMetadataBuilder(org.bboxdb.storage.sstable.SSTableMetadataBuilder) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Tuple(org.bboxdb.storage.entity.Tuple) Test(org.junit.Test)

Aggregations

Tuple (org.bboxdb.storage.entity.Tuple)198 Test (org.junit.Test)123 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)104 BoundingBox (org.bboxdb.commons.math.BoundingBox)62 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)58 ArrayList (java.util.ArrayList)41 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)25 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)24 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)18 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)18 ByteBuffer (java.nio.ByteBuffer)17 BBoxDBException (org.bboxdb.misc.BBoxDBException)16 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)15 SSTableKeyIndexReader (org.bboxdb.storage.sstable.reader.SSTableKeyIndexReader)13 IOException (java.io.IOException)11 List (java.util.List)11 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)11 InsertTupleRequest (org.bboxdb.network.packages.request.InsertTupleRequest)11 StorageManagerException (org.bboxdb.storage.StorageManagerException)11 TupleBuilder (org.bboxdb.tools.converter.tuple.TupleBuilder)11