This is an automated email from the ASF dual-hosted git repository.

colinlee pushed a commit to branch fix_bloom_filter
in repository https://gitbox.apache.org/repos/asf/tsfile.git


The following commit(s) were added to refs/heads/fix_bloom_filter by this push:
     new a259b813 fix data lossing.
a259b813 is described below

commit a259b813cdbe1a88121c9ec00b64ec065c2b5008
Author: ColinLee <[email protected]>
AuthorDate: Fri Jun 20 22:43:00 2025 +0800

    fix data lossing.
---
 cpp/src/reader/bloom_filter.cc                     |  1 -
 cpp/src/reader/bloom_filter.h                      |  2 +-
 .../{bloomfilter_test.cc => bloom_filter_test.cc}  | 22 +++++++++++-----------
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/cpp/src/reader/bloom_filter.cc b/cpp/src/reader/bloom_filter.cc
index dc5295dd..c50f1afd 100644
--- a/cpp/src/reader/bloom_filter.cc
+++ b/cpp/src/reader/bloom_filter.cc
@@ -201,7 +201,6 @@ int BloomFilter::add_path_entry(const String &device_name,
         int32_t hv = hf.hash(entry);
         bitset_.set(hv);
     }
-    std::cout << std::endl;
     free_entry_buf(entry.buf_);
     return E_OK;
 }
diff --git a/cpp/src/reader/bloom_filter.h b/cpp/src/reader/bloom_filter.h
index 5bf1fe11..5bb2dc51 100644
--- a/cpp/src/reader/bloom_filter.h
+++ b/cpp/src/reader/bloom_filter.h
@@ -72,7 +72,7 @@ class BitSet {
     void set(int32_t pos) {
         int32_t word_idx = pos / 64;
         int32_t word_offset = pos % 64;
-        words_[word_idx] |= (1ul << word_offset);
+        words_[word_idx] |= (1ull << word_offset);
     }
     int32_t get_words_in_use() const {
         for (int32_t i = word_count_ - 1; i >= 0; i--) {
diff --git a/cpp/test/reader/bloomfilter_test.cc 
b/cpp/test/reader/bloom_filter_test.cc
similarity index 86%
rename from cpp/test/reader/bloomfilter_test.cc
rename to cpp/test/reader/bloom_filter_test.cc
index e061d966..5e8bbff1 100644
--- a/cpp/test/reader/bloomfilter_test.cc
+++ b/cpp/test/reader/bloom_filter_test.cc
@@ -16,19 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#include <unordered_set>
+#include "reader/bloom_filter.h"
 
 #include <gtest/gtest.h>
 
-#include "reader/bloom_filter.h"
+#include <unordered_set>
 using namespace storage;
 TEST(BloomfilterTest, BloomFilter) {
     BloomFilter filter;
 
-    std::unordered_set<uint8_t> my_set = {
-        0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 128, 32, 0, 0, 1,
-        0, 4, 0, 0, 0, 16, 0, 0, 0, 0, 32
-    };
+    std::unordered_set<uint8_t> my_set = {0, 0, 0,   0,  0, 0, 0, 0, 2,
+                                          0, 2, 128, 32, 0, 0, 1, 0, 4,
+                                          0, 0, 0,   16, 0, 0, 0, 0, 32};
 
     filter.init(0.1, 10);
     common::PageArena arena;
@@ -44,8 +43,8 @@ TEST(BloomfilterTest, BloomFilter) {
     std::unordered_set<uint8_t> data;
     for (int i = 0; i < filter_data_bytes_len; i++) {
         data.insert(static_cast<int>(filter_data_bytes[i]));
-        std::cout << static_cast<int>(filter_data_bytes[i]) << " ";
-        ASSERT_TRUE(my_set.find(static_cast<int>(filter_data_bytes[i])) != 
my_set.end());
+        ASSERT_TRUE(my_set.find(static_cast<int>(filter_data_bytes[i])) !=
+                    my_set.end());
     }
     filter.serialize_to(out);
 
@@ -58,8 +57,9 @@ TEST(BloomfilterTest, BloomFilter) {
     filter2.get_bit_set()->to_bytes(filter_data_bytes2, 
filter_data_bytes_len2);
     ASSERT_EQ(filter_data_bytes_len, filter_data_bytes_len2);
     for (int i = 0; i < filter_data_bytes_len2; i++) {
-        ASSERT_TRUE(data.find(static_cast<int>(filter_data_bytes2[i])) != 
data.end());
-        std::cout << static_cast<int>(filter_data_bytes[i]) << " ";
-        ASSERT_TRUE(my_set.find(static_cast<int>(filter_data_bytes2[i])) != 
my_set.end());
+        ASSERT_TRUE(data.find(static_cast<int>(filter_data_bytes2[i])) !=
+                    data.end());
+        ASSERT_TRUE(my_set.find(static_cast<int>(filter_data_bytes2[i])) !=
+                    my_set.end());
     }
 }

Reply via email to