From 94cf48275d73bb0c4cbdd3473a23e20c846e45cb Mon Sep 17 00:00:00 2001 From: proost Date: Sat, 21 Nov 2026 00:15:21 +0900 Subject: [PATCH 1/2] fix: wrong buffer size for ebpps --- sampling/include/ebpps_sketch_impl.hpp | 2 +- sampling/test/ebpps_sketch_test.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sampling/include/ebpps_sketch_impl.hpp b/sampling/include/ebpps_sketch_impl.hpp index 9a7b23e3..574a6917 100644 --- a/sampling/include/ebpps_sketch_impl.hpp +++ b/sampling/include/ebpps_sketch_impl.hpp @@ -331,7 +331,7 @@ auto ebpps_sketch::serialize(unsigned header_size_bytes, const SerDe& sd) c const size_t size = header_size_bytes + (prelongs << 3) + sample_.get_serialized_size_bytes(sd); vector_bytes bytes(size, 0, allocator_); uint8_t* ptr = bytes.data() + header_size_bytes; - const uint8_t* end_ptr = ptr + size; + const uint8_t* end_ptr = bytes.data() + size; uint8_t flags = 0; if (is_empty()) { diff --git a/sampling/test/ebpps_sketch_test.cpp b/sampling/test/ebpps_sketch_test.cpp index 5ee72813..0f8e06e7 100644 --- a/sampling/test/ebpps_sketch_test.cpp +++ b/sampling/test/ebpps_sketch_test.cpp @@ -301,4 +301,15 @@ TEST_CASE("ebpps sketch: merge keeps the max weight", "[ebpps_sketch]") { REQUIRE(sk4.get_c() == Approx(ref.get_c()).margin(EPS)); } +TEST_CASE("ebpps sketch: serialize with header", "[ebpps_sketch]") { + auto sk = create_unweighted_sketch(10, 25); + const size_t body_size = sk.get_serialized_size_bytes(); + for (unsigned header_size : {0u, 1u, 8u, 13u}) { + auto bytes = sk.serialize(header_size); + REQUIRE(bytes.size() == header_size + body_size); + auto sk2 = ebpps_sketch::deserialize(bytes.data() + header_size, bytes.size() - header_size); + check_if_equal(sk, sk2); + } +} + } \ No newline at end of file From a2db789b750fd67edadef70e2cbd11e8544299ef Mon Sep 17 00:00:00 2001 From: proost Date: Sat, 21 Nov 2026 00:16:28 +0900 Subject: [PATCH 2/2] style: newline --- sampling/test/ebpps_sketch_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sampling/test/ebpps_sketch_test.cpp b/sampling/test/ebpps_sketch_test.cpp index 0f8e06e7..e104e319 100644 --- a/sampling/test/ebpps_sketch_test.cpp +++ b/sampling/test/ebpps_sketch_test.cpp @@ -312,4 +312,4 @@ TEST_CASE("ebpps sketch: serialize with header", "[ebpps_sketch]") { } } -} \ No newline at end of file +}