Skip to content
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

refactor: make RegionOptions and MergeOutput serializable #4180

Merged
merged 6 commits into from
Jun 24, 2024

Conversation

zyy17
Copy link
Collaborator

@zyy17 zyy17 commented Jun 20, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

Make PickerOutput and MergeOutput serializable and deserializable. It's easy to transmit over the network in JSON format.

In order to use #[serde(skip)], the PR will make file_purger in FileHandleInner as Option type.

  1. Make MergeOutput serializable and deserializable;
  2. Make RegionOptions serializable, and we can marshal it into JSON string;

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

  • New Features

    • Added serialization support to various structs and enums to enable data interchange. This includes RegionOptions, CompactionOptions, TwcsOptions, IndexOptions, InvertedIndexOptions, MemtableOptions, and PartitionTreeOptions.
  • Improvements

    • Enhanced the MergeOutput struct with serialization and deserialization capabilities for better data management and interchange.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jun 20, 2024
Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.77%. Comparing base (5566dd7) to head (4d99fd1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4180      +/-   ##
==========================================
- Coverage   85.06%   84.77%   -0.29%     
==========================================
  Files        1028     1028              
  Lines      180477   180478       +1     
==========================================
- Hits       153514   152996     -518     
- Misses      26963    27482     +519     

src/mito2/src/sst/file.rs Outdated Show resolved Hide resolved
src/mito2/src/sst/file.rs Outdated Show resolved Hide resolved
src/mito2/src/compaction/picker.rs Outdated Show resolved Hide resolved
@zyy17 zyy17 force-pushed the refactor/serialize-compaction-struture branch from f6dcc94 to 4b9fd86 Compare June 21, 2024 09:07
@zyy17 zyy17 changed the title refactor: make PickerOutput and MergeOutput serializable and deserializable refactor: make RegionOptions and MergeOutput serializable Jun 21, 2024
@zyy17
Copy link
Collaborator Author

zyy17 commented Jun 21, 2024

@evenyag @WenyXu I have removed Serialize and Deserialize from PickerOutput and add the new modification of making RegionOptions serializable. PTAL.

@zyy17 zyy17 requested review from evenyag and WenyXu June 21, 2024 09:17
@WenyXu
Copy link
Member

WenyXu commented Jun 21, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jun 21, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Jun 21, 2024

Walkthrough

The changes primarily introduce the Serialize trait from serde to various structs and enums within the compactor.rs and options.rs files in the mito2 module. This enables these types to be serialized, improving their usability for data interchange. The core modifications include updating the MergeOutput struct and several structs and enums related to region options to derive Serialize along with existing traits.

Changes

Files Change Summary
src/mito2/src/compaction/compactor.rs Added use serde::{Deserialize, Serialize}; and updated MergeOutput struct to derive Serialize.
src/mito2/src/region/options.rs Applied Serialize to RegionOptions, CompactionOptions, TwcsOptions, IndexOptions,
InvertedIndexOptions, MemtableOptions, and PartitionTreeOptions structs/enums.

Poem

In the code, a change so bright,
Serialization takes its flight.
With serde's might, the data flows,
In mito2, new life it shows.
JSON dreams and seamless streams,
In Rust we trust, fulfilling schemes. 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator

@fengjiachun fengjiachun 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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5566dd7 and 4d99fd1.

Files selected for processing (2)
  • src/mito2/src/compaction/compactor.rs (2 hunks)
  • src/mito2/src/region/options.rs (8 hunks)
Additional comments not posted (10)
src/mito2/src/compaction/compactor.rs (2)

22-22: Ensure correct usage of serde traits for serialization.

The import of serde::{Deserialize, Serialize} is necessary for the changes made to MergeOutput. Ensure that these traits are used consistently throughout the codebase for all serializable entities.


178-178: Review of the MergeOutput struct enhancements.

The addition of Serialize and Deserialize to the MergeOutput struct aligns with the PR's goal to enable serialization. This change is crucial for network transmission of these objects in JSON format, enhancing interoperability and data management.

src/mito2/src/region/options.rs (8)

25-25: Review of the updated import statement for serde.

The inclusion of Serialize and Deserialize is essential for the new serializability of the RegionOptions and other related structs. This import statement is correctly placed and necessary for the changes.


39-39: Serialization capabilities added to RegionOptions.

The update to include Serialize in the RegionOptions struct is correctly implemented. This change is vital for enabling the serialization of region configurations, which can now be easily transmitted or stored in JSON format.


105-105: Enhancements to CompactionOptions enum.

Adding serialization to the CompactionOptions enum allows for more flexible configuration management and easier integration with systems that require JSON configuration. The use of external tagging (compaction.type) is appropriate and enhances clarity.


130-130: Serialization support for TwcsOptions.

The TwcsOptions struct now supports serialization, which is crucial for settings related to time window compaction strategies. The use of DisplayFromStr for custom serialization of numerical fields is a good practice, ensuring that these values are handled correctly in JSON.


198-198: Serialization enhancements to IndexOptions.

The update to IndexOptions to include serialization support is well-implemented. The use of prefix_inverted_index to handle nested serialization paths is a smart choice, maintaining consistency and clarity in the JSON structure.


208-208: Updates to InvertedIndexOptions for better serialization handling.

The changes to InvertedIndexOptions enhance its serialization capabilities, particularly with the custom deserializer for ignore_column_ids. This is an important improvement for managing index configurations in a serialized format.


231-231: Serialization capabilities added to MemtableOptions.

The update to the MemtableOptions enum to support serialization, with specific handling for different types of memtables, is correctly implemented. The use of external tagging (memtable.type) is appropriate and enhances the configurability and management of memtables in a serialized format.


243-243: Enhancements to PartitionTreeOptions for serialization.

Adding serialization support to PartitionTreeOptions allows for better configuration management of partition tree memtables. The use of DisplayFromStr for custom serialization of numerical fields is consistent with best practices.

@zyy17 zyy17 added this pull request to the merge queue Jun 24, 2024
Merged via the queue into GreptimeTeam:main with commit 0139a70 Jun 24, 2024
51 checks passed
@zyy17 zyy17 deleted the refactor/serialize-compaction-struture branch June 24, 2024 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants