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

BITCOUNT Upper bound calculation fix #1138

Merged
merged 2 commits into from
Mar 27, 2025

Conversation

vazois
Copy link
Collaborator

@vazois vazois commented Mar 26, 2025

This PR fixes issue #1135

@Copilot Copilot bot review requested due to automatic review settings March 26, 2025 20:51
Copy link
Contributor

@Copilot 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 addresses issue #1135 by fixing the BITCOUNT upper bound calculation.

  • Updated the BITCOUNT calculation logic to ensure the end offset is inclusive
  • Added a test case that validates using int.MaxValue as the upper bound

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/Garnet.test/GarnetBitmapTests.cs Added a test to verify BITCOUNT with an inclusive upper bound
libs/server/Resp/Bitmap/BitmapManagerBitCount.cs Adjusted upper bound calculation to account for an inclusive index
Comments suppressed due to low confidence (2)

libs/server/Resp/Bitmap/BitmapManagerBitCount.cs:73

  • The change to 'valLen - 1' ensures the end offset is treated as an inclusive index; please verify that this adjustment consistently meets the intended BITCOUNT behavior across all edge cases.
endOffset = endOffset >= valLen ? valLen - 1 : endOffset;

test/Garnet.test/GarnetBitmapTests.cs:2317

  • [nitpick] Consider adding additional test cases covering boundary scenarios, such as negative offsets, to further validate the BITCOUNT logic.
count = db.StringBitCount(key, 0, int.MaxValue);

@vazois vazois linked an issue Mar 26, 2025 that may be closed by this pull request
@vazois vazois merged commit 202b9e6 into microsoft:main Mar 27, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BITCOUNT end offset calculation
2 participants