Skip to content

Conversation

@ypeckstadt
Copy link
Contributor

@ypeckstadt ypeckstadt commented Nov 7, 2025

Description

This PR fixes a problem with the --max-threads argument being required when it should not be. I have to double-check, but I think this is a regression issue that was introduced in version 3.16.1. This PR fixes the issue by ensuring it is not required and that a proper default value is set.

To avoid this from happening again, this PR adds extra tests as well and makes sure this problem is covered in both the Core and the CLI core.

Related issues and/or PRs

NA

Changes made

  • Replace the int type for the argument with Integer so it can properly be null-checked
  • Fixed the 16 default value that was set on import max threads. It should be the same run time based default value that is commonly used.
  • Assign the correct default value for both import and export max threads argument
  • Made sure the default value is set properly, and in an easier way, in the Core code as well
  • Added unit tests for both CLI and Core code usage

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

This PR exposes a problem with the other CLI code. It needs to update the usage for other integer-based arguments as well and switch to Integer where required. This will be handled in a separate PR.

Release notes

Fixed incorrect validation causing maxThreads to be treated as required

Copilot AI review requested due to automatic review settings November 7, 2025 07:25
@ypeckstadt ypeckstadt self-assigned this Nov 7, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ypeckstadt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical regression where the --max-threads command-line argument was incorrectly enforced as mandatory for data export and import operations. The fix ensures that this argument is now optional, providing a robust default value based on the system's available processors when not specified by the user. The changes also include updated data types for command options and comprehensive new tests to validate the correct behavior and prevent similar issues in the future.

Highlights

  • Bug Fix: Optional maxThreads Argument: The --max-threads argument for both data export and import commands is no longer treated as a required parameter, fixing a regression introduced in version 3.16.1.
  • Default Value for maxThreads: If --max-threads is not explicitly provided, it now defaults to the number of available processors on the system, ensuring optimal parallel processing without user intervention.
  • Type Change for CLI Options: The maxThreads field in ExportCommandOptions and ImportCommandOptions has been changed from int to Integer to correctly represent its optional nature (allowing null when not specified).
  • Enhanced Test Coverage: New unit tests have been added for both ExportCommand and ImportCommand in the CLI, as well as for ExportOptions and ImportOptions in the core, to prevent future regressions related to maxThreads handling and default values.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes an issue where the --max-threads argument was incorrectly treated as required. The solution, changing the argument's type from int to Integer in the CLI options to allow for null values and then applying a default, is sound and has been applied consistently across both ExportCommand and ImportCommand. The related core options classes have also been refactored to handle default values more cleanly using @Builder.Default, and the accompanying tests are a great addition. My review includes a few suggestions to enhance maintainability by addressing duplicated code in the command classes and improving the robustness of the new CLI tests, which currently duplicate some implementation logic.

@ypeckstadt ypeckstadt requested review from a team, Torch3333, brfrn169, feeblefakie and komamitsu and removed request for a team November 7, 2025 07:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the default value handling for the maximum number of threads used in import and export operations, setting it to the number of available processors instead of a hardcoded value.

  • Changed maxThreads/maxThreadCount fields to use @Builder.Default with Runtime.getRuntime().availableProcessors()
  • Updated CLI command classes to use Integer instead of int for proper null handling
  • Added comprehensive test coverage for both programmatic builder usage and CLI argument parsing

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ImportOptions.java Added @Builder.Default annotation to maxThreads field with dynamic default value
ExportOptions.java Added @Builder.Default annotation to maxThreadCount field and repositioned field declaration
ExportManager.java Removed redundant default value logic now handled by ExportOptions builder
ImportCommandOptions.java Changed maxThreads to Integer type and removed hardcoded defaultValue
ImportCommand.java Added null check for maxThreads with runtime default assignment
ExportCommandOptions.java Changed maxThreads to Integer type for nullable handling
ExportCommand.java Added null check for maxThreads with runtime default assignment
ImportOptionsTest.java New test file validating builder default behavior with and without explicit values
JsonExportManagerTest.java Added tests for ExportOptions builder default behavior
ImportCommandTest.java Added tests for CLI parsing and default value application
ExportCommandTest.java Added tests for CLI parsing and default value application

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!
But, I left one comment. PTAL!

Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@brfrn169
Copy link
Collaborator

@ypeckstadt Could you please resolve the conflicts?

# Conflicts:
#	data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/command/dataimport/ImportCommandTest.java
@ypeckstadt ypeckstadt force-pushed the fix/data-loader-max-threads-req branch from b07e70a to cfc0d0b Compare November 12, 2025 08:43
@ypeckstadt
Copy link
Contributor Author

@brfrn169 I have rebased the PR and fixed the conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants