use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestTupleStoreAdapter method testTupleStoreConfig1.
/**
* Test configuration 1
* @throws ZookeeperException
*/
@Test(timeout = 60000)
public void testTupleStoreConfig1() throws ZookeeperException {
final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().build();
final TupleStoreName tupleStoreName = new TupleStoreName("dg_table1");
tupleStoreAdapter.deleteTable(tupleStoreName);
Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName));
tupleStoreAdapter.writeTuplestoreConfiguration(tupleStoreName, tupleStoreConfiguration);
final TupleStoreConfiguration readConfig = tupleStoreAdapter.readTuplestoreConfiguration(tupleStoreName);
Assert.assertEquals(tupleStoreConfiguration, readConfig);
Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName));
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestTupleStoreAdapter method testTupleStoreConfig3.
/**
* Test configuration 3
* @throws ZookeeperException
*/
@Test(timeout = 60000)
public void testTupleStoreConfig3() throws ZookeeperException {
final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().withSpatialIndexReader("reader").withSpatialIndexWriter("writer").build();
final TupleStoreName tupleStoreName = new TupleStoreName("dg_table1");
tupleStoreAdapter.deleteTable(tupleStoreName);
Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName));
tupleStoreAdapter.writeTuplestoreConfiguration(tupleStoreName, tupleStoreConfiguration);
final TupleStoreConfiguration readConfig = tupleStoreAdapter.readTuplestoreConfiguration(tupleStoreName);
Assert.assertEquals(tupleStoreConfiguration, readConfig);
Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName));
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method encodeAndDecodeCreateTable.
/**
* The the encoding and decoding of an create table package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void encodeAndDecodeCreateTable() throws IOException, PackageEncodeException {
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final TupleStoreConfiguration ssTableConfiguration = TupleStoreConfigurationBuilder.create().withTTL(10, TimeUnit.MILLISECONDS).withVersions(666).withSpatialIndexReader("reader").withSpatialIndexWriter("writer").build();
final CreateTableRequest createPackage = new CreateTableRequest(sequenceNumber, "test", ssTableConfiguration);
final byte[] encodedVersion = networkPackageToByte(createPackage);
Assert.assertNotNull(encodedVersion);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
final CreateTableRequest decodedPackage = CreateTableRequest.decodeTuple(bb);
Assert.assertEquals(createPackage.getTable(), decodedPackage.getTable());
Assert.assertEquals(createPackage.getTupleStoreConfiguration(), ssTableConfiguration);
Assert.assertEquals(createPackage, decodedPackage);
Assert.assertEquals(createPackage.hashCode(), decodedPackage.hashCode());
Assert.assertEquals(createPackage.toString(), decodedPackage.toString());
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestNetworkCommunication method testGetByKey.
/**
* Insert a tuple and request it via key
* @throws ExecutionException
* @throws InterruptedException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testGetByKey() throws InterruptedException, ExecutionException, BBoxDBException {
System.out.println("=== Running testGetByKey");
final String table = DISTRIBUTION_GROUP + "_relation12333";
final BBoxDBConnection bboxdbConnection = connectToServer();
final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
// Create table
final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
resultCreateTable.waitForAll();
Assert.assertFalse(resultCreateTable.isFailed());
// Inside our bbox query
final Tuple tuple1 = new Tuple("abc", new BoundingBox(0d, 1d, 0d, 1d), "abc".getBytes());
final EmptyResultFuture result1 = bboxDBClient.insertTuple(table, tuple1);
result1.waitForAll();
final TupleListFuture future = bboxDBClient.queryKey(table, "abc");
future.waitForAll();
final List<Tuple> resultList = Lists.newArrayList(future.iterator());
Assert.assertEquals(1, resultList.size());
System.out.println("=== End testGetByKey");
disconnect(bboxDBClient);
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestNetworkCommunication method testPaging.
/**
* Insert some tuples and request it via paging
* @throws ExecutionException
* @throws InterruptedException
* @throws BBoxDBException
*/
@Test(timeout = 60000)
public void testPaging() throws InterruptedException, ExecutionException, BBoxDBException {
System.out.println("=== Running testPaging");
final String table = DISTRIBUTION_GROUP + "_relation9999";
final BBoxDBConnection bboxdbConnection = connectToServer();
final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
// Create table
final EmptyResultFuture resultCreateTable = bboxDBClient.createTable(table, new TupleStoreConfiguration());
resultCreateTable.waitForAll();
Assert.assertFalse(resultCreateTable.isFailed());
// Inside our bbox query
final Tuple tuple1 = new Tuple("abc", new BoundingBox(0d, 1d, 0d, 1d), "abc".getBytes());
final EmptyResultFuture result1 = bboxDBClient.insertTuple(table, tuple1);
final Tuple tuple2 = new Tuple("def", new BoundingBox(0d, 0.5d, 0d, 0.5d), "def".getBytes());
final EmptyResultFuture result2 = bboxDBClient.insertTuple(table, tuple2);
final Tuple tuple3 = new Tuple("geh", new BoundingBox(0.5d, 1.5d, 0.5d, 1.5d), "geh".getBytes());
final EmptyResultFuture result3 = bboxDBClient.insertTuple(table, tuple3);
final Tuple tuple4 = new Tuple("ijk", new BoundingBox(-10d, -9d, -10d, -9d), "ijk".getBytes());
final EmptyResultFuture result4 = bboxDBClient.insertTuple(table, tuple4);
final Tuple tuple5 = new Tuple("lmn", new BoundingBox(1d, 2d, 1d, 2d), "lmn".getBytes());
final EmptyResultFuture result5 = bboxDBClient.insertTuple(table, tuple5);
result1.waitForAll();
result2.waitForAll();
result3.waitForAll();
result4.waitForAll();
result5.waitForAll();
// Without paging
System.out.println("Pages = unlimited");
bboxDBClient.setPagingEnabled(false);
bboxDBClient.setTuplesPerPage((short) 0);
final TupleListFuture future = bboxDBClient.queryBoundingBox(table, new BoundingBox(-10d, 10d, -10d, 10d));
future.waitForAll();
final List<Tuple> resultList = Lists.newArrayList(future.iterator());
Assert.assertEquals(5, resultList.size());
// With paging (tuples per page 10)
System.out.println("Pages = 10");
bboxDBClient.setPagingEnabled(true);
bboxDBClient.setTuplesPerPage((short) 10);
final TupleListFuture future2 = bboxDBClient.queryBoundingBox(table, new BoundingBox(-10d, 10d, -10d, 10d));
future2.waitForAll();
final List<Tuple> resultList2 = Lists.newArrayList(future2.iterator());
Assert.assertEquals(5, resultList2.size());
// With paging (tuples per page 5)
System.out.println("Pages = 5");
bboxDBClient.setPagingEnabled(true);
bboxDBClient.setTuplesPerPage((short) 5);
final TupleListFuture future3 = bboxDBClient.queryBoundingBox(table, new BoundingBox(-10d, 10d, -10d, 10d));
future3.waitForAll();
final List<Tuple> resultList3 = Lists.newArrayList(future3.iterator());
Assert.assertEquals(5, resultList3.size());
// With paging (tuples per page 2)
System.out.println("Pages = 2");
bboxDBClient.setPagingEnabled(true);
bboxDBClient.setTuplesPerPage((short) 2);
final TupleListFuture future4 = bboxDBClient.queryBoundingBox(table, new BoundingBox(-10d, 10d, -10d, 10d));
System.out.println("Client is waiting on: " + future4);
future4.waitForAll();
final List<Tuple> resultList4 = Lists.newArrayList(future4.iterator());
Assert.assertEquals(5, resultList4.size());
// With paging (tuples per page 1)
System.out.println("Pages = 1");
bboxDBClient.setPagingEnabled(true);
bboxDBClient.setTuplesPerPage((short) 1);
final TupleListFuture future5 = bboxDBClient.queryBoundingBox(table, new BoundingBox(-10d, 10d, -10d, 10d));
future5.waitForAll();
final List<Tuple> resultList5 = Lists.newArrayList(future5.iterator());
Assert.assertEquals(5, resultList5.size());
System.out.println("=== End testPaging");
disconnect(bboxDBClient);
}
Aggregations