Search in sources :

Example 41 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestRTreeMemoryDeserializer method testSerializeIndexSmall.

/**
 * Test the encoding and the decoding of the index with only one entry
 * = data is encoded in the root node
 *
 * @throws StorageManagerException
 * @throws IOException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testSerializeIndexSmall() throws StorageManagerException, IOException, InterruptedException {
    final List<SpatialIndexEntry> tupleList = new ArrayList<>();
    tupleList.add(new SpatialIndexEntry(new BoundingBox(1.0, 1.2), 2));
    final SpatialIndexBuilder index = new RTreeBuilder();
    index.bulkInsert(tupleList);
    RTreeTestHelper.queryIndex(tupleList, index);
    final File tempFile = File.createTempFile("rtree-", "-test");
    tempFile.deleteOnExit();
    final RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
    index.writeToFile(raf);
    raf.close();
    final AbstractRTreeReader indexRead = getRTreeReader();
    final RandomAccessFile rafRead = new RandomAccessFile(tempFile, "r");
    indexRead.readFromFile(rafRead);
    rafRead.close();
    final List<? extends SpatialIndexEntry> resultList = indexRead.getEntriesForRegion(new BoundingBox(1.1, 1.2));
    Assert.assertEquals(1, resultList.size());
    indexRead.close();
}
Also used : RTreeBuilder(org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder) RandomAccessFile(java.io.RandomAccessFile) AbstractRTreeReader(org.bboxdb.storage.sstable.spatialindex.rtree.AbstractRTreeReader) SpatialIndexBuilder(org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder) BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 42 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestCellGrid method testCellGridCreation.

/**
 * Test cell grid creation
 */
@Test(timeout = 60000)
public void testCellGridCreation() {
    final CellGrid cellGrid2D1 = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0), 10);
    final CellGrid cellGrid2D2 = CellGrid.buildWithFixedCellSize(new BoundingBox(0.0, 10.0, 0.0, 10.0), 1);
    Assert.assertEquals(cellGrid2D1.getAllCells(), cellGrid2D2.getAllCells());
    Assert.assertEquals(cellGrid2D1, cellGrid2D2);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) CellGrid(org.bboxdb.storage.entity.CellGrid) Test(org.junit.Test)

Example 43 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestCellGrid method testGetCells1.

/**
 * Test the cell creation
 */
@Test(timeout = 60000)
public void testGetCells1() {
    final CellGrid cellGrid1D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0), 10);
    Assert.assertEquals(10, cellGrid1D.getAllCells().size());
    final CellGrid cellGrid2D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0), 10);
    Assert.assertEquals(100, cellGrid2D.getAllCells().size());
    final CellGrid cellGrid3D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0, 0.0, 10.0), 10);
    Assert.assertEquals(1000, cellGrid3D.getAllCells().size());
    final CellGrid cellGrid4D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0), 10);
    Assert.assertEquals(10000, cellGrid4D.getAllCells().size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) CellGrid(org.bboxdb.storage.entity.CellGrid) Test(org.junit.Test)

Example 44 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class TestCellGrid method testGetCells3.

/**
 * Test the cell creation
 */
@Test(expected = IllegalArgumentException.class)
public void testGetCells3() {
    final CellGrid cellGrid2D = CellGrid.buildWithFixedAmountOfCells(new BoundingBox(0.0, 10.0, 0.0, 10.0), 10);
    Assert.assertEquals(1, cellGrid2D.getAllInersectedBoundingBoxes(new BoundingBox(1.5, 1.5, 1.5, 1.5)).size());
    // Wrong dimension
    Assert.assertEquals(1, cellGrid2D.getAllInersectedBoundingBoxes(new BoundingBox(10.0, 10.0)).size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) CellGrid(org.bboxdb.storage.entity.CellGrid) Test(org.junit.Test)

Example 45 with BoundingBox

use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.

the class BenchmarkInsertPerformance method runBenchmark.

@Override
public void runBenchmark() throws InterruptedException, ExecutionException, BBoxDBException {
    // Number of tuples
    final int tuples = 5000000;
    // Remove old data
    final EmptyResultFuture deleteResult = bboxdbClient.deleteDistributionGroup(DISTRIBUTION_GROUP);
    deleteResult.waitForAll();
    // Create a new distribution group
    final DistributionGroupConfiguration config = DistributionGroupConfigurationBuilder.create(3).withReplicationFactor((short) 3).build();
    final EmptyResultFuture createResult = bboxdbClient.createDistributionGroup(DISTRIBUTION_GROUP, config);
    createResult.waitForAll();
    final Random bbBoxRandom = new Random();
    // Insert the tuples
    for (; insertedTuples.get() < tuples; insertedTuples.incrementAndGet()) {
        final double x = Math.abs(bbBoxRandom.nextFloat() % 100000.0 * 1000);
        final double y = Math.abs(bbBoxRandom.nextFloat() % 100000.0 * 1000);
        final double z = Math.abs(bbBoxRandom.nextFloat() % 100000.0 * 1000);
        final BoundingBox boundingBox = new BoundingBox(x, x + 1, y, y + 1, z, z + 1);
        final EmptyResultFuture insertFuture = bboxdbClient.insertTuple(TABLE, new Tuple(Integer.toString(insertedTuples.get()), boundingBox, "abcdef".getBytes()));
        // register pending future
        pendingFutures.put(insertFuture);
    }
}
Also used : Random(java.util.Random) BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) Tuple(org.bboxdb.storage.entity.Tuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

Aggregations

BoundingBox (org.bboxdb.commons.math.BoundingBox)194 Test (org.junit.Test)113 Tuple (org.bboxdb.storage.entity.Tuple)61 ArrayList (java.util.ArrayList)25 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)24 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)23 BBoxDBException (org.bboxdb.misc.BBoxDBException)22 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)20 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)16 List (java.util.List)15 DistributionRegionIdMapper (org.bboxdb.distribution.region.DistributionRegionIdMapper)13 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)13 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)13 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)12 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)11 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)11 IOException (java.io.IOException)10 Date (java.util.Date)10 DoubleInterval (org.bboxdb.commons.math.DoubleInterval)10 SpatialIndexReadOperator (org.bboxdb.storage.queryprocessor.operator.SpatialIndexReadOperator)10