Search in sources :

Example 36 with Result

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

the class StorageSingleClusteringKeyScanIntegrationTestBase method scan_WithClusteringKeyEndRange_ShouldReturnProperResult.

private void scan_WithClusteringKeyEndRange_ShouldReturnProperResult(List<Value<?>> clusteringKeyValues, DataType clusteringKeyType, Order clusteringOrder, boolean endInclusive, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
    // Arrange
    Value<?> endClusteringKeyValue;
    if (clusteringKeyType == DataType.BOOLEAN) {
        endClusteringKeyValue = clusteringKeyValues.get(1);
    } else {
        endClusteringKeyValue = clusteringKeyValues.get(14);
    }
    List<Value<?>> expected = getExpected(clusteringKeyValues, null, null, endClusteringKeyValue, endInclusive, orderingType);
    int limit = getLimit(withLimit, expected);
    if (limit > 0) {
        expected = expected.subList(0, limit);
    }
    Scan scan = getScan(clusteringKeyType, clusteringOrder, null, null, endClusteringKeyValue, 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 37 with Result

use of com.scalar.db.api.Result 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 38 with Result

use of com.scalar.db.api.Result 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 39 with Result

use of com.scalar.db.api.Result 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 40 with Result

use of com.scalar.db.api.Result 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)

Aggregations

Result (com.scalar.db.api.Result)324 Test (org.junit.Test)158 Get (com.scalar.db.api.Get)132 Scan (com.scalar.db.api.Scan)106 Put (com.scalar.db.api.Put)101 Key (com.scalar.db.io.Key)85 Test (org.junit.jupiter.api.Test)83 GrpcTransaction (com.scalar.db.transaction.rpc.GrpcTransaction)39 IntValue (com.scalar.db.io.IntValue)36 GrpcTwoPhaseCommitTransaction (com.scalar.db.transaction.rpc.GrpcTwoPhaseCommitTransaction)32 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)29 Delete (com.scalar.db.api.Delete)28 TextValue (com.scalar.db.io.TextValue)24 Value (com.scalar.db.io.Value)19 BigIntValue (com.scalar.db.io.BigIntValue)16 Scanner (com.scalar.db.api.Scanner)15 ArrayList (java.util.ArrayList)14 BooleanValue (com.scalar.db.io.BooleanValue)11 ConditionalExpression (com.scalar.db.api.ConditionalExpression)10 ScanAll (com.scalar.db.api.ScanAll)9