Search in sources :

Example 26 with Order

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

the class StorageSingleClusteringKeyScanIntegrationTestBase method scan_WithClusteringKeyEndRange_ShouldReturnProperResult.

@Test
public void scan_WithClusteringKeyEndRange_ShouldReturnProperResult() throws ExecutionException, IOException {
    for (DataType clusteringKeyType : clusteringKeyTypes) {
        for (Order clusteringOrder : Order.values()) {
            truncateTable(clusteringKeyType, clusteringOrder);
            List<Value<?>> clusteringKeyValues = prepareRecords(clusteringKeyType, clusteringOrder);
            for (boolean endInclusive : Arrays.asList(true, false)) {
                for (OrderingType orderingType : OrderingType.values()) {
                    for (boolean withLimit : Arrays.asList(false, true)) {
                        scan_WithClusteringKeyEndRange_ShouldReturnProperResult(clusteringKeyValues, clusteringKeyType, clusteringOrder, endInclusive, orderingType, withLimit);
                    }
                }
            }
        }
    }
}
Also used : Order(com.scalar.db.api.Scan.Ordering.Order) Value(com.scalar.db.io.Value) DataType(com.scalar.db.io.DataType) Test(org.junit.Test)

Example 27 with Order

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

the class StorageMultipleClusteringKeyScanIntegrationTestBase method execute.

private void execute(TestForFirstClusteringKeyScan test) throws java.util.concurrent.ExecutionException, InterruptedException {
    List<Callable<Void>> testCallables = new ArrayList<>();
    for (DataType firstClusteringKeyType : clusteringKeyTypes.keySet()) {
        for (Order firstClusteringOrder : Order.values()) {
            testCallables.add(() -> {
                truncateTable(firstClusteringKeyType, firstClusteringOrder, DataType.INT, Order.ASC);
                List<ClusteringKey> clusteringKeys = prepareRecords(firstClusteringKeyType, firstClusteringOrder, DataType.INT, Order.ASC);
                test.execute(clusteringKeys, firstClusteringKeyType, firstClusteringOrder);
                return null;
            });
        }
    }
    execute(testCallables);
}
Also used : Order(com.scalar.db.api.Scan.Ordering.Order) ArrayList(java.util.ArrayList) DataType(com.scalar.db.io.DataType) Callable(java.util.concurrent.Callable)

Example 28 with Order

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

the class StorageMultipleClusteringKeyScanIntegrationTestBase method deleteTables.

private static void deleteTables() throws java.util.concurrent.ExecutionException, InterruptedException {
    List<Callable<Void>> testCallables = new ArrayList<>();
    for (DataType firstClusteringKeyType : clusteringKeyTypes.keySet()) {
        Callable<Void> testCallable = () -> {
            for (DataType secondClusteringKeyType : clusteringKeyTypes.get(firstClusteringKeyType)) {
                for (Order firstClusteringOrder : Order.values()) {
                    for (Order secondClusteringOrder : Order.values()) {
                        admin.dropTable(getNamespaceName(firstClusteringKeyType), getTableName(firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder));
                    }
                }
            }
            admin.dropNamespace(getNamespaceName(firstClusteringKeyType));
            return null;
        };
        testCallables.add(testCallable);
    }
    // We firstly execute the callables without the last one. And then we execute the last one. This
    // is because the last table deletion deletes the metadata table, and this process can't be
    // handled in multiple threads/processes at the same time.
    execute(testCallables.subList(0, testCallables.size() - 1));
    execute(testCallables.subList(testCallables.size() - 1, testCallables.size()));
}
Also used : Order(com.scalar.db.api.Scan.Ordering.Order) ArrayList(java.util.ArrayList) DataType(com.scalar.db.io.DataType) Callable(java.util.concurrent.Callable)

Example 29 with Order

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

the class StorageMultipleClusteringKeyScanIntegrationTestBase method createTables.

private void createTables() throws InterruptedException, java.util.concurrent.ExecutionException {
    List<Callable<Void>> testCallables = new ArrayList<>();
    Map<String, String> options = getCreateOptions();
    for (DataType firstClusteringKeyType : clusteringKeyTypes.keySet()) {
        Callable<Void> testCallable = () -> {
            admin.createNamespace(getNamespaceName(firstClusteringKeyType), true, options);
            for (DataType secondClusteringKeyType : clusteringKeyTypes.get(firstClusteringKeyType)) {
                for (Order firstClusteringOrder : Order.values()) {
                    for (Order secondClusteringOrder : Order.values()) {
                        createTable(firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder, options);
                    }
                }
            }
            return null;
        };
        testCallables.add(testCallable);
    }
    // We firstly execute the first one and then the rest. This is because the first table creation
    // creates the metadata table, and this process can't be handled in multiple threads/processes
    // at the same time.
    execute(testCallables.subList(0, 1));
    execute(testCallables.subList(1, testCallables.size()));
}
Also used : Order(com.scalar.db.api.Scan.Ordering.Order) ArrayList(java.util.ArrayList) DataType(com.scalar.db.io.DataType) Callable(java.util.concurrent.Callable)

Example 30 with Order

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

the class StorageSingleClusteringKeyScanIntegrationTestBase method scan_WithClusteringKeyRangeWithSameValues_ShouldReturnProperResult.

@Test
public void scan_WithClusteringKeyRangeWithSameValues_ShouldReturnProperResult() throws ExecutionException, IOException {
    for (DataType clusteringKeyType : clusteringKeyTypes) {
        for (Order clusteringOrder : Order.values()) {
            truncateTable(clusteringKeyType, clusteringOrder);
            List<Value<?>> clusteringKeyValues = prepareRecords(clusteringKeyType, clusteringOrder);
            for (boolean startInclusive : Arrays.asList(true, false)) {
                for (boolean endInclusive : Arrays.asList(true, false)) {
                    for (OrderingType orderingType : OrderingType.values()) {
                        for (boolean withLimit : Arrays.asList(false, true)) {
                            scan_WithClusteringKeyRangeWithSameValues_ShouldReturnProperResult(clusteringKeyValues, clusteringKeyType, clusteringOrder, startInclusive, endInclusive, orderingType, withLimit);
                        }
                    }
                }
            }
        }
    }
}
Also used : Order(com.scalar.db.api.Scan.Ordering.Order) Value(com.scalar.db.io.Value) DataType(com.scalar.db.io.DataType) Test(org.junit.Test)

Aggregations

Order (com.scalar.db.api.Scan.Ordering.Order)33 DataType (com.scalar.db.io.DataType)30 Value (com.scalar.db.io.Value)17 ArrayList (java.util.ArrayList)12 Test (org.junit.jupiter.api.Test)12 Callable (java.util.concurrent.Callable)8 Test (org.junit.Test)8 Key (com.scalar.db.io.Key)4 HashMap (java.util.HashMap)4 ComparisonChain (com.google.common.collect.ComparisonChain)1 ImmutableList (com.google.common.collect.ImmutableList)1 Ordering (com.google.common.collect.Ordering)1 UnsignedBytes (com.google.common.primitives.UnsignedBytes)1 BigIntValue (com.scalar.db.io.BigIntValue)1 BlobValue (com.scalar.db.io.BlobValue)1 BooleanValue (com.scalar.db.io.BooleanValue)1 DoubleValue (com.scalar.db.io.DoubleValue)1 FloatValue (com.scalar.db.io.FloatValue)1 IntValue (com.scalar.db.io.IntValue)1 TextValue (com.scalar.db.io.TextValue)1