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

Restrict table bits_per_tag at compile time #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/packedtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ namespace cuckoofilter {
// Using Permutation encoding to save 1 bit per tag
template <size_t bits_per_tag>
class PackedTable {
static_assert(bits_per_tag == 5 || bits_per_tag == 6 || bits_per_tag == 7 ||
bits_per_tag == 8 || bits_per_tag == 9 ||
bits_per_tag == 13 || bits_per_tag == 17,
"bits_per_tag must be 5, 6, 7, 8, 9, 13, or 17");
static const size_t kDirBitsPerTag = bits_per_tag - 4;
static const size_t kBitsPerBucket = (3 + kDirBitsPerTag) * 4;
static const size_t kBytesPerBucket = (kBitsPerBucket + 7) >> 3;
Expand Down
4 changes: 4 additions & 0 deletions src/singletable.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ namespace cuckoofilter {
// the most naive table implementation: one huge bit array
template <size_t bits_per_tag>
class SingleTable {
static_assert(bits_per_tag == 2 || bits_per_tag == 4 || bits_per_tag == 8 ||
bits_per_tag == 12 || bits_per_tag == 16 ||
bits_per_tag == 32,
"bits_per_tag must be 2, 4, 8, 12, 16, or 32");
static const size_t kTagsPerBucket = 4;
static const size_t kBytesPerBucket =
(bits_per_tag * kTagsPerBucket + 7) >> 3;
Expand Down