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

binary fuse filter: allow size=0,size=1,size=2 and add tests #27

Merged
merged 1 commit into from
Aug 22, 2021
Merged

binary fuse filter: allow size=0,size=1,size=2 and add tests #27

merged 1 commit into from
Aug 22, 2021

Conversation

slimsag
Copy link
Contributor

@slimsag slimsag commented Aug 21, 2021

In dabe365 checks were added to prevent
creation of filters with size <= 1, and while these incredibly small
sizes are not particularly useful in a binary fuse filter, keeping the
property that all sizes [0..N] are allowed is nice due to the fact
that, if the restriction is in place, you must:

  • Verify your set length is >= 1.
  • If it isn't, use a separate code path to lookup and encode your 0, 1, or 2 keys
    outside the binary fuse filter. And also handle encoding that to a file if you
    e.g. intend to serialize the filter to disk.

With this change, input sizes 0,1,2 are allowed and consume no more
memory than size=3 (there is no overflow condition in calculating the
array length.)

Also added a few tests for these three edge cases.

Ref #26

Signed-off-by: Stephen Gutekanst stephen@hexops.com

In dabe365 checks were added to prevent
creation of filters with `size <= 1`, and while these incredibly small
sizes are not particularly useful in a binary fuse filter, keeping the
property that all sizes `[0..N]` are allowed is nice due to the fact
that, if the restriction is in place, you must:

* Verify your set length is >= 1.
* If it isn't, use a separate code path to lookup and encode your 0, 1, or 2 keys
  outside the binary fuse filter. And also handle encoding that to a file if you
  e.g. intend to serialize the filter to disk.

With this change, input sizes 0,1,2 are allowed and consume no more
memory than size=3 (there is no overflow condition in calculating the
array length.)

Also added a few tests for these three edge cases.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
slimsag added a commit to hexops/fastfilter that referenced this pull request Aug 21, 2021
Mirroring FastFilter/xor_singleheader#27

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
slimsag added a commit to hexops/fastfilter that referenced this pull request Aug 21, 2021
Mirroring FastFilter/xor_singleheader#27

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
@lemire
Copy link
Member

lemire commented Aug 22, 2021

Why not!

@lemire lemire merged commit 9c68073 into FastFilter:master Aug 22, 2021
@lemire
Copy link
Member

lemire commented Aug 22, 2021

Merged.

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.

2 participants