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

feat(fulltext_index): introduce creator #4249

Merged
merged 6 commits into from
Jul 2, 2024

Conversation

zhongzc
Copy link
Contributor

@zhongzc zhongzc commented Jul 2, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

#4246

What's changed and what's your intention?

as @coderabbitai

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

    • Introduced a fulltext indexing module with support for configurable analyzers (English and Chinese) and case sensitivity options.
    • Added functionality to create fulltext indexes, push text to the index, and retrieve memory usage during index creation.
  • Bug Fixes

    • Corrected parameter naming from capicity to capacity in various functions and tests to ensure consistency and prevent errors.
  • Error Handling

    • Introduced structured error handling for fulltext indexing with detailed error types and status codes.

@zhongzc zhongzc requested a review from a team as a code owner July 2, 2024 08:03
Copy link
Contributor

coderabbitai bot commented Jul 2, 2024

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

This change set introduces a new fulltext indexing feature leveraging the Tantivy search engine. It includes configuration, creation, and error handling functionalities. Dependencies such as serde, tokio, and tantivy are added to support these features. Additionally, some minor corrections in variable names and consistency adjustments are made in the puffin_manager module.

Changes

Files Change Summary
src/index/Cargo.toml Added dependencies: serde, tantivy with zstd-compression, tantivy-jieba, tokio, and common-test-util.
src/index/src/fulltext_index.rs Introduced Config struct and Analyzer enum to configure fulltext index settings.
src/index/src/fulltext_index/create.rs Added the FulltextIndexCreator trait and methods for text indexing. Exported TantivyFulltextIndexCreator implementation.
src/index/src/fulltext_index/create/tantivy.rs Implemented TantivyFulltextIndexCreator for fulltext indexing with Tantivy, including analyzer configuration and memory management.
src/index/src/fulltext_index/error.rs Introduced structured error handling with the Error enum and Result type alias.
src/index/src/lib.rs Added fulltext_index module.
src/puffin/src/puffin_manager/stager/bounded_stager.rs Corrected the capacity parameter spelling in the new function.
src/puffin/src/puffin_manager/tests.rs Corrected the spelling of capacity variable in function signatures and its usage.

Poem

In the code, where search is found,
New indices now do abound.
With Tantivy's power at our will,
English and Chinese texts we fill.
Serde, Tokio join the stage,
Errors handled, tests engage.
🐇✨ Fulltext searches, fast and sage!


Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.

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.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jul 2, 2024
Signed-off-by: Zhenchi <[email protected]>
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: 6

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f2c08b8 and 992c10e.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (8)
  • src/index/Cargo.toml (1 hunks)
  • src/index/src/fulltext_index.rs (1 hunks)
  • src/index/src/fulltext_index/create.rs (1 hunks)
  • src/index/src/fulltext_index/create/tantivy.rs (1 hunks)
  • src/index/src/fulltext_index/error.rs (1 hunks)
  • src/index/src/lib.rs (1 hunks)
  • src/puffin/src/puffin_manager/stager/bounded_stager.rs (1 hunks)
  • src/puffin/src/puffin_manager/tests.rs (9 hunks)
Files skipped from review due to trivial changes (1)
  • src/puffin/src/puffin_manager/tests.rs
Additional context used
GitHub Check: Check typos and docs
src/index/src/fulltext_index/create/tantivy.rs

[warning] 33-33:
"maximun" should be "maximum".

Additional comments not posted (6)
src/index/src/lib.rs (1)

17-17: Verify the necessity of the feature flag.

The feature flag iter_partition_in_place is enabled. Ensure it is necessary for the functionality introduced in this module.

src/index/Cargo.toml (1)

27-31: Verify the appropriateness of new dependencies.

Ensure that the versions and features of the new dependencies (serde, tantivy, tantivy-jieba, tokio, and common-test-util) are appropriate for the functionality introduced.

Also applies to: 34-34

src/index/src/fulltext_index.rs (1)

1-37: LGTM! The new module for fulltext indexing is well-defined.

The Config struct and Analyzer enum are correctly implemented with serde for serialization/deserialization and the Default trait.

src/index/src/fulltext_index/create.rs (1)

1-33: LGTM! The FulltextIndexCreator trait and its implementation are well-defined.

The trait and its methods are correctly implemented with appropriate async traits. The module structure is clear and organized.

src/index/src/fulltext_index/create/tantivy.rs (1)

122-315: Comprehensive Unit Tests

The unit tests for TantivyFulltextIndexCreator are comprehensive and cover various configurations and edge cases. This is a good practice to ensure the robustness of the implementation.

src/puffin/src/puffin_manager/stager/bounded_stager.rs (1)

70-70: Typographical Error: "capicity" should be "capacity"

There is a typographical error in the function parameter.

-pub async fn new(base_dir: PathBuf, capicity: u64) -> Result<Self> {
+pub async fn new(base_dir: PathBuf, capacity: u64) -> Result<Self> {

Likely invalid or redundant comment.

src/index/src/fulltext_index/error.rs Outdated Show resolved Hide resolved
src/index/src/fulltext_index/error.rs Outdated Show resolved Hide resolved
src/index/src/fulltext_index/create/tantivy.rs Outdated Show resolved Hide resolved
src/index/src/fulltext_index/create/tantivy.rs Outdated Show resolved Hide resolved
Signed-off-by: Zhenchi <[email protected]>
Copy link
Contributor

@v0y4g3r v0y4g3r left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, index master

src/index/src/fulltext_index/error.rs Outdated Show resolved Hide resolved
src/index/src/fulltext_index/create/tantivy.rs Outdated Show resolved Hide resolved
@zhongzc
Copy link
Contributor Author

zhongzc commented Jul 2, 2024

@coderabbitai pause

Copy link
Contributor

coderabbitai bot commented Jul 2, 2024

Actions performed

Reviews paused.

Signed-off-by: Zhenchi <[email protected]>
src/index/src/fulltext_index.rs Outdated Show resolved Hide resolved
@zhongzc zhongzc enabled auto-merge July 2, 2024 08:46
Copy link

codecov bot commented Jul 2, 2024

Codecov Report

Attention: Patch coverage is 95.53073% with 8 lines in your changes missing coverage. Please review.

Project coverage is 84.71%. Comparing base (db5d116) to head (8d965d5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4249      +/-   ##
==========================================
- Coverage   85.00%   84.71%   -0.29%     
==========================================
  Files        1051     1054       +3     
  Lines      186627   186950     +323     
==========================================
- Hits       158636   158371     -265     
- Misses      27991    28579     +588     

@zhongzc zhongzc added this pull request to the merge queue Jul 2, 2024
Merged via the queue into GreptimeTeam:main with commit e64379d Jul 2, 2024
50 checks passed
@zhongzc zhongzc deleted the zhongzc/fulltext-build-0 branch July 2, 2024 09:26
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.

4 participants