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