Skip to content

Fix errorprone and Javadoc warnings #2614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
be9ee23
Initial commit
inv-jishnu Apr 10, 2025
89b9f05
Spotless applied again
inv-jishnu Apr 11, 2025
49c83b6
Removed unused code
inv-jishnu Apr 11, 2025
b2871fb
Merge branch 'master' into feat/data-loader/import-log-2
ypeckstadt Apr 15, 2025
c5c9c0a
Removed unused classes and references
inv-jishnu Apr 15, 2025
4964e8d
Merge branch 'master' into feat/data-loader/import-log-2
inv-jishnu Apr 15, 2025
ff81f5f
Merge branch 'master' into feat/data-loader/import-log-2
inv-jishnu Apr 15, 2025
3934c2a
Improve Javadocs
ypeckstadt Apr 16, 2025
9958f95
Changes
inv-jishnu Apr 21, 2025
1afbc21
Renamed parameters
inv-jishnu Apr 21, 2025
8c5114d
logging changes
inv-jishnu Apr 21, 2025
ffab395
removed repeated code
inv-jishnu Apr 22, 2025
79df1ed
Merge branch 'master' into feat/data-loader/import-log-2
inv-jishnu Apr 22, 2025
cf31672
Merge branch 'master' into feat/data-loader/import-log-2
brfrn169 Apr 23, 2025
6dd213e
Added excetpion throw
inv-jishnu Apr 23, 2025
6542177
Synchronisation changes
inv-jishnu Apr 25, 2025
603e46e
Added volatile back to fix spotbugs issue
inv-jishnu Apr 25, 2025
eaf9d88
Removed unused variable
inv-jishnu Apr 25, 2025
502034e
Chanaged LOGGER to logger
inv-jishnu Apr 30, 2025
6b22d1a
logger name change in test
inv-jishnu Apr 30, 2025
7d5ad8c
Fix warnings and rename logger
inv-jishnu Apr 30, 2025
afd58f4
Fix added for warning and supress warning added for lombok related wa…
inv-jishnu Apr 30, 2025
3652f10
Merged latest changes from master after resolving conflicts
inv-jishnu May 14, 2025
cc5365b
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu May 15, 2025
570ab38
Merge branch 'master' into fix/data-loader/logger-rename
ypeckstadt May 22, 2025
977c6af
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu May 27, 2025
bcc3547
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu May 28, 2025
37c7b3b
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu Jun 2, 2025
2be52e5
Resolved conflicts and merged changes from master
inv-jishnu Jun 9, 2025
2018640
Merge branch 'master' into fix/data-loader/logger-rename
ypeckstadt Jun 11, 2025
5fba851
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu Jun 11, 2025
3de9ad7
Added annotation for same name but different
inv-jishnu Jun 11, 2025
f5bb662
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu Jun 11, 2025
0f03536
Changd put to mutate
inv-jishnu Jun 11, 2025
bfad6d3
Removed constant formatter to fix warning
inv-jishnu Jun 11, 2025
be503d6
Revert "Changd put to mutate"
inv-jishnu Jun 12, 2025
ac03202
Changes
inv-jishnu Jun 12, 2025
862bbb2
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu Jun 12, 2025
eecf28a
Scan order updated
inv-jishnu Jun 13, 2025
7e3784b
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu Jun 13, 2025
e179656
Fixed symbol not found issue
inv-jishnu Jun 13, 2025
f75d31b
Javadoc related fixes
inv-jishnu Jun 13, 2025
06a4a9a
Java doc related changes -2
inv-jishnu Jun 13, 2025
db73e47
Javadoc changes and removed an unused file
inv-jishnu Jun 16, 2025
0d30850
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu Jun 16, 2025
a2756c1
Merge branch 'master' into fix/data-loader/logger-rename
inv-jishnu Jun 16, 2025
52824bc
Merge branch 'master' into fix/data-loader/logger-rename
brfrn169 Jun 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
@CommandLine.Command(name = "export", description = "export data from a ScalarDB table")
public class ExportCommand extends ExportCommandOptions implements Callable<Integer> {

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

@Spec CommandSpec spec;
Expand Down Expand Up @@ -169,11 +168,8 @@ private String getOutputAbsoluteFilePath(
String fileName =
StringUtils.isBlank(outputFileName)
? String.format(
EXPORT_FILE_NAME_FORMAT,
namespace,
table,
System.nanoTime(),
outputFormat.toString().toLowerCase())
"export.%s.%s.%s.%s",
namespace, table, System.nanoTime(), outputFormat.toString().toLowerCase())
: outputFileName;

if (StringUtils.isBlank(outputDirectory)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,31 @@
import java.util.stream.Collectors;
import picocli.CommandLine;

/**
* A {@link picocli.CommandLine.ITypeConverter} implementation that converts a comma-separated
* string of column-order pairs into a list of {@link com.scalar.db.api.Scan.Ordering} objects.
*
* <p>This converter is used to parse CLI arguments for scan ordering in ScalarDB-based
* applications. The input string must contain one or more key-value pairs in the format {@code
* column=order}, separated by commas. The {@code order} must be a valid {@link
* com.scalar.db.api.Scan.Ordering.Order} enum value, such as {@code ASC} or {@code DESC}
* (case-insensitive).
*
* <p>Example input: {@code "name=asc,age=desc"} results in a list containing {@code
* Scan.Ordering.asc("name")} and {@code Scan.Ordering.desc("age")}.
*
* <p>Invalid formats or unrecognized order values will result in an {@link
* IllegalArgumentException}.
*/
public class ScanOrderingConverter implements CommandLine.ITypeConverter<List<Scan.Ordering>> {
/**
* Converts a comma-separated string of key-value pairs into a list of {@link Scan.Ordering}
* objects. Each pair must be in the format "column=order", where "order" is a valid enum value of
* {@link Scan.Ordering.Order} (e.g., ASC or DESC, case-insensitive).
* Converts a comma-separated string of key-value pairs into a list of {@link
* com.scalar.db.api.Scan.Ordering} objects. Each pair must be in the format "column=order", where
* "order" is a valid enum value of {@link com.scalar.db.api.Scan.Ordering} (e.g., ASC or DESC,
* case-insensitive).
*
* @param value the comma-separated key-value string to convert
* @return a list of {@link Scan.Ordering} objects constructed from the input
* @return a list of {@link com.scalar.db.api.Scan.Ordering} objects constructed from the input
* @throws IllegalArgumentException if parsing fails due to invalid format or enum value
*/
@Override
Expand All @@ -26,7 +43,9 @@ public List<Scan.Ordering> convert(String value) {
String columnName = entry.getKey();
Scan.Ordering.Order sortOrder =
Scan.Ordering.Order.valueOf(entry.getValue().trim().toUpperCase());
return new Scan.Ordering(columnName, sortOrder);
return sortOrder == Scan.Ordering.Order.ASC
? Scan.Ordering.asc(columnName)
: Scan.Ordering.desc(columnName);
})
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CommandLineInputUtils {
* Parses a single key-value pair from a string in the format "key=value".
*
* @param keyValue the key-value string to parse
* @return a {@link Map.Entry} representing the parsed key-value pair
* @return a {@link java.util.Map.Entry} representing the parsed key-value pair
* @throws IllegalArgumentException if the input is null, empty, or not in the expected format
*/
public static Map.Entry<String, String> parseKeyValue(String keyValue) {
Expand Down Expand Up @@ -50,7 +50,7 @@ public static String[] splitByDelimiter(String value, String delimiter, int limi

/**
* Validates that a given integer value is positive. If the value is less than 1, it throws a
* {@link CommandLine.ParameterException} with the specified error message.
* {@link picocli.CommandLine.ParameterException} with the specified error message.
*
* @param commandLine the {@link CommandLine} instance used to provide context for the exception
* @param value the integer value to validate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ void callConvert_withInvalidValue_shouldThrowException() {
void callConvert_withValidValueAndOrderAscending_shouldReturnScanOrdering() {
String value = "id=ASC,age=DESC";
List<Scan.Ordering> expectedOrder = new ArrayList<>();
expectedOrder.add(new Scan.Ordering("id", Scan.Ordering.Order.ASC));
expectedOrder.add(new Scan.Ordering("age", Scan.Ordering.Order.DESC));
expectedOrder.add(Scan.Ordering.asc("id"));
expectedOrder.add(Scan.Ordering.desc("age"));
Assertions.assertEquals(expectedOrder, scanOrderingConverter.convert(value));
}

@Test
void callConvert_withValidValueAndOrderDescending_shouldReturnScanOrdering() {
String value = "id=desc";
List<Scan.Ordering> expectedOrder =
Collections.singletonList(new Scan.Ordering("id", Scan.Ordering.Order.DESC));
List<Scan.Ordering> expectedOrder = Collections.singletonList(Scan.Ordering.desc("id"));
Assertions.assertEquals(expectedOrder, scanOrderingConverter.convert(value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* <p>This class holds the metadata for a column, including the namespace (schema), table name, and
* the column name within the table.
*/
@SuppressWarnings("SameNameButDifferent")
@Value
@Builder
public class ColumnInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,18 @@

/** The constants that are used in the com.scalar.dataloader.core package */
public class Constants {

public static final String IMPORT_LOG_ENTRY_STATUS_FIELD = "data_loader_import_status";
/**
* Format string used for table lookup keys. It expects two string arguments: the namespace and
* the table name, respectively.
*
* <p>Example: {@code String.format(TABLE_LOOKUP_KEY_FORMAT, "ns", "table")} will result in
* "ns.table".
*/
public static final String TABLE_LOOKUP_KEY_FORMAT = "%s.%s";

public static final String LOG_UPDATE_SUCCESS = "Row %s has been updated in table %s.%s";
public static final String LOG_INSERT_SUCCESS = "Row %s has been inserted into table %s.%s";
public static final String LOG_IMPORT_VALIDATION = "Validating data for line %s ...";
public static final String LOG_IMPORT_GET_DATA =
"Retrieving existing data record from database ...";
public static final String LOG_IMPORT_LINE_SUCCESS = "Row %s import is completed";
public static final String LOG_IMPORT_LINE_FAILED = "Row %s import has failed: %s";
public static final String LOG_IMPORT_COMPLETED =
"The import process has been completed. Please check the success and failed output files for a detailed report";

public static final String LOG_SCANNING_START = "Retrieving data from %s.%s table ...";
public static final String LOG_CONVERTING = "Converting %s.%s data to %s ...";
public static final String MISSING_CSV_HEADERS =
"Valid headers are not present or missing in the provided CSV file";
public static final String ERROR_MISSING_SOURCE_FIELD =
"the data mapping source field '%s' for table '%s' is missing in the json data record";
/**
* Status message used to indicate that a transaction was aborted as part of a batch transaction
* failure.
*/
public static final String ABORT_TRANSACTION_STATUS =
"Transaction aborted as part of batch transaction aborted";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,29 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

/**
* A custom {@link ObjectMapper} used for data loading operations.
*
* <p>This mapper is configured to:
*
* <ul>
* <li>Exclude {@code null} values during serialization
* <li>Support Java 8 date/time types via {@link JavaTimeModule}
* </ul>
*
* <p>It can be reused wherever consistent JSON serialization/deserialization behavior is needed.
*/
public class DataLoaderObjectMapper extends ObjectMapper {

/**
* Constructs a {@code DataLoaderObjectMapper} with default settings, including:
*
* <ul>
* <li>{@link com.fasterxml.jackson.annotation.JsonInclude.Include#NON_NULL} to skip {@code
* null} values
* <li>{@link JavaTimeModule} registration to handle Java 8 date/time types
* </ul>
*/
public DataLoaderObjectMapper() {
super();
this.setSerializationInclusion(JsonInclude.Include.NON_NULL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

/** Type of key in database */
public enum DatabaseKeyType {
/** Represents a partition key, which determines the partition where the data is stored. */
PARTITION,

/** Represents a clustering key, which determines the order of data within a partition. */
CLUSTERING
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@

/** The available input and output formats for the data loader import and export commands */
public enum FileFormat {
/**
* JSON (JavaScript Object Notation) format. Typically, represents the entire dataset as a single
* JSON array or object.
*/
JSON,

/**
* JSON Lines (JSONL) format. Each line is a separate JSON object, making it suitable for
* streaming large datasets.
*/
JSONL,

/**
* CSV (Comma-Separated Values) format. A plain text format where each line represents a row and
* columns are separated by commas.
*/
CSV
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
package com.scalar.db.dataloader.core;

/** The available modes a ScalarDB instance can run in */
/**
* The available modes a ScalarDB instance can run in. Determines how ScalarDB interacts with the
* underlying database.
*/
public enum ScalarDbMode {

/**
* Storage mode: Operates directly on the underlying storage engine without transactional
* guarantees. Suitable for raw data access and simple CRUD operations.
*/
STORAGE,

/**
* Transaction mode: Provides transaction management with ACID guarantees across multiple
* operations. Suitable for applications that require consistency and atomicity.
*/
TRANSACTION
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import com.scalar.db.io.Key;
import lombok.Value;

/** * The scan range which is used in data export scan filtering */
/** The scan range which is used in data export scan filtering */
@SuppressWarnings("SameNameButDifferent")
@Value
public class ScanRange {
/** The key for scan start filter */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@
import java.util.Iterator;
import java.util.List;

/** Export manager implementation which manages the export task that exports data in CSV format */
public class CsvExportManager extends ExportManager {

/**
* Constructs a {@code CsvExportManager} with the specified {@link DistributedStorage}, {@link
* ScalarDbDao}, and {@link ProducerTaskFactory}.
*
* @param storage the {@code DistributedStorage} instance used to read data from the database
* @param dao the {@code ScalarDbDao} used to execute export-related database operations
* @param producerTaskFactory the factory used to create producer tasks for exporting data
*/
public CsvExportManager(
DistributedStorage storage, ScalarDbDao dao, ProducerTaskFactory producerTaskFactory) {
super(storage, dao, producerTaskFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Export manager class which manages the export task */
@SuppressWarnings({"SameNameButDifferent", "FutureReturnValueIgnored"})
@RequiredArgsConstructor
public abstract class ExportManager {
private static final Logger logger = LoggerFactory.getLogger(ExportManager.class);
Expand Down Expand Up @@ -64,6 +66,7 @@ abstract void processFooter(
* @param exportOptions Export options
* @param tableMetadata Metadata for a single ScalarDB table
* @param writer Writer to write the exported data
* @return export report object containing data such as total exported row count
*/
public ExportReport startExport(
ExportOptions exportOptions, TableMetadata tableMetadata, Writer writer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import lombok.Builder;
import lombok.Data;

/** Options for a ScalarDB export data operation */
@SuppressWarnings("SameNameButDifferent")
/** Options for a ScalarDB export data operation. */
@SuppressWarnings({"SameNameButDifferent", "MissingSummary"})
@Builder(builderMethodName = "hiddenBuilder")
@Data
public class ExportOptions {
Expand All @@ -31,6 +31,15 @@ public class ExportOptions {
@Builder.Default private List<String> projectionColumns = Collections.emptyList();
private List<Scan.Ordering> sortOrders;

/**
* Generates and returns an export options builder.
*
* @param namespace namespaces for export
* @param tableName tableName for export
* @param scanPartitionKey scan partition key for export
* @param outputFileFormat output file format for export
* @return a configured export options builder
*/
public static ExportOptionsBuilder builder(
String namespace, String tableName, Key scanPartitionKey, FileFormat outputFileFormat) {
return hiddenBuilder()
Expand All @@ -39,4 +48,13 @@ public static ExportOptionsBuilder builder(
.scanPartitionKey(scanPartitionKey)
.outputFileFormat(outputFileFormat);
}

/**
* Explicit builder class declaration required for Javadoc generation.
*
* <p>Although Lombok generates this builder class automatically, Javadoc requires an explicit
* declaration to resolve references in the generated documentation, especially when using a
* custom builder method name (e.g., {@code hiddenBuilder()}).
*/
public static class ExportOptionsBuilder {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ public class ExportReport {
*/
private final LongAdder exportedRowCount = new LongAdder();

/**
* Returns the total number of rows that have been exported so far.
*
* @return the cumulative exported row count
*/
public long getExportedRowCount() {
return exportedRowCount.sum();
}

/**
* Increments the exported row count by the specified value.
*
* @param count the number of rows to add to the exported count
*/
public void updateExportedRowCount(long count) {
this.exportedRowCount.add(count);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@
import java.io.IOException;
import java.io.Writer;

/** Export manager implementation which manages the export task that exports data in JSON format */
public class JsonExportManager extends ExportManager {

/**
* Constructs a {@code JsonExportManager} with the specified {@link DistributedStorage}, {@link
* ScalarDbDao}, and {@link ProducerTaskFactory}.
*
* @param storage the {@code DistributedStorage} instance used to read data from the database
* @param dao the {@code ScalarDbDao} used to execute export-related database operations
* @param producerTaskFactory the factory used to create producer tasks for exporting data
*/
public JsonExportManager(
DistributedStorage storage, ScalarDbDao dao, ProducerTaskFactory producerTaskFactory) {
super(storage, dao, producerTaskFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@
import java.io.IOException;
import java.io.Writer;

/**
* Export manager implementation which manages the export task that exports data in JSONLines format
*/
public class JsonLineExportManager extends ExportManager {

/**
* Constructs a {@code JsonLineExportManager} with the specified {@link DistributedStorage},
* {@link ScalarDbDao}, and {@link ProducerTaskFactory}.
*
* @param storage the {@code DistributedStorage} instance used to read data from the database
* @param dao the {@code ScalarDbDao} used to execute export-related database operations
* @param producerTaskFactory the factory used to create producer tasks for exporting data
*/
public JsonLineExportManager(
DistributedStorage storage, ScalarDbDao dao, ProducerTaskFactory producerTaskFactory) {
super(storage, dao, producerTaskFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class CsvProducerTask extends ProducerTask {
* Class constructor
*
* @param includeMetadata Include metadata in the exported data
* @param projectColumns list of columns that is required in export data
* @param tableMetadata Metadata for a single ScalarDB table
* @param columnDataTypes Map of data types for the all columns in a ScalarDB table
* @param delimiter Delimiter used in csv content
Expand Down
Loading