Search in sources :

Example 11 with DataType

use of com.scalar.db.io.DataType in project scalardb by scalar-labs.

the class StorageSinglePartitionKeyIntegrationTestBase method createTables.

private void createTables() throws ExecutionException {
    Map<String, String> options = getCreateOptions();
    admin.createNamespace(namespace, true, options);
    for (DataType partitionKeyType : partitionKeyTypes) {
        createTable(partitionKeyType, options);
    }
}
Also used : DataType(com.scalar.db.io.DataType)

Example 12 with DataType

use of com.scalar.db.io.DataType in project scalardb by scalar-labs.

the class ResultInterpreter method getValue.

@Nullable
private Value<?> getValue(String name, ResultSet resultSet) throws SQLException {
    Value<?> ret;
    DataType dataType = metadata.getColumnDataType(name);
    switch(dataType) {
        case BOOLEAN:
            ret = new BooleanValue(name, resultSet.getBoolean(name));
            break;
        case INT:
            ret = new IntValue(name, resultSet.getInt(name));
            break;
        case BIGINT:
            ret = new BigIntValue(name, resultSet.getLong(name));
            break;
        case FLOAT:
            // To handle Float.MAX_VALUE in MySQL, we need to get the value as double, then cast it to
            // float
            ret = new FloatValue(name, (float) resultSet.getDouble(name));
            break;
        case DOUBLE:
            ret = new DoubleValue(name, resultSet.getDouble(name));
            break;
        case TEXT:
            ret = new TextValue(name, resultSet.getString(name));
            break;
        case BLOB:
            ret = new BlobValue(name, resultSet.getBytes(name));
            break;
        default:
            throw new AssertionError();
    }
    if (resultSet.wasNull()) {
        return null;
    }
    return ret;
}
Also used : DoubleValue(com.scalar.db.io.DoubleValue) TextValue(com.scalar.db.io.TextValue) BooleanValue(com.scalar.db.io.BooleanValue) DataType(com.scalar.db.io.DataType) FloatValue(com.scalar.db.io.FloatValue) IntValue(com.scalar.db.io.IntValue) BigIntValue(com.scalar.db.io.BigIntValue) BigIntValue(com.scalar.db.io.BigIntValue) BlobValue(com.scalar.db.io.BlobValue) Nullable(javax.annotation.Nullable)

Example 13 with DataType

use of com.scalar.db.io.DataType in project scalardb by scalar-labs.

the class DistributedStorageMultipleClusteringKeyScanIntegrationTestBase method executeInParallel.

private void executeInParallel(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;
            });
        }
    }
    executeInParallel(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 14 with DataType

use of com.scalar.db.io.DataType in project scalardb by scalar-labs.

the class DistributedStorageMultipleClusteringKeyScanIntegrationTestBase method executeInParallel.

private void executeInParallel(TestForSecondClusteringKeyScan test) throws java.util.concurrent.ExecutionException, InterruptedException {
    List<Callable<Void>> testCallables = new ArrayList<>();
    for (DataType firstClusteringKeyType : clusteringKeyTypes.keySet()) {
        for (DataType secondClusteringKeyType : clusteringKeyTypes.get(firstClusteringKeyType)) {
            for (Order firstClusteringOrder : Order.values()) {
                for (Order secondClusteringOrder : Order.values()) {
                    testCallables.add(() -> {
                        truncateTable(firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder);
                        List<ClusteringKey> clusteringKeys = prepareRecords(firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder);
                        test.execute(clusteringKeys, firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder);
                        return null;
                    });
                }
            }
        }
    }
    executeInParallel(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 15 with DataType

use of com.scalar.db.io.DataType in project scalardb by scalar-labs.

the class DistributedStorageMultipleClusteringKeyScanIntegrationTestBase method createTables.

private void createTables() throws java.util.concurrent.ExecutionException, InterruptedException {
    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.
    executeInParallel(testCallables.subList(0, 1));
    executeInParallel(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)

Aggregations

DataType (com.scalar.db.io.DataType)52 Order (com.scalar.db.api.Scan.Ordering.Order)30 Value (com.scalar.db.io.Value)18 Test (org.junit.jupiter.api.Test)16 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 Callable (java.util.concurrent.Callable)12 Key (com.scalar.db.io.Key)6 Result (com.scalar.db.api.Result)5 Scan (com.scalar.db.api.Scan)3 Delete (com.scalar.db.api.Delete)2 Get (com.scalar.db.api.Get)2 TableMetadata (com.scalar.db.api.TableMetadata)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Ordering (com.scalar.db.api.Scan.Ordering)1 ExecutionException (com.scalar.db.exception.storage.ExecutionException)1 BigIntValue (com.scalar.db.io.BigIntValue)1 BlobValue (com.scalar.db.io.BlobValue)1