Search in sources :

Example 16 with BoundingBox

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

the class TestRegionIdMapper method testGetAll.

/**
 * Get all known mappings
 */
@Test(timeout = 60000)
public void testGetAll() {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(1, new BoundingBox(1d, 2d, 1d, 2d));
    regionIdMapper.addMapping(2, new BoundingBox(10d, 20d, 10d, 20d));
    regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
    final List<TupleStoreName> mappingResult = regionIdMapper.getAllLocalTables(DEFAULT_SSTABLE_NAME);
    Assert.assertEquals(3, mappingResult.size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 17 with BoundingBox

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

the class TestRegionIdMapper method testMappingDisappears2.

/**
 * Wait until mapping disappears
 * @throws InterruptedException
 * @throws TimeoutException
 */
@Test(timeout = 15000, expected = TimeoutException.class)
public void testMappingDisappears2() throws TimeoutException, InterruptedException {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
    regionIdMapper.waitUntilMappingDisappears(3, 5, TimeUnit.SECONDS);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 18 with BoundingBox

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

the class TestRegionIdMapper method testZeroMapping.

/**
 * Test the mapping with no entries
 */
@Test(timeout = 60000)
public void testZeroMapping() {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    Assert.assertEquals(0, regionIdMapper.getLocalTablesForRegion(new BoundingBox(2.5d, 2.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 19 with BoundingBox

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

the class TestRegionIdMapper method testMappingAppears3.

/**
 * Wait until mapping appears
 * @throws InterruptedException
 * @throws TimeoutException
 */
@Test(timeout = 15000)
public void testMappingAppears3() throws TimeoutException, InterruptedException {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    final Runnable runable = new Runnable() {

        @Override
        public void run() {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
        }
    };
    final Thread thread = new Thread(runable);
    thread.start();
    regionIdMapper.waitUntilMappingAppears(3, 5, TimeUnit.SECONDS);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

Example 20 with BoundingBox

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

the class TestRegionIdMapper method testOneMapping.

/**
 * Test the mapping with one entry
 */
@Test(timeout = 60000)
public void testOneMapping() {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(1, new BoundingBox(1d, 2d, 1d, 2d));
    Assert.assertEquals(0, regionIdMapper.getLocalTablesForRegion(new BoundingBox(2.5d, 2.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
    Assert.assertEquals(1, regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 1.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
    regionIdMapper.clear();
    Assert.assertEquals(0, regionIdMapper.getLocalTablesForRegion(new BoundingBox(1.5d, 1.5d, 1.5d, 1.5d), DEFAULT_SSTABLE_NAME).size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DistributionRegionIdMapper(org.bboxdb.distribution.region.DistributionRegionIdMapper) Test(org.junit.Test)

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