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