Search in sources :

Example 41 with Scan

use of com.scalar.db.api.Scan in project scalardb by scalar-labs.

the class ConsensusCommitIntegrationTestBase method scan_ScanGivenForDeletedWhenCoordinatorStateNotExistAndExpired_ShouldAbortTransaction.

@Test
public void scan_ScanGivenForDeletedWhenCoordinatorStateNotExistAndExpired_ShouldAbortTransaction() throws ExecutionException, CoordinatorException, CrudException {
    Scan scan = prepareScan(0, 0, 0, namespace1, TABLE_1);
    selection_SelectionGivenForDeletedWhenCoordinatorStateNotExistAndExpired_ShouldAbortTransaction(scan);
}
Also used : Scan(com.scalar.db.api.Scan) Test(org.junit.Test)

Example 42 with Scan

use of com.scalar.db.api.Scan in project scalardb by scalar-labs.

the class ConsensusCommitIntegrationTestBase method scan_ScanGivenForDeletedWhenCoordinatorStateNotExistAndNotExpired_ShouldNotAbortTransaction.

@Test
public void scan_ScanGivenForDeletedWhenCoordinatorStateNotExistAndNotExpired_ShouldNotAbortTransaction() throws ExecutionException, CoordinatorException {
    Scan scan = prepareScan(0, 0, 0, namespace1, TABLE_1);
    selection_SelectionGivenForDeletedWhenCoordinatorStateNotExistAndNotExpired_ShouldNotAbortTransaction(scan);
}
Also used : Scan(com.scalar.db.api.Scan) Test(org.junit.Test)

Example 43 with Scan

use of com.scalar.db.api.Scan in project scalardb by scalar-labs.

the class ConsensusCommitIntegrationTestBase method scan_DeleteGivenBefore_ShouldScan.

@Test
public void scan_DeleteGivenBefore_ShouldScan() throws CommitException, UnknownTransactionStatusException, CrudException {
    // Arrange
    ConsensusCommit transaction = manager.start();
    transaction.put(preparePut(0, 0, namespace1, TABLE_1).withValue(BALANCE, 1));
    transaction.put(preparePut(0, 1, namespace1, TABLE_1).withValue(BALANCE, 1));
    transaction.commit();
    // Act
    ConsensusCommit transaction1 = manager.start();
    transaction1.delete(prepareDelete(0, 0, namespace1, TABLE_1));
    Scan scan = prepareScan(0, 0, 1, namespace1, TABLE_1);
    List<Result> results = transaction1.scan(scan);
    assertThatCode(transaction1::commit).doesNotThrowAnyException();
    // Assert
    assertThat(results.size()).isEqualTo(1);
}
Also used : Scan(com.scalar.db.api.Scan) Result(com.scalar.db.api.Result) Test(org.junit.Test)

Example 44 with Scan

use of com.scalar.db.api.Scan in project scalardb by scalar-labs.

the class ConsensusCommitIntegrationTestBase method scan_ScanGivenForDeletedWhenCoordinatorStateAborted_ShouldRollback.

@Test
public void scan_ScanGivenForDeletedWhenCoordinatorStateAborted_ShouldRollback() throws ExecutionException, CoordinatorException, CrudException {
    Scan scan = prepareScan(0, 0, 0, namespace1, TABLE_1);
    selection_SelectionGivenForDeletedWhenCoordinatorStateAborted_ShouldRollback(scan);
}
Also used : Scan(com.scalar.db.api.Scan) Test(org.junit.Test)

Example 45 with Scan

use of com.scalar.db.api.Scan in project scalardb by scalar-labs.

the class DistributedTransactionServiceWithConsensusCommitIntegrationTest method scan_ScanGivenForNonExisting_ShouldReturnEmpty.

@Test
public void scan_ScanGivenForNonExisting_ShouldReturnEmpty() throws TransactionException {
    // Arrange
    populateRecords(TABLE_1);
    GrpcTransaction transaction = manager.start();
    Scan scan = prepareScan(0, 4, 4, TABLE_1);
    // Act
    List<Result> results = transaction.scan(scan);
    transaction.commit();
    // Assert
    assertThat(results.size()).isEqualTo(0);
}
Also used : Scan(com.scalar.db.api.Scan) GrpcTransaction(com.scalar.db.transaction.rpc.GrpcTransaction) Result(com.scalar.db.api.Result) Test(org.junit.Test)

Aggregations

Scan (com.scalar.db.api.Scan)241 Key (com.scalar.db.io.Key)137 Test (org.junit.jupiter.api.Test)125 Result (com.scalar.db.api.Result)105 Test (org.junit.Test)72 Put (com.scalar.db.api.Put)37 HashMap (java.util.HashMap)32 QueryRequest (software.amazon.awssdk.services.dynamodb.model.QueryRequest)32 AttributeValue (software.amazon.awssdk.services.dynamodb.model.AttributeValue)31 ByteBuffer (java.nio.ByteBuffer)27 KeyBytesEncoder (com.scalar.db.storage.dynamo.bytes.KeyBytesEncoder)26 Scanner (com.scalar.db.api.Scanner)17 CosmosQueryRequestOptions (com.azure.cosmos.models.CosmosQueryRequestOptions)14 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 PartitionKey (com.azure.cosmos.models.PartitionKey)11 ArrayList (java.util.ArrayList)11 Delete (com.scalar.db.api.Delete)9 Value (com.scalar.db.io.Value)8 ConditionalExpression (com.scalar.db.api.ConditionalExpression)7