Search in sources :

Example 26 with Scan

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

the class StorageSingleClusteringKeyScanIntegrationTestBase method scan_WithClusteringKeyRangeWithMinAndMaxValue_ShouldReturnProperResult.

private void scan_WithClusteringKeyRangeWithMinAndMaxValue_ShouldReturnProperResult(List<Value<?>> clusteringKeyValues, DataType clusteringKeyType, Order clusteringOrder, boolean startInclusive, boolean endInclusive, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
    // Arrange
    Value<?> startClusteringKeyValue = getMinValue(CLUSTERING_KEY, clusteringKeyType);
    Value<?> endClusteringKeyValue = getMaxValue(CLUSTERING_KEY, clusteringKeyType);
    List<Value<?>> expected = getExpected(clusteringKeyValues, startClusteringKeyValue, startInclusive, endClusteringKeyValue, endInclusive, orderingType);
    int limit = getLimit(withLimit, expected);
    if (limit > 0) {
        expected = expected.subList(0, limit);
    }
    Scan scan = getScan(clusteringKeyType, clusteringOrder, startClusteringKeyValue, startInclusive, endClusteringKeyValue, endInclusive, orderingType, limit);
    // Act
    List<Result> actual = scanAll(scan);
    // Assert
    assertScanResult(actual, expected, description(clusteringKeyType, clusteringOrder, startInclusive, endInclusive, orderingType, withLimit));
}
Also used : Value(com.scalar.db.io.Value) Scan(com.scalar.db.api.Scan) Result(com.scalar.db.api.Result)

Example 27 with Scan

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

the class StorageSingleClusteringKeyScanIntegrationTestBase method scan_WithClusteringKeyRangeWithSameValues_ShouldReturnProperResult.

private void scan_WithClusteringKeyRangeWithSameValues_ShouldReturnProperResult(List<Value<?>> clusteringKeyValues, DataType clusteringKeyType, Order clusteringOrder, boolean startInclusive, boolean endInclusive, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
    // Arrange
    Value<?> startAndEndClusteringKeyValue;
    if (clusteringKeyType == DataType.BOOLEAN) {
        startAndEndClusteringKeyValue = clusteringKeyValues.get(0);
    } else {
        startAndEndClusteringKeyValue = clusteringKeyValues.get(9);
    }
    List<Value<?>> expected = getExpected(clusteringKeyValues, startAndEndClusteringKeyValue, startInclusive, startAndEndClusteringKeyValue, endInclusive, orderingType);
    int limit = getLimit(withLimit, expected);
    if (limit > 0) {
        expected = expected.subList(0, limit);
    }
    Scan scan = getScan(clusteringKeyType, clusteringOrder, startAndEndClusteringKeyValue, startInclusive, startAndEndClusteringKeyValue, endInclusive, orderingType, limit);
    // Act
    List<Result> actual = scanAll(scan);
    // Assert
    assertScanResult(actual, expected, description(clusteringKeyType, clusteringOrder, startInclusive, endInclusive, orderingType, withLimit));
}
Also used : Value(com.scalar.db.io.Value) Scan(com.scalar.db.api.Scan) Result(com.scalar.db.api.Result)

Example 28 with Scan

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

the class StorageSingleClusteringKeyScanIntegrationTestBase method scan_WithoutClusteringKeyRange_ShouldReturnProperResult.

private void scan_WithoutClusteringKeyRange_ShouldReturnProperResult(List<Value<?>> clusteringKeyValues, DataType clusteringKeyType, Order clusteringOrder, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
    // Arrange
    List<Value<?>> expected = getExpected(clusteringKeyValues, null, null, null, null, orderingType);
    int limit = getLimit(withLimit, expected);
    if (limit > 0) {
        expected = expected.subList(0, limit);
    }
    Scan scan = getScan(clusteringKeyType, clusteringOrder, null, null, null, null, orderingType, limit);
    // Act
    List<Result> actual = scanAll(scan);
    // Assert
    assertScanResult(actual, expected, description(clusteringKeyType, clusteringOrder, null, null, orderingType, withLimit));
}
Also used : Value(com.scalar.db.io.Value) Scan(com.scalar.db.api.Scan) Result(com.scalar.db.api.Result)

Example 29 with Scan

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

the class StorageSingleClusteringKeyScanIntegrationTestBase method scan_WithClusteringKeyEndRangeWithMaxValue_ShouldReturnProperResult.

private void scan_WithClusteringKeyEndRangeWithMaxValue_ShouldReturnProperResult(List<Value<?>> clusteringKeyValues, DataType clusteringKeyType, Order clusteringOrder, boolean endInclusive, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
    // Arrange
    Value<?> endClusteringKey = getMaxValue(CLUSTERING_KEY, clusteringKeyType);
    List<Value<?>> expected = getExpected(clusteringKeyValues, null, null, endClusteringKey, endInclusive, orderingType);
    int limit = getLimit(withLimit, expected);
    if (limit > 0) {
        expected = expected.subList(0, limit);
    }
    Scan scan = getScan(clusteringKeyType, clusteringOrder, null, null, endClusteringKey, endInclusive, orderingType, limit);
    // Act
    List<Result> actual = scanAll(scan);
    // Assert
    assertScanResult(actual, expected, description(clusteringKeyType, clusteringOrder, null, endInclusive, orderingType, withLimit));
}
Also used : Value(com.scalar.db.io.Value) Scan(com.scalar.db.api.Scan) Result(com.scalar.db.api.Result)

Example 30 with Scan

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

the class StorageSingleClusteringKeyScanIntegrationTestBase method scan_WithClusteringKeyStartRange_ShouldReturnProperResult.

private void scan_WithClusteringKeyStartRange_ShouldReturnProperResult(List<Value<?>> clusteringKeyValues, DataType clusteringKeyType, Order clusteringOrder, boolean startInclusive, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
    // Arrange
    Value<?> startClusteringKeyValue;
    if (clusteringKeyType == DataType.BOOLEAN) {
        startClusteringKeyValue = clusteringKeyValues.get(0);
    } else {
        startClusteringKeyValue = clusteringKeyValues.get(4);
    }
    List<Value<?>> expected = getExpected(clusteringKeyValues, startClusteringKeyValue, startInclusive, null, null, orderingType);
    int limit = getLimit(withLimit, expected);
    if (limit > 0) {
        expected = expected.subList(0, limit);
    }
    Scan scan = getScan(clusteringKeyType, clusteringOrder, startClusteringKeyValue, startInclusive, null, null, orderingType, limit);
    // Act
    List<Result> actual = scanAll(scan);
    // Assert
    assertScanResult(actual, expected, description(clusteringKeyType, clusteringOrder, startInclusive, null, orderingType, withLimit));
}
Also used : Value(com.scalar.db.io.Value) Scan(com.scalar.db.api.Scan) Result(com.scalar.db.api.Result)

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