use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method preparePut.
private Put preparePut(int id, int type, String namespace, String table) {
Key partitionKey = new Key(ACCOUNT_ID, id);
Key clusteringKey = new Key(ACCOUNT_TYPE, type);
return new Put(partitionKey, clusteringKey).forNamespace(namespace).forTable(table).withConsistency(Consistency.LINEARIZABLE);
}
use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class ConsensusCommitIntegrationTestBase method populateRecords.
private void populateRecords(String namespace, String table) throws CommitException, UnknownTransactionStatusException {
ConsensusCommit transaction = manager.start();
IntStream.range(0, NUM_ACCOUNTS).forEach(i -> IntStream.range(0, NUM_TYPES).forEach(j -> {
Key partitionKey = new Key(ACCOUNT_ID, i);
Key clusteringKey = new Key(ACCOUNT_TYPE, j);
Put put = new Put(partitionKey, clusteringKey).forNamespace(namespace).forTable(table).withValue(BALANCE, INITIAL_BALANCE);
transaction.put(put);
}));
transaction.commit();
}
use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class BatchHandlerTest method handle_MultiPartitionOperationsGiven_ShouldCallTransactWriteItems.
@Test
public void handle_MultiPartitionOperationsGiven_ShouldCallTransactWriteItems() {
// Arrange
when(client.transactWriteItems(any(TransactWriteItemsRequest.class))).thenReturn(transactWriteResponse);
Put put1 = preparePut();
Key partitionKey = new Key(ANY_NAME_1, ANY_TEXT_3);
Key clusteringKey = new Key(ANY_NAME_2, ANY_TEXT_3);
Put put2 = new Put(partitionKey, clusteringKey).forNamespace(ANY_NAMESPACE_NAME).forTable(ANY_TABLE_NAME).withValue(ANY_NAME_3, ANY_INT_1).withValue(ANY_NAME_4, ANY_INT_2);
// Act Assert
assertThatCode(() -> handler.handle(Arrays.asList(put1, put2))).doesNotThrowAnyException();
// Assert
verify(client).transactWriteItems(any(TransactWriteItemsRequest.class));
}
use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class DistributedTransactionServiceWithJdbcTransactionIntegrationTest method prepareDelete.
private Delete prepareDelete(int id, int type, String namespace, String table) {
Key partitionKey = new Key(ACCOUNT_ID, id);
Key clusteringKey = new Key(ACCOUNT_TYPE, type);
return new Delete(partitionKey, clusteringKey).forNamespace(namespace).forTable(table).withConsistency(Consistency.LINEARIZABLE);
}
use of com.scalar.db.io.Key in project scalardb by scalar-labs.
the class DistributedTransactionServiceWithJdbcTransactionIntegrationTest method preparePut.
private Put preparePut(int id, int type, String namespace, String table) {
Key partitionKey = new Key(ACCOUNT_ID, id);
Key clusteringKey = new Key(ACCOUNT_TYPE, type);
return new Put(partitionKey, clusteringKey).forNamespace(namespace).forTable(table).withConsistency(Consistency.LINEARIZABLE);
}
Aggregations