fix: fix hash func in bloom filter implementation#2412
Merged
Snailclimb merged 1 commit intoSnailclimb:mainfrom Jun 19, 2024
codesssss:patch-1
Merged
fix: fix hash func in bloom filter implementation#2412Snailclimb merged 1 commit intoSnailclimb:mainfrom codesssss:patch-1
Snailclimb merged 1 commit intoSnailclimb:mainfrom
codesssss:patch-1
Conversation
Owner
感谢完善👍 |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
标题
修复布隆过滤器中哈希计算导致的位图越界溢出问题
描述
问题描述:
在原有的布隆过滤器实现中,哈希计算会导致位图(BitSet)出现越界溢出的问题。具体表现为生成的哈希值超出了位图的容量范围(
cap),导致布隆过滤器的位图操作出现意外行为,并最终导致位图溢出。修正方法:
通过调整哈希计算逻辑,确保生成的哈希值在
cap范围内。具体修正方法如下:修正后的代码:
测试用例及结果:
测试用例:
修正前的结果:
修正后的结果:
通过修正哈希计算逻辑,哈希值始终在
cap范围内,避免了位图越界溢出的问题。修正后的布隆过滤器表现正常,各测试用例结果符合预期。关联issue: #2413