use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestStorageManager method testVersionDuplicates.
/**
* Test the storage manager with duplicates
* @throws StorageManagerException
* @throws RejectedException
*/
@Test(timeout = 60000)
public void testVersionDuplicates() throws StorageManagerException, RejectedException {
// Delete the old table
storageRegistry.deleteTable(TEST_RELATION, true);
// Create a new table
final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().allowDuplicates(true).withVersions(3).build();
storageRegistry.createTable(TEST_RELATION, tupleStoreConfiguration);
// Assure table is created successfully
storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
Assert.assertTrue(storageManager.getServiceState().isInRunningState());
final Tuple tuple1 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc1".getBytes());
storageManager.put(tuple1);
final Tuple tuple2 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc2".getBytes());
storageManager.put(tuple2);
final Tuple tuple3 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc3".getBytes());
storageManager.put(tuple3);
final Tuple tuple4 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc4".getBytes());
storageManager.put(tuple4);
final Tuple tuple5 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc5".getBytes());
storageManager.put(tuple5);
final List<Tuple> readTuples = storageManager.get("abc");
Assert.assertEquals(3, readTuples.size());
Assert.assertTrue(readTuples.contains(tuple3));
Assert.assertTrue(readTuples.contains(tuple4));
Assert.assertTrue(readTuples.contains(tuple5));
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestStorageRegistry method testDeleteTable.
/**
* Test delete table
* @throws StorageManagerException
* @throws InterruptedException
* @throws RejectedException
*/
@Test(timeout = 60000)
public void testDeleteTable() throws StorageManagerException, InterruptedException, RejectedException {
storageRegistry.deleteTable(RELATION_NAME, true);
Assert.assertFalse(storageRegistry.isStorageManagerActive(RELATION_NAME));
storageRegistry.createTable(RELATION_NAME, new TupleStoreConfiguration());
final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(RELATION_NAME);
for (int i = 0; i < 50000; i++) {
final Tuple createdTuple = new Tuple(Integer.toString(i), BoundingBox.FULL_SPACE, Integer.toString(i).getBytes());
storageManager.put(createdTuple);
}
// Wait for requests to settle
storageManager.flush();
storageRegistry.deleteTable(RELATION_NAME, true);
Assert.assertTrue(storageManager.isShutdownComplete());
// Check the removal of the directory
final BBoxDBConfiguration configuration = BBoxDBConfigurationManager.getConfiguration();
final String storageDirectory = configuration.getStorageDirectories().get(0);
final String pathname = SSTableHelper.getSSTableDir(storageDirectory, RELATION_NAME);
final File directory = new File(pathname);
System.out.println("Check for " + directory);
Assert.assertFalse(directory.exists());
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestTableCompactor method testCompactTestFileCreation.
@Test(timeout = 60000)
public void testCompactTestFileCreation() throws StorageManagerException {
final List<Tuple> tupleList1 = new ArrayList<Tuple>();
tupleList1.add(new Tuple("1", BoundingBox.FULL_SPACE, "abc".getBytes()));
final SSTableKeyIndexReader reader1 = addTuplesToFileAndGetReader(tupleList1, 1);
final List<Tuple> tupleList2 = new ArrayList<Tuple>();
tupleList2.add(new Tuple("2", BoundingBox.FULL_SPACE, "def".getBytes()));
final SSTableKeyIndexReader reader2 = addTuplesToFileAndGetReader(tupleList2, 2);
storageRegistry.deleteTable(TEST_RELATION, true);
storageRegistry.createTable(TEST_RELATION, new TupleStoreConfiguration());
final TupleStoreManager storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
final SSTableCompactor compactor = new SSTableCompactor(storageManager, Arrays.asList(reader1, reader2));
compactor.executeCompactation();
final List<SSTableWriter> resultWriter = compactor.getResultList();
Assert.assertEquals(1, resultWriter.size());
Assert.assertEquals(2, compactor.getReadTuples());
Assert.assertEquals(2, compactor.getWrittenTuples());
for (final SSTableWriter writer : resultWriter) {
Assert.assertTrue(writer.getSstableFile().exists());
Assert.assertTrue(writer.getSstableIndexFile().exists());
writer.close();
}
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class CLI method actionCreateTable.
/**
* Create a new table
* @param line
*/
protected void actionCreateTable(final CommandLine line) {
if (!line.hasOption(CLIParameter.TABLE)) {
System.err.println("Create table should be performed, but no table was specified");
printHelpAndExit();
}
final TupleStoreConfigurationBuilder ssTableConfigurationBuilder = TupleStoreConfigurationBuilder.create();
// Duplicates
if (line.hasOption(CLIParameter.DUPLICATES)) {
final String allowDuplicates = line.getOptionValue(CLIParameter.DUPLICATES);
final boolean duplicatesAllowed = MathUtil.tryParseBooleanOrExit(allowDuplicates, () -> "Unable to parse the bolean value for duplicates: " + allowDuplicates);
ssTableConfigurationBuilder.allowDuplicates(duplicatesAllowed);
}
// TTL
if (line.hasOption(CLIParameter.TTL)) {
final String ttlString = line.getOptionValue(CLIParameter.TTL);
final int ttl = MathUtil.tryParseIntOrExit(ttlString, () -> "Unable to parse the region size: " + ttlString);
ssTableConfigurationBuilder.withTTL(ttl, TimeUnit.MILLISECONDS);
}
// Versions
if (line.hasOption(CLIParameter.VERSIONS)) {
final String versionString = line.getOptionValue(CLIParameter.VERSIONS);
final int versions = MathUtil.tryParseIntOrExit(versionString, () -> "Unable to parse the region size: " + versionString);
ssTableConfigurationBuilder.withVersions(versions);
}
// Spatial index reader
if (line.hasOption(CLIParameter.SPATIAL_INDEX_READER)) {
final String spatialIndexReader = line.getOptionValue(CLIParameter.SPATIAL_INDEX_READER);
ssTableConfigurationBuilder.withSpatialIndexReader(spatialIndexReader);
}
// Spatial index writer
if (line.hasOption(CLIParameter.SPATIAL_INDEX_WRITER)) {
final String spatialIndexWriter = line.getOptionValue(CLIParameter.SPATIAL_INDEX_WRITER);
ssTableConfigurationBuilder.withSpatialIndexWriter(spatialIndexWriter);
}
final TupleStoreConfiguration configuration = ssTableConfigurationBuilder.build();
try {
final String table = line.getOptionValue(CLIParameter.TABLE);
final EmptyResultFuture resultFuture = bboxDbConnection.createTable(table, configuration);
resultFuture.waitForAll();
if (resultFuture.isFailed()) {
System.err.println("Unable to create table: " + resultFuture.getAllMessages());
System.exit(-1);
}
} catch (BBoxDBException e) {
System.err.println("Got an exception while creating table: " + e);
System.exit(-1);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
}
use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.
the class TestTuplestoreConfiguration method testWriteAndReadConfiguration.
@Test(timeout = 60000)
public void testWriteAndReadConfiguration() {
final TupleStoreConfiguration configuration1 = new TupleStoreConfiguration();
final String yamlString = configuration1.exportToYaml();
final TupleStoreConfiguration configuration2 = TupleStoreConfiguration.importFromYaml(yamlString);
Assert.assertEquals(configuration1, configuration2);
Assert.assertEquals(configuration1.hashCode(), configuration2.hashCode());
Assert.assertTrue(configuration1.toString().length() > 10);
}
Aggregations