use of org.bboxdb.storage.entity.TupleStoreConfigurationBuilder 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;
}
}
Aggregations