use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class OperationCheckerTest method whenCheckingScanAllOperationWithInvalidProjections_shouldThrowIllegalArgumentException.
@Test
public void whenCheckingScanAllOperationWithInvalidProjections_shouldThrowIllegalArgumentException() {
// Arrange
List<String> projections = Arrays.asList(COL1, COL2, "v4");
int limit = 10;
ScanAll scanAll = new ScanAll().withProjections(projections).withLimit(limit).forNamespace(NAMESPACE).forTable(TABLE_NAME);
// Act Assert
assertThatThrownBy(() -> operationChecker.check(scanAll)).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class ProtoUtils method toScan.
public static Scan toScan(com.scalar.db.rpc.Scan scan, TableMetadata metadata) {
Scan ret;
if (scan.hasPartitionKey()) {
ret = new Scan(toKey(scan.getPartitionKey(), metadata));
if (scan.hasStartClusteringKey()) {
ret.withStart(toKey(scan.getStartClusteringKey(), metadata), scan.getStartInclusive());
}
if (scan.hasEndClusteringKey()) {
ret.withEnd(toKey(scan.getEndClusteringKey(), metadata), scan.getEndInclusive());
}
scan.getOrderingList().forEach(o -> ret.withOrdering(toOrdering(o)));
} else {
ret = new ScanAll();
}
ret.withLimit(scan.getLimit());
if (!scan.getNamespace().isEmpty()) {
ret.forNamespace(scan.getNamespace());
}
if (!scan.getTable().isEmpty()) {
ret.forTable(scan.getTable());
}
ret.withConsistency(toConsistency(scan.getConsistency()));
ret.withProjections(scan.getProjectionList());
return ret;
}
use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class ConsensusCommitSpecificIntegrationTestBase method scanAll_ScanAllGivenForCommittedRecord_ShouldReturnRecord.
@Test
public void scanAll_ScanAllGivenForCommittedRecord_ShouldReturnRecord() throws CrudException, CommitException, UnknownTransactionStatusException {
// Arrange
populateRecords(namespace1, TABLE_1);
ConsensusCommit transaction = manager.start();
ScanAll scanAll = prepareScanAll(namespace1, TABLE_1).withLimit(1);
// Act
List<Result> results = transaction.scan(scanAll);
// Assert
assertThat(results.size()).isEqualTo(1);
Assertions.assertThat(((TransactionResult) ((FilteredResult) results.get(0)).getOriginalResult()).getState()).isEqualTo(TransactionState.COMMITTED);
}
use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class ConsensusCommitSpecificIntegrationTestBase method scanAll_DeleteCalledBefore_ShouldReturnEmpty.
@Test
public void scanAll_DeleteCalledBefore_ShouldReturnEmpty() throws CommitException, UnknownTransactionStatusException, CrudException {
// Arrange
ConsensusCommit transaction = manager.start();
transaction.put(preparePut(0, 0, namespace1, TABLE_1).withIntValue(BALANCE, 1));
transaction.commit();
// Act
ConsensusCommit transaction1 = manager.start();
ScanAll scanAll = prepareScanAll(namespace1, TABLE_1);
List<Result> resultBefore = transaction1.scan(scanAll);
transaction1.delete(prepareDelete(0, 0, namespace1, TABLE_1));
List<Result> resultAfter = transaction1.scan(scanAll);
assertThatCode(transaction1::commit).doesNotThrowAnyException();
// Assert
assertThat(resultBefore.size()).isEqualTo(1);
assertThat(resultAfter.size()).isEqualTo(0);
}
use of com.scalar.db.api.ScanAll in project scalardb by scalar-labs.
the class ConsensusCommitSpecificIntegrationTestBase method scanAll_DeleteGivenBefore_ShouldScanAll.
@Test
public void scanAll_DeleteGivenBefore_ShouldScanAll() throws CommitException, UnknownTransactionStatusException, CrudException {
// Arrange
ConsensusCommit transaction = manager.start();
transaction.put(preparePut(0, 0, namespace1, TABLE_1).withIntValue(BALANCE, 1));
transaction.put(preparePut(0, 1, namespace1, TABLE_1).withIntValue(BALANCE, 1));
transaction.commit();
// Act
ConsensusCommit transaction1 = manager.start();
transaction1.delete(prepareDelete(0, 0, namespace1, TABLE_1));
ScanAll scanAll = prepareScanAll(namespace1, TABLE_1);
List<Result> results = transaction1.scan(scanAll);
assertThatCode(transaction1::commit).doesNotThrowAnyException();
// Assert
assertThat(results.size()).isEqualTo(1);
}
Aggregations