Search in sources :

Example 96 with BoundingBox

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

the class TestNetworkClasses method encodeAndDecodeKeepAlive2.

/**
 * The the encoding and decoding of a keep alive package
 * @throws IOException
 * @throws PackageEncodeException
 */
@Test(timeout = 60000)
public void encodeAndDecodeKeepAlive2() throws IOException, PackageEncodeException {
    final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
    final String tablename = "testgroup_abc";
    final List<Tuple> tuples = new ArrayList<>();
    tuples.add(new Tuple("abc", new BoundingBox(1d, 2d, 1d, 2d), "".getBytes()));
    tuples.add(new Tuple("def", new BoundingBox(2d, 2d, 4d, 20d), "".getBytes()));
    tuples.add(new Tuple("xyz", new BoundingBox(10d, 20d, 10d, 20d), "".getBytes()));
    final KeepAliveRequest keepAlivePackage = new KeepAliveRequest(sequenceNumber, tablename, tuples);
    byte[] encodedVersion = networkPackageToByte(keepAlivePackage);
    Assert.assertNotNull(encodedVersion);
    final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
    final KeepAliveRequest decodedPackage = KeepAliveRequest.decodeTuple(bb);
    Assert.assertEquals(keepAlivePackage.getTablename(), decodedPackage.getTablename());
    Assert.assertEquals(keepAlivePackage.getTuples().size(), decodedPackage.getTuples().size());
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) ArrayList(java.util.ArrayList) KeepAliveRequest(org.bboxdb.network.packages.request.KeepAliveRequest) ByteBuffer(java.nio.ByteBuffer) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Example 97 with BoundingBox

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

the class TestNetworkClasses method encodeAndDecodeInsertTuple2.

/**
 * The the encoding and decoding of an insert tuple package
 * @throws IOException
 * @throws PackageEncodeException
 */
@Test(timeout = 60000)
public void encodeAndDecodeInsertTuple2() throws IOException, PackageEncodeException {
    final Tuple tuple = new Tuple("key", new BoundingBox(1.3244343224, 232.232333343, 34324.343, 343243.0), "abc".getBytes(), 12);
    final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
    final InsertTupleRequest insertPackage = new InsertTupleRequest(sequenceNumber, ROUTING_HEADER_UNROUTED, new TupleStoreName("test"), tuple);
    byte[] encodedVersion = networkPackageToByte(insertPackage);
    Assert.assertNotNull(encodedVersion);
    final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
    final InsertTupleRequest decodedPackage = InsertTupleRequest.decodeTuple(bb);
    Assert.assertEquals(insertPackage.getTuple(), decodedPackage.getTuple());
    Assert.assertEquals(insertPackage.getTable(), decodedPackage.getTable());
    Assert.assertEquals(insertPackage.getRoutingHeader(), new RoutingHeader(false));
    Assert.assertEquals(insertPackage, decodedPackage);
    Assert.assertEquals(insertPackage.hashCode(), decodedPackage.hashCode());
    Assert.assertTrue(insertPackage.toString().length() > 10);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) ByteBuffer(java.nio.ByteBuffer) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) InsertTupleRequest(org.bboxdb.network.packages.request.InsertTupleRequest) Test(org.junit.Test)

Example 98 with BoundingBox

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

the class TestNetworkClasses method testDecodeJoinQuery.

/**
 * Test decode bounding box query
 * @throws IOException
 * @throws PackageEncodeException
 */
@Test(timeout = 60000)
public void testDecodeJoinQuery() throws IOException, PackageEncodeException {
    final List<TupleStoreName> tables = Arrays.asList(new TupleStoreName("3dgroup_table1"), new TupleStoreName("3dgroup_table2"), new TupleStoreName("3dgroup_table3"));
    final BoundingBox boundingBox = new BoundingBox(10d, 20d);
    final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
    final QueryJoinRequest queryRequest = new QueryJoinRequest(sequenceNumber, ROUTING_HEADER_ROUTED, tables, boundingBox, false, (short) 10);
    byte[] encodedPackage = networkPackageToByte(queryRequest);
    Assert.assertNotNull(encodedPackage);
    final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedPackage);
    boolean result = NetworkPackageDecoder.validateRequestPackageHeader(bb, NetworkConst.REQUEST_TYPE_QUERY);
    Assert.assertTrue(result);
    final QueryJoinRequest decodedPackage = QueryJoinRequest.decodeTuple(bb);
    Assert.assertEquals(queryRequest.getBoundingBox(), decodedPackage.getBoundingBox());
    Assert.assertEquals(tables, decodedPackage.getTables());
    Assert.assertEquals(queryRequest.isPagingEnabled(), decodedPackage.isPagingEnabled());
    Assert.assertEquals(queryRequest.getTuplesPerPage(), decodedPackage.getTuplesPerPage());
    Assert.assertEquals(NetworkConst.REQUEST_QUERY_JOIN, NetworkPackageDecoder.getQueryTypeFromRequest(bb));
    Assert.assertEquals(queryRequest.toString(), decodedPackage.toString());
}
Also used : QueryJoinRequest(org.bboxdb.network.packages.request.QueryJoinRequest) BoundingBox(org.bboxdb.commons.math.BoundingBox) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 99 with BoundingBox

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

the class TestNetworkClasses method testDecodeCointinousBoundingBoxQuery.

/**
 * Test decode bounding box query
 * @throws IOException
 * @throws PackageEncodeException
 */
@Test(timeout = 60000)
public void testDecodeCointinousBoundingBoxQuery() throws IOException, PackageEncodeException {
    final String table = "table1";
    final BoundingBox boundingBox = new BoundingBox(10d, 20d);
    final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
    final QueryBoundingBoxContinuousRequest queryRequest = new QueryBoundingBoxContinuousRequest(sequenceNumber, ROUTING_HEADER_ROUTED, table, boundingBox);
    byte[] encodedPackage = networkPackageToByte(queryRequest);
    Assert.assertNotNull(encodedPackage);
    final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedPackage);
    boolean result = NetworkPackageDecoder.validateRequestPackageHeader(bb, NetworkConst.REQUEST_TYPE_QUERY);
    Assert.assertTrue(result);
    final QueryBoundingBoxContinuousRequest decodedPackage = QueryBoundingBoxContinuousRequest.decodeTuple(bb);
    Assert.assertEquals(queryRequest.getBoundingBox(), decodedPackage.getBoundingBox());
    Assert.assertEquals(queryRequest.getTable(), decodedPackage.getTable());
    Assert.assertEquals(NetworkConst.REQUEST_QUERY_CONTINUOUS_BBOX, NetworkPackageDecoder.getQueryTypeFromRequest(bb));
    Assert.assertTrue(queryRequest.toString().length() > 10);
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) QueryBoundingBoxContinuousRequest(org.bboxdb.network.packages.request.QueryBoundingBoxContinuousRequest) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 100 with BoundingBox

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

the class TestRegionIdMapper method testMappingAppears1.

/**
 * Wait until mapping appears
 * @throws InterruptedException
 * @throws TimeoutException
 */
@Test(timeout = 10000)
public void testMappingAppears1() throws TimeoutException, InterruptedException {
    final DistributionRegionIdMapper regionIdMapper = new DistributionRegionIdMapper(DISTRIBUTION_REGION_NAME);
    regionIdMapper.addMapping(3, new BoundingBox(15d, 18d, 15d, 18d));
    regionIdMapper.waitUntilMappingAppears(3);
}
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