Skip to content

Commit

Permalink
upgrading upstream to 2.0.0
Browse files Browse the repository at this point in the history
this now includes ->Size and contains a breaking change on
serialisation format

therefore binfuse must also make a breaking change
  • Loading branch information
oschonrock committed Jan 29, 2025
1 parent ddac531 commit 8732348
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion include/binfuse/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ class filter {
return ftype<FilterType>::contains(needle, &fil_);
}

[[nodiscard]] bool is_populated() const { return fil_.SegmentCount > 0; }
[[nodiscard]] std::size_t size() const {
return static_cast<std::size_t>(fil_.Size);
}

[[nodiscard]] bool is_populated() const { return size() > 0; }

[[nodiscard]] std::size_t serialization_bytes() const {
// upstream API should be const
Expand Down
4 changes: 2 additions & 2 deletions include/binfuse/sharded_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class sharded_filter : private sharded_mmap_base<AccessMode> {
}

[[nodiscard]] bool contains(std::uint64_t needle) const {
auto prefix = extract_prefix(needle);
const auto prefix = extract_prefix(needle);
// we know prefix is always < max_shards() by definition
auto& filter = filters[prefix];
const auto& filter = filters[prefix];
if (!filter.is_populated()) {
// this filter has not been populated. no fingerprint pointer
// has been set and an upstream `contain` call will throw
Expand Down
Binary file modified test/data/sharded_filter8_tiny.bin
Binary file not shown.
1 change: 1 addition & 0 deletions test/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ TEST(binfuse_filter, construct_from_upstream) { // NOLINT

binfuse::filter8 filter(std::move(fil)); // NOLINT not trivial
EXPECT_TRUE(filter.is_populated());
EXPECT_EQ(filter.size(), 3);
EXPECT_TRUE(filter.contains(0x0000000000000000));
EXPECT_TRUE(filter.contains(0x0000000000000001));
EXPECT_TRUE(filter.contains(0x0000000000000002));
Expand Down

0 comments on commit 8732348

Please sign in to comment.