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

fix: parse min-blob-size error when min-blob-size ends with unit #2767

Merged

Conversation

wangshao1
Copy link
Collaborator

@wangshao1 wangshao1 commented Jun 28, 2024

Summary by CodeRabbit

  • Bug Fixes

    • Adjusted configuration loading for "min-blob-size" to handle human-readable formats, improving usability.
  • New Features

    • Added a test case for the ZREVRANK functionality in the Redis client for better reliability and coverage.

Copy link

coderabbitai bot commented Jun 28, 2024

Walkthrough

The recent updates include several key changes. In PikaConf::Load, the method for fetching the min-blob-size configuration was updated, which affects how this parameter is interpreted. Adjustments were also made to the loop condition in ZRevrank to improve its functionality. Furthermore, new integration tests for ZREVRANK were added to validate the enhancements.

Changes

File(s) Change Summary
src/pika_conf.cc Changed GetConfInt64 to GetConfInt64Human for min-blob-size configuration in PikaConf::Load()
src/storage/src/redis_zsets.cc Updated loop condition in ZRevrank function to iterate while left is greater than 0
tests/integration/zset_test.go Added test case for ZREVRANK, verifying various operations on sorted sets

Poem

In the land of code, where configs roam,
A tweak to blob sizes, now more known.
With zsets ranked, in reverse delight,
Tests will ensure they function right.
A gentle hop, a code adjust,
For better storage we entrust.


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 ☢️ Bug Something isn't working label Jun 28, 2024
@wangshao1 wangshao1 changed the title fix: parse min-blob-size error with fix: parse min-blob-size error when min-blob-size ends with unit Jun 28, 2024
Copy link

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1be0738 and 257b18a.

Files selected for processing (3)
  • src/pika_conf.cc (1 hunks)
  • src/storage/src/redis_zsets.cc (1 hunks)
  • tests/integration/zset_test.go (1 hunks)
Additional comments not posted (2)
src/pika_conf.cc (1)

650-650: Updated method for parsing 'min-blob-size' configuration.

The change from GetConfInt64 to GetConfInt64Human allows for human-readable input formats (e.g., "10MB", "1GB"). This is a beneficial change as it enhances the flexibility and user-friendliness of configuration settings.

src/storage/src/redis_zsets.cc (1)

1133-1133: Refinement in loop condition of ZRevrank

The modification in the loop condition from left >= 0 to left > 0 appears to be a deliberate change to avoid an off-by-one error. However, it's crucial to ensure that this change aligns with the intended functionality of the ZRevrank method. This adjustment could potentially affect how ranks are calculated, especially for edge cases.

Please verify through additional unit tests that this change does not inadvertently exclude any elements that should be included in the rank calculation, and that it behaves correctly across all possible inputs.

Copy link

@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 1be0738 and 5652eb5.

Files selected for processing (1)
  • src/pika_conf.cc (1 hunks)
Additional comments not posted (1)
src/pika_conf.cc (1)

665-665: Confirm the change in configuration parsing for min-blob-size.

The change from GetConfInt64 to GetConfInt64Human for min-blob-size suggests an enhancement in how values are parsed, likely supporting more human-readable formats (e.g., "1M" instead of "1048576"). This is a positive change if documented properly and tested.

Verification successful

Confirm the correct implementation of GetConfInt64Human.

The function GetConfInt64Human is used consistently across the codebase for parsing various configuration values. This suggests a standardized approach to handling human-readable integer formats. To ensure its correctness, let's verify the implementation details of GetConfInt64Human in base_conf.cc.


Verify the implementation of GetConfInt64Human in base_conf.cc.

The previous attempt to capture the implementation details of GetConfInt64Human was unsuccessful. We will now use rg to locate the function definition in base_conf.cc to ensure it correctly handles human-readable formats.


Extract the full implementation of GetConfInt64Human from base_conf.cc.

We have located the definition of GetConfInt64Human. Now, let's extract its full implementation to verify that it correctly handles human-readable formats.


Confirm the change in configuration parsing for min-blob-size.

The function GetConfInt64Human correctly handles human-readable formats, converting 'K', 'M', and 'G' suffixes to their corresponding values in bytes. The change from GetConfInt64 to GetConfInt64Human for min-blob-size and other configurations is properly implemented and enhances the usability of configuration settings.

  • src/pika_conf.cc: Line 665
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the new parsing function handles various human-readable formats correctly.

# Test: Search for the function `GetConfInt64Human` usage. Expect: Only occurances of the new signature.
rg --type cpp $'GetConfInt64Human'

Length of output: 1143



Script:

#!/bin/bash
# Description: Verify the implementation of GetConfInt64Human function.

# Search for the implementation of GetConfInt64Human in base_conf.cc
ast-grep --lang cpp --pattern $'bool BaseConf::GetConfInt64Human(const std::string& name, int64_t* value) const {
  $$$
}'

Length of output: 123



Script:

#!/bin/bash
# Description: Verify the implementation of GetConfInt64Human function.

# Search for the implementation of GetConfInt64Human in base_conf.cc
rg 'bool BaseConf::GetConfInt64Human' --type cpp

Length of output: 158



Script:

#!/bin/bash
# Description: Extract the full implementation of GetConfInt64Human function.

# Extract the full implementation of GetConfInt64Human from base_conf.cc
rg -A 20 'bool BaseConf::GetConfInt64Human' src/pstd/src/base_conf.cc

Length of output: 676

@chejinge chejinge merged commit c259401 into OpenAtomFoundation:unstable Jun 28, 2024
14 checks passed
chejinge pushed a commit that referenced this pull request Jun 28, 2024
Co-authored-by: wangshaoyi <wangshaoyi@360.cn>
chejinge pushed a commit that referenced this pull request Aug 1, 2024
Co-authored-by: wangshaoyi <wangshaoyi@360.cn>
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
Co-authored-by: wangshaoyi <wangshaoyi@360.cn>
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
Co-authored-by: wangshaoyi <wangshaoyi@360.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.0.0 bug ☢️ Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants