Search in sources :

Example 11 with SSTableMetadataBuilder

use of org.bboxdb.storage.sstable.SSTableMetadataBuilder in project bboxdb by jnidzwetzki.

the class TestSSTableMetadataBuilder method testDumpAndReadFromYamlString1.

/**
 * Dump the index to yaml and reread the data
 */
@Test(timeout = 60000)
public void testDumpAndReadFromYamlString1() {
    final SSTableMetadataBuilder ssTableIndexBuilder = new SSTableMetadataBuilder();
    final BoundingBox boundingBox1 = new BoundingBox(1d, 2d, 1d, 2d);
    final Tuple tuple1 = new Tuple("abc", boundingBox1, "".getBytes());
    ssTableIndexBuilder.addTuple(tuple1);
    final TupleStoreMetaData metaData = ssTableIndexBuilder.getMetaData();
    final String yamlData = metaData.exportToYaml();
    final TupleStoreMetaData metaDataRead = TupleStoreMetaData.importFromYaml(yamlData);
    Assert.assertEquals(metaData, metaDataRead);
    Assert.assertEquals(2, metaData.getDimensions());
    Assert.assertTrue(metaData.toString().length() > 10);
    Assert.assertEquals(metaData.hashCode(), metaDataRead.hashCode());
}
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 12 with SSTableMetadataBuilder

use of org.bboxdb.storage.sstable.SSTableMetadataBuilder in project bboxdb by jnidzwetzki.

the class TestSSTableMetadataBuilder method testDumpAndReadFromYamlFile2.

/**
 * Dump the index to yaml file and reread the data - two tuple
 * @throws IOException
 */
@Test(timeout = 60000)
public void testDumpAndReadFromYamlFile2() throws IOException {
    final SSTableMetadataBuilder ssTableIndexBuilder = new SSTableMetadataBuilder();
    addTwoTuples(ssTableIndexBuilder);
    final File tmpFile = File.createTempFile("test", ".tmp");
    final TupleStoreMetaData metaData = ssTableIndexBuilder.getMetaData();
    metaData.exportToYamlFile(tmpFile);
    final TupleStoreMetaData metaDataRead = TupleStoreMetaData.importFromYamlFile(tmpFile);
    Assert.assertEquals(metaData, metaDataRead);
    tmpFile.delete();
}
Also used : TupleStoreMetaData(org.bboxdb.storage.entity.TupleStoreMetaData) SSTableMetadataBuilder(org.bboxdb.storage.sstable.SSTableMetadataBuilder) File(java.io.File) Test(org.junit.Test)

Example 13 with SSTableMetadataBuilder

use of org.bboxdb.storage.sstable.SSTableMetadataBuilder in project bboxdb by jnidzwetzki.

the class TestSSTableMetadataBuilder method testSSTableIndexBuilder5.

/**
 * Build index with two tuples
 */
@Test(timeout = 60000)
public void testSSTableIndexBuilder5() {
    final SSTableMetadataBuilder ssTableIndexBuilder = new SSTableMetadataBuilder();
    final BoundingBox boundingBox1 = new BoundingBox(1d, 2d);
    final Tuple tuple1 = new Tuple("abc", boundingBox1, "".getBytes());
    final BoundingBox boundingBox2 = new BoundingBox(1d, 1.1d);
    final Tuple tuple2 = new Tuple("def", boundingBox2, "".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)

Example 14 with SSTableMetadataBuilder

use of org.bboxdb.storage.sstable.SSTableMetadataBuilder in project bboxdb by jnidzwetzki.

the class TestSSTableMetadataBuilder method testDumpAndReadFromYamlFile1.

/**
 * Dump the index to yaml file and reread the data - zero tuples
 * @throws IOException
 */
@Test(timeout = 60000)
public void testDumpAndReadFromYamlFile1() throws IOException {
    final SSTableMetadataBuilder ssTableIndexBuilder = new SSTableMetadataBuilder();
    final File tmpFile = File.createTempFile("test", ".tmp");
    final TupleStoreMetaData metaData = ssTableIndexBuilder.getMetaData();
    metaData.exportToYamlFile(tmpFile);
    final TupleStoreMetaData metaDataRead = TupleStoreMetaData.importFromYamlFile(tmpFile);
    Assert.assertEquals(metaData, metaDataRead);
    tmpFile.delete();
}
Also used : TupleStoreMetaData(org.bboxdb.storage.entity.TupleStoreMetaData) SSTableMetadataBuilder(org.bboxdb.storage.sstable.SSTableMetadataBuilder) File(java.io.File) Test(org.junit.Test)

Aggregations

SSTableMetadataBuilder (org.bboxdb.storage.sstable.SSTableMetadataBuilder)14 Test (org.junit.Test)14 TupleStoreMetaData (org.bboxdb.storage.entity.TupleStoreMetaData)11 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)8 Tuple (org.bboxdb.storage.entity.Tuple)8 BoundingBox (org.bboxdb.commons.math.BoundingBox)7 File (java.io.File)2