Search in sources :

Example 6 with TupleStoreMetaData

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

the class TestSSTableMetadataBuilder method testSSTableIndexBuilder6.

/**
 * Build index with two tuples - bounding boxes are differ in the dimension
 */
@Test(expected = IllegalArgumentException.class)
public void testSSTableIndexBuilder6() {
    final SSTableMetadataBuilder ssTableIndexBuilder = new SSTableMetadataBuilder();
    final BoundingBox boundingBox1 = new BoundingBox(1d, 2d, 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(new double[] {}, 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 7 with TupleStoreMetaData

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

the class TestSSTableMetadataBuilder method testSSTableIndexBuilder4.

/**
 * Build index with two tuples
 */
@Test(timeout = 60000)
public void testSSTableIndexBuilder4() {
    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, 3d);
    final Tuple tuple2 = new Tuple("def", boundingBox2, "".getBytes());
    ssTableIndexBuilder.addTuple(tuple1);
    ssTableIndexBuilder.addTuple(tuple2);
    final TupleStoreMetaData metadata = ssTableIndexBuilder.getMetaData();
    Assert.assertArrayEquals(boundingBox2.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 8 with TupleStoreMetaData

use of org.bboxdb.storage.entity.TupleStoreMetaData 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 9 with TupleStoreMetaData

use of org.bboxdb.storage.entity.TupleStoreMetaData 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 10 with TupleStoreMetaData

use of org.bboxdb.storage.entity.TupleStoreMetaData 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)

Aggregations

TupleStoreMetaData (org.bboxdb.storage.entity.TupleStoreMetaData)13 Test (org.junit.Test)12 SSTableMetadataBuilder (org.bboxdb.storage.sstable.SSTableMetadataBuilder)11 BoundingBox (org.bboxdb.commons.math.BoundingBox)6 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)6 Tuple (org.bboxdb.storage.entity.Tuple)6 File (java.io.File)3