Skip to content

Commit

Permalink
Refactor to partially remove deprecated Value classes usage (#2328)
Browse files Browse the repository at this point in the history
  • Loading branch information
Torch3333 authored Nov 7, 2024
1 parent b4170b4 commit 8c82415
Show file tree
Hide file tree
Showing 33 changed files with 882 additions and 1,124 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.scalar.db.storage.dynamo;

import com.scalar.db.api.DistributedStorageColumnValueIntegrationTestBase;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import com.scalar.db.io.Value;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
Expand All @@ -20,26 +20,27 @@ protected Map<String, String> getCreationOptions() {
}

@Override
protected Value<?> getRandomValue(Random random, String columnName, DataType dataType) {
protected Column<?> getColumnWithRandomValue(
Random random, String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getRandomDynamoDoubleValue(random, columnName);
}
return super.getRandomValue(random, columnName, dataType);
return super.getColumnWithRandomValue(random, columnName, dataType);
}

@Override
protected Value<?> getMinValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMinValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMinDynamoDoubleValue(columnName);
}
return super.getMinValue(columnName, dataType);
return super.getColumnWithMinValue(columnName, dataType);
}

@Override
protected Value<?> getMaxValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMaxDynamoDoubleValue(columnName);
}
return super.getMaxValue(columnName, dataType);
return super.getColumnWithMaxValue(columnName, dataType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.scalar.db.api.DistributedStorageMultipleClusteringKeyScanIntegrationTestBase;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import com.scalar.db.io.Value;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
Expand Down Expand Up @@ -41,26 +41,27 @@ protected Map<String, String> getCreationOptions() {
}

@Override
protected Value<?> getRandomValue(Random random, String columnName, DataType dataType) {
protected Column<?> getColumnWithRandomValue(
Random random, String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getRandomDynamoDoubleValue(random, columnName);
}
return super.getRandomValue(random, columnName, dataType);
return super.getColumnWithRandomValue(random, columnName, dataType);
}

@Override
protected Value<?> getMinValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMinValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMinDynamoDoubleValue(columnName);
}
return super.getMinValue(columnName, dataType);
return super.getColumnWithMinValue(columnName, dataType);
}

@Override
protected Value<?> getMaxValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMaxDynamoDoubleValue(columnName);
}
return super.getMaxValue(columnName, dataType);
return super.getColumnWithMaxValue(columnName, dataType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.scalar.db.api.DistributedStorageMultiplePartitionKeyIntegrationTestBase;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import com.scalar.db.io.Value;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
Expand Down Expand Up @@ -37,26 +37,27 @@ protected ListMultimap<DataType, DataType> getPartitionKeyTypes() {
}

@Override
protected Value<?> getRandomValue(Random random, String columnName, DataType dataType) {
protected Column<?> getColumnWithRandomValue(
Random random, String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getRandomDynamoDoubleValue(random, columnName);
}
return super.getRandomValue(random, columnName, dataType);
return super.getColumnWithRandomValue(random, columnName, dataType);
}

@Override
protected Value<?> getMinValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMinValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMinDynamoDoubleValue(columnName);
}
return super.getMinValue(columnName, dataType);
return super.getColumnWithMinValue(columnName, dataType);
}

@Override
protected Value<?> getMaxValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMaxDynamoDoubleValue(columnName);
}
return super.getMaxValue(columnName, dataType);
return super.getColumnWithMaxValue(columnName, dataType);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.scalar.db.storage.dynamo;

import com.scalar.db.api.DistributedStorageSecondaryIndexIntegrationTestBase;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import com.scalar.db.io.Value;
import com.scalar.db.util.TestUtils;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -36,28 +36,29 @@ protected Map<String, String> getCreationOptions() {
}

@Override
protected Value<?> getRandomValue(Random random, String columnName, DataType dataType) {
protected Column<?> getColumnWithRandomValue(
Random random, String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getRandomDynamoDoubleValue(random, columnName);
}
// don't allow empty value since secondary index cannot contain empty value
return TestUtils.getRandomValue(random, columnName, dataType, false);
return TestUtils.getColumnWithRandomValue(random, columnName, dataType, false);
}

@Override
protected Value<?> getMinValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMinValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMinDynamoDoubleValue(columnName);
}
// don't allow empty value since secondary index cannot contain empty value
return TestUtils.getMinValue(columnName, dataType, false);
return TestUtils.getColumnWithMinValue(columnName, dataType, false);
}

@Override
protected Value<?> getMaxValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMaxDynamoDoubleValue(columnName);
}
return super.getMaxValue(columnName, dataType);
return super.getColumnWithMaxValue(columnName, dataType);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.scalar.db.storage.dynamo;

import com.scalar.db.api.DistributedStorageSingleClusteringKeyScanIntegrationTestBase;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import com.scalar.db.io.Value;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -36,26 +36,27 @@ protected Map<String, String> getCreationOptions() {
}

@Override
protected Value<?> getRandomValue(Random random, String columnName, DataType dataType) {
protected Column<?> getColumnWithRandomValue(
Random random, String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getRandomDynamoDoubleValue(random, columnName);
}
return super.getRandomValue(random, columnName, dataType);
return super.getColumnWithRandomValue(random, columnName, dataType);
}

@Override
protected Value<?> getMinValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMinValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMinDynamoDoubleValue(columnName);
}
return super.getMinValue(columnName, dataType);
return super.getColumnWithMinValue(columnName, dataType);
}

@Override
protected Value<?> getMaxValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMaxDynamoDoubleValue(columnName);
}
return super.getMaxValue(columnName, dataType);
return super.getColumnWithMaxValue(columnName, dataType);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.scalar.db.storage.dynamo;

import com.scalar.db.api.DistributedStorageSinglePartitionKeyIntegrationTestBase;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import com.scalar.db.io.Value;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
Expand All @@ -20,26 +20,27 @@ protected Map<String, String> getCreationOptions() {
}

@Override
protected Value<?> getRandomValue(Random random, String columnName, DataType dataType) {
protected Column<?> getColumnWithRandomValue(
Random random, String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getRandomDynamoDoubleValue(random, columnName);
}
return super.getRandomValue(random, columnName, dataType);
return super.getColumnWithRandomValue(random, columnName, dataType);
}

@Override
protected Value<?> getMinValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMinValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMinDynamoDoubleValue(columnName);
}
return super.getMinValue(columnName, dataType);
return super.getColumnWithMinValue(columnName, dataType);
}

@Override
protected Value<?> getMaxValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType) {
if (dataType == DataType.DOUBLE) {
return DynamoTestUtils.getMaxDynamoDoubleValue(columnName);
}
return super.getMaxValue(columnName, dataType);
return super.getColumnWithMaxValue(columnName, dataType);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.scalar.db.storage.dynamo;

import com.scalar.db.io.DoubleColumn;
import com.scalar.db.io.DoubleValue;
import java.util.Random;

public final class DynamoTestUtils {
Expand All @@ -11,8 +10,8 @@ public final class DynamoTestUtils {

private DynamoTestUtils() {}

public static DoubleValue getRandomDynamoDoubleValue(Random random, String columnName) {
return new DoubleValue(columnName, nextDynamoDouble(random));
public static DoubleColumn getRandomDynamoDoubleValue(Random random, String columnName) {
return DoubleColumn.of(columnName, nextDynamoDouble(random));
}

public static DoubleColumn getRandomDynamoDoubleColumn(Random random, String columnName) {
Expand All @@ -27,11 +26,11 @@ public static double nextDynamoDouble(Random random) {
.orElse(0.0d);
}

public static DoubleValue getMinDynamoDoubleValue(String columnName) {
return new DoubleValue(columnName, MIN_DYNAMO_DOUBLE_VALUE);
public static DoubleColumn getMinDynamoDoubleValue(String columnName) {
return DoubleColumn.of(columnName, MIN_DYNAMO_DOUBLE_VALUE);
}

public static DoubleValue getMaxDynamoDoubleValue(String columnName) {
return new DoubleValue(columnName, MAX_DYNAMO_DOUBLE_VALUE);
public static DoubleColumn getMaxDynamoDoubleValue(String columnName) {
return DoubleColumn.of(columnName, MAX_DYNAMO_DOUBLE_VALUE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.scalar.db.api.DistributedStorageColumnValueIntegrationTestBase;
import com.scalar.db.config.DatabaseConfig;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import com.scalar.db.io.Value;
import com.scalar.db.util.TestUtils;
import java.util.Properties;
import java.util.Random;
Expand All @@ -22,31 +22,32 @@ protected Properties getProperties(String testName) {
}

@Override
protected Value<?> getRandomValue(Random random, String columnName, DataType dataType) {
protected Column<?> getColumnWithRandomValue(
Random random, String columnName, DataType dataType) {
if (JdbcTestUtils.isOracle(rdbEngine)) {
if (dataType == DataType.DOUBLE) {
return JdbcTestUtils.getRandomOracleDoubleValue(random, columnName);
}
// don't allow empty value since Oracle treats empty value as NULL
return TestUtils.getRandomValue(random, columnName, dataType, false);
return TestUtils.getColumnWithRandomValue(random, columnName, dataType, false);
}
return super.getRandomValue(random, columnName, dataType);
return super.getColumnWithRandomValue(random, columnName, dataType);
}

@Override
protected Value<?> getMinValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMinValue(String columnName, DataType dataType) {
if (JdbcTestUtils.isOracle(rdbEngine)) {
if (dataType == DataType.DOUBLE) {
return JdbcTestUtils.getMinOracleDoubleValue(columnName);
}
// don't allow empty value since Oracle treats empty value as NULL
return TestUtils.getMinValue(columnName, dataType, false);
return TestUtils.getColumnWithMinValue(columnName, dataType, false);
}
return super.getMinValue(columnName, dataType);
return super.getColumnWithMinValue(columnName, dataType);
}

@Override
protected Value<?> getMaxValue(String columnName, DataType dataType) {
protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType) {
if (JdbcTestUtils.isOracle(rdbEngine)) {
if (dataType == DataType.DOUBLE) {
return JdbcTestUtils.getMaxOracleDoubleValue(columnName);
Expand All @@ -57,6 +58,6 @@ protected Value<?> getMaxValue(String columnName, DataType dataType) {
return JdbcTestUtils.getMaxSqlServerTextValue(columnName);
}
}
return super.getMaxValue(columnName, dataType);
return super.getColumnWithMaxValue(columnName, dataType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.scalar.db.config.DatabaseConfig;
import com.scalar.db.io.Column;
import com.scalar.db.io.DataType;
import com.scalar.db.util.ScalarDbUtils;
import java.util.Properties;
import java.util.Random;

Expand Down Expand Up @@ -33,7 +32,7 @@ protected int getThreadNum() {
protected Column<?> getRandomColumn(Random random, String columnName, DataType dataType) {
if (JdbcTestUtils.isOracle(rdbEngine)) {
if (dataType == DataType.DOUBLE) {
return ScalarDbUtils.toColumn(JdbcTestUtils.getRandomOracleDoubleValue(random, columnName));
return JdbcTestUtils.getRandomOracleDoubleValue(random, columnName);
}
}
return super.getRandomColumn(random, columnName, dataType);
Expand Down
Loading

0 comments on commit 8c82415

Please sign in to comment.