Skip to content

Commit 1747d5e

Browse files
feeblefakieinv-jishnuypeckstadt
authored
Backport to branch(3) : Fix errorprone and Javadoc warnings (#2782)
Co-authored-by: inv-jishnu <[email protected]> Co-authored-by: Peckstadt Yves <[email protected]>
1 parent 8fbe2e4 commit 1747d5e

File tree

68 files changed

+457
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+457
-125
lines changed

data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommand.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
@CommandLine.Command(name = "export", description = "export data from a ScalarDB table")
4646
public class ExportCommand extends ExportCommandOptions implements Callable<Integer> {
4747

48-
private static final String EXPORT_FILE_NAME_FORMAT = "export.%s.%s.%s.%s";
4948
private static final Logger logger = LoggerFactory.getLogger(ExportCommand.class);
5049

5150
@Spec CommandSpec spec;
@@ -169,11 +168,8 @@ private String getOutputAbsoluteFilePath(
169168
String fileName =
170169
StringUtils.isBlank(outputFileName)
171170
? String.format(
172-
EXPORT_FILE_NAME_FORMAT,
173-
namespace,
174-
table,
175-
System.nanoTime(),
176-
outputFormat.toString().toLowerCase())
171+
"export.%s.%s.%s.%s",
172+
namespace, table, System.nanoTime(), outputFormat.toString().toLowerCase())
177173
: outputFileName;
178174

179175
if (StringUtils.isBlank(outputDirectory)) {

data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ScanOrderingConverter.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,31 @@
77
import java.util.stream.Collectors;
88
import picocli.CommandLine;
99

10+
/**
11+
* A {@link picocli.CommandLine.ITypeConverter} implementation that converts a comma-separated
12+
* string of column-order pairs into a list of {@link com.scalar.db.api.Scan.Ordering} objects.
13+
*
14+
* <p>This converter is used to parse CLI arguments for scan ordering in ScalarDB-based
15+
* applications. The input string must contain one or more key-value pairs in the format {@code
16+
* column=order}, separated by commas. The {@code order} must be a valid {@link
17+
* com.scalar.db.api.Scan.Ordering.Order} enum value, such as {@code ASC} or {@code DESC}
18+
* (case-insensitive).
19+
*
20+
* <p>Example input: {@code "name=asc,age=desc"} results in a list containing {@code
21+
* Scan.Ordering.asc("name")} and {@code Scan.Ordering.desc("age")}.
22+
*
23+
* <p>Invalid formats or unrecognized order values will result in an {@link
24+
* IllegalArgumentException}.
25+
*/
1026
public class ScanOrderingConverter implements CommandLine.ITypeConverter<List<Scan.Ordering>> {
1127
/**
12-
* Converts a comma-separated string of key-value pairs into a list of {@link Scan.Ordering}
13-
* objects. Each pair must be in the format "column=order", where "order" is a valid enum value of
14-
* {@link Scan.Ordering.Order} (e.g., ASC or DESC, case-insensitive).
28+
* Converts a comma-separated string of key-value pairs into a list of {@link
29+
* com.scalar.db.api.Scan.Ordering} objects. Each pair must be in the format "column=order", where
30+
* "order" is a valid enum value of {@link com.scalar.db.api.Scan.Ordering} (e.g., ASC or DESC,
31+
* case-insensitive).
1532
*
1633
* @param value the comma-separated key-value string to convert
17-
* @return a list of {@link Scan.Ordering} objects constructed from the input
34+
* @return a list of {@link com.scalar.db.api.Scan.Ordering} objects constructed from the input
1835
* @throws IllegalArgumentException if parsing fails due to invalid format or enum value
1936
*/
2037
@Override
@@ -26,7 +43,9 @@ public List<Scan.Ordering> convert(String value) {
2643
String columnName = entry.getKey();
2744
Scan.Ordering.Order sortOrder =
2845
Scan.Ordering.Order.valueOf(entry.getValue().trim().toUpperCase());
29-
return new Scan.Ordering(columnName, sortOrder);
46+
return sortOrder == Scan.Ordering.Order.ASC
47+
? Scan.Ordering.asc(columnName)
48+
: Scan.Ordering.desc(columnName);
3049
})
3150
.collect(Collectors.toList());
3251
}

data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/util/CommandLineInputUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class CommandLineInputUtils {
1313
* Parses a single key-value pair from a string in the format "key=value".
1414
*
1515
* @param keyValue the key-value string to parse
16-
* @return a {@link Map.Entry} representing the parsed key-value pair
16+
* @return a {@link java.util.Map.Entry} representing the parsed key-value pair
1717
* @throws IllegalArgumentException if the input is null, empty, or not in the expected format
1818
*/
1919
public static Map.Entry<String, String> parseKeyValue(String keyValue) {
@@ -50,7 +50,7 @@ public static String[] splitByDelimiter(String value, String delimiter, int limi
5050

5151
/**
5252
* Validates that a given integer value is positive. If the value is less than 1, it throws a
53-
* {@link CommandLine.ParameterException} with the specified error message.
53+
* {@link picocli.CommandLine.ParameterException} with the specified error message.
5454
*
5555
* @param commandLine the {@link CommandLine} instance used to provide context for the exception
5656
* @param value the integer value to validate

data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/command/dataexport/ScanOrderingConverterTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ void callConvert_withInvalidValue_shouldThrowException() {
2929
void callConvert_withValidValueAndOrderAscending_shouldReturnScanOrdering() {
3030
String value = "id=ASC,age=DESC";
3131
List<Scan.Ordering> expectedOrder = new ArrayList<>();
32-
expectedOrder.add(new Scan.Ordering("id", Scan.Ordering.Order.ASC));
33-
expectedOrder.add(new Scan.Ordering("age", Scan.Ordering.Order.DESC));
32+
expectedOrder.add(Scan.Ordering.asc("id"));
33+
expectedOrder.add(Scan.Ordering.desc("age"));
3434
Assertions.assertEquals(expectedOrder, scanOrderingConverter.convert(value));
3535
}
3636

3737
@Test
3838
void callConvert_withValidValueAndOrderDescending_shouldReturnScanOrdering() {
3939
String value = "id=desc";
40-
List<Scan.Ordering> expectedOrder =
41-
Collections.singletonList(new Scan.Ordering("id", Scan.Ordering.Order.DESC));
40+
List<Scan.Ordering> expectedOrder = Collections.singletonList(Scan.Ordering.desc("id"));
4241
Assertions.assertEquals(expectedOrder, scanOrderingConverter.convert(value));
4342
}
4443
}

data-loader/core/src/main/java/com/scalar/db/dataloader/core/ColumnInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* <p>This class holds the metadata for a column, including the namespace (schema), table name, and
1010
* the column name within the table.
1111
*/
12+
@SuppressWarnings("SameNameButDifferent")
1213
@Value
1314
@Builder
1415
public class ColumnInfo {

data-loader/core/src/main/java/com/scalar/db/dataloader/core/Constants.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,18 @@
22

33
/** The constants that are used in the com.scalar.dataloader.core package */
44
public class Constants {
5-
6-
public static final String IMPORT_LOG_ENTRY_STATUS_FIELD = "data_loader_import_status";
5+
/**
6+
* Format string used for table lookup keys. It expects two string arguments: the namespace and
7+
* the table name, respectively.
8+
*
9+
* <p>Example: {@code String.format(TABLE_LOOKUP_KEY_FORMAT, "ns", "table")} will result in
10+
* "ns.table".
11+
*/
712
public static final String TABLE_LOOKUP_KEY_FORMAT = "%s.%s";
8-
9-
public static final String LOG_UPDATE_SUCCESS = "Row %s has been updated in table %s.%s";
10-
public static final String LOG_INSERT_SUCCESS = "Row %s has been inserted into table %s.%s";
11-
public static final String LOG_IMPORT_VALIDATION = "Validating data for line %s ...";
12-
public static final String LOG_IMPORT_GET_DATA =
13-
"Retrieving existing data record from database ...";
14-
public static final String LOG_IMPORT_LINE_SUCCESS = "Row %s import is completed";
15-
public static final String LOG_IMPORT_LINE_FAILED = "Row %s import has failed: %s";
16-
public static final String LOG_IMPORT_COMPLETED =
17-
"The import process has been completed. Please check the success and failed output files for a detailed report";
18-
19-
public static final String LOG_SCANNING_START = "Retrieving data from %s.%s table ...";
20-
public static final String LOG_CONVERTING = "Converting %s.%s data to %s ...";
21-
public static final String MISSING_CSV_HEADERS =
22-
"Valid headers are not present or missing in the provided CSV file";
23-
public static final String ERROR_MISSING_SOURCE_FIELD =
24-
"the data mapping source field '%s' for table '%s' is missing in the json data record";
13+
/**
14+
* Status message used to indicate that a transaction was aborted as part of a batch transaction
15+
* failure.
16+
*/
2517
public static final String ABORT_TRANSACTION_STATUS =
2618
"Transaction aborted as part of batch transaction aborted";
2719
}

data-loader/core/src/main/java/com/scalar/db/dataloader/core/DataLoaderObjectMapper.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,29 @@
44
import com.fasterxml.jackson.databind.ObjectMapper;
55
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
66

7+
/**
8+
* A custom {@link ObjectMapper} used for data loading operations.
9+
*
10+
* <p>This mapper is configured to:
11+
*
12+
* <ul>
13+
* <li>Exclude {@code null} values during serialization
14+
* <li>Support Java 8 date/time types via {@link JavaTimeModule}
15+
* </ul>
16+
*
17+
* <p>It can be reused wherever consistent JSON serialization/deserialization behavior is needed.
18+
*/
719
public class DataLoaderObjectMapper extends ObjectMapper {
820

21+
/**
22+
* Constructs a {@code DataLoaderObjectMapper} with default settings, including:
23+
*
24+
* <ul>
25+
* <li>{@link com.fasterxml.jackson.annotation.JsonInclude.Include#NON_NULL} to skip {@code
26+
* null} values
27+
* <li>{@link JavaTimeModule} registration to handle Java 8 date/time types
28+
* </ul>
29+
*/
930
public DataLoaderObjectMapper() {
1031
super();
1132
this.setSerializationInclusion(JsonInclude.Include.NON_NULL);

data-loader/core/src/main/java/com/scalar/db/dataloader/core/DatabaseKeyType.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
/** Type of key in database */
44
public enum DatabaseKeyType {
5+
/** Represents a partition key, which determines the partition where the data is stored. */
56
PARTITION,
7+
8+
/** Represents a clustering key, which determines the order of data within a partition. */
69
CLUSTERING
710
}

data-loader/core/src/main/java/com/scalar/db/dataloader/core/FileFormat.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,21 @@
22

33
/** The available input and output formats for the data loader import and export commands */
44
public enum FileFormat {
5+
/**
6+
* JSON (JavaScript Object Notation) format. Typically, represents the entire dataset as a single
7+
* JSON array or object.
8+
*/
59
JSON,
10+
11+
/**
12+
* JSON Lines (JSONL) format. Each line is a separate JSON object, making it suitable for
13+
* streaming large datasets.
14+
*/
615
JSONL,
16+
17+
/**
18+
* CSV (Comma-Separated Values) format. A plain text format where each line represents a row and
19+
* columns are separated by commas.
20+
*/
721
CSV
822
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
package com.scalar.db.dataloader.core;
22

3-
/** The available modes a ScalarDB instance can run in */
3+
/**
4+
* The available modes a ScalarDB instance can run in. Determines how ScalarDB interacts with the
5+
* underlying database.
6+
*/
47
public enum ScalarDbMode {
8+
9+
/**
10+
* Storage mode: Operates directly on the underlying storage engine without transactional
11+
* guarantees. Suitable for raw data access and simple CRUD operations.
12+
*/
513
STORAGE,
14+
15+
/**
16+
* Transaction mode: Provides transaction management with ACID guarantees across multiple
17+
* operations. Suitable for applications that require consistency and atomicity.
18+
*/
619
TRANSACTION
720
}

0 commit comments

Comments
 (0)