use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method createTables.
private void createTables() throws ExecutionException {
Map<String, String> options = getCreateOptions();
TableMetadata tableMetadata = TableMetadata.newBuilder().addColumn(ACCOUNT_ID, DataType.INT).addColumn(ACCOUNT_TYPE, DataType.INT).addColumn(BALANCE, DataType.INT).addPartitionKey(ACCOUNT_ID).addClusteringKey(ACCOUNT_TYPE).build();
admin.createNamespace(namespace1, true, options);
consensusCommitAdmin.createTransactionalTable(namespace1, TABLE_1, tableMetadata, true, options);
admin.createNamespace(namespace2, true, options);
consensusCommitAdmin.createTransactionalTable(namespace2, TABLE_2, tableMetadata, true, options);
consensusCommitAdmin.createCoordinatorTable(options);
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class TwoPhaseConsensusCommitIntegrationTest method createTables.
private static void createTables() throws ExecutionException {
TableMetadata tableMetadata = TableMetadata.newBuilder().addColumn(ACCOUNT_ID, DataType.INT).addColumn(ACCOUNT_TYPE, DataType.INT).addColumn(BALANCE, DataType.INT).addPartitionKey(ACCOUNT_ID).addClusteringKey(ACCOUNT_TYPE).build();
admin.createNamespace(NAMESPACE, true);
consensusCommitAdmin.createTransactionalTable(NAMESPACE, TABLE_1, tableMetadata, true);
consensusCommitAdmin.createTransactionalTable(NAMESPACE, TABLE_2, tableMetadata, true);
consensusCommitAdmin.createCoordinatorTable();
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class DeleteStatementHandler method handle.
@Nonnull
@Override
public List<Map<String, AttributeValue>> handle(Operation operation) throws ExecutionException {
checkArgument(operation, Delete.class);
Delete delete = (Delete) operation;
TableMetadata tableMetadata = metadataManager.getTableMetadata(operation);
try {
delete(delete, tableMetadata);
} catch (ConditionalCheckFailedException e) {
throw new NoMutationException("no mutation was applied.", e);
} catch (TransactionConflictException e) {
throw new RetriableExecutionException(e.getMessage(), e);
} catch (DynamoDbException e) {
throw new ExecutionException(e.getMessage(), e);
}
return Collections.emptyList();
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class Dynamo method scan.
@Override
public Scanner scan(Scan scan) throws ExecutionException {
scan = copyAndSetTargetToIfNot(scan);
operationChecker.check(scan);
TableMetadata metadata = metadataManager.getTableMetadata(scan);
ScalarDbUtils.addProjectionsForKeys(scan, metadata);
List<Map<String, AttributeValue>> items = selectStatementHandler.handle(scan);
return new ScannerImpl(items, new ResultInterpreter(scan.getProjections(), metadata));
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class SelectStatementHandler method handle.
@Nonnull
@Override
public List<Map<String, AttributeValue>> handle(Operation operation) throws ExecutionException {
checkArgument(operation, Get.class, Scan.class);
TableMetadata tableMetadata = metadataManager.getTableMetadata(operation);
try {
if (ScalarDbUtils.isSecondaryIndexSpecified(operation, tableMetadata)) {
return executeQueryWithIndex((Selection) operation, tableMetadata);
}
if (operation instanceof Get) {
return executeGet((Get) operation, tableMetadata);
} else {
return executeQuery((Scan) operation, tableMetadata);
}
} catch (DynamoDbException e) {
throw new ExecutionException(e.getMessage(), e);
}
}
Aggregations