use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class GrpcAdminTest method createTable_IsCalledWithProperArguments_StubShouldBeCalledProperly.
@Test
public void createTable_IsCalledWithProperArguments_StubShouldBeCalledProperly() throws ExecutionException {
// Arrange
String namespace = "namespace";
String table = "table";
TableMetadata metadata = TableMetadata.newBuilder().addColumn("col1", DataType.INT).addColumn("col2", DataType.INT).addPartitionKey("col1").build();
boolean ifNotExists = false;
Map<String, String> options = Collections.emptyMap();
// Act
admin.createTable(namespace, table, metadata, ifNotExists, options);
// Assert
verify(stub).createTable(any());
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class DistributedTransactionServiceWithJdbcTransactionIntegrationTest method createTable.
private static void createTable() 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);
admin.createTable(NAMESPACE, TABLE, tableMetadata, true);
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class DistributedTransactionServiceWithConsensusCommitIntegrationTest method createTables.
static void createTables(DistributedStorageAdmin admin, ConsensusCommitAdmin consensusCommitAdmin) 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 GrpcTransactionAdminTest method createTable_CalledWithProperArguments_StubShouldBeCalledProperly.
@Test
public void createTable_CalledWithProperArguments_StubShouldBeCalledProperly() throws ExecutionException {
// Arrange
String namespace = "namespace";
String table = "table";
TableMetadata metadata = TableMetadata.newBuilder().addColumn("col1", DataType.INT).addColumn("col2", DataType.INT).addPartitionKey("col1").build();
Map<String, String> options = Collections.emptyMap();
// Act
admin.createTable(namespace, table, metadata, true, options);
// Assert
verify(stub).createTable(CreateTableRequest.newBuilder().setNamespace(namespace).setTable(table).setTableMetadata(ProtoUtils.toTableMetadata(metadata)).setIfNotExists(true).putAllOptions(options).build());
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class DistributedStorageService method mutate.
@Override
public void mutate(MutateRequest request, StreamObserver<Empty> responseObserver) {
execute(() -> {
List<Mutation> mutations;
if (request.getMutationCount() > 0) {
TableMetadata metadata = tableMetadataManager.getTableMetadata(request.getMutationList().get(0).getNamespace(), request.getMutationList().get(0).getTable());
if (metadata == null) {
throw new IllegalArgumentException("the specified table is not found");
}
mutations = new ArrayList<>(request.getMutationCount());
for (com.scalar.db.rpc.Mutation mutation : request.getMutationList()) {
mutations.add(ProtoUtils.toMutation(mutation, metadata));
}
} else {
mutations = Collections.emptyList();
}
storage.mutate(mutations);
responseObserver.onNext(Empty.getDefaultInstance());
responseObserver.onCompleted();
}, responseObserver, "mutate");
}
Aggregations