Skip to content

Commit

Permalink
[Fix](bvar) Fix bloom filter bvar fault
Browse files Browse the repository at this point in the history
The previous addition of bvar caused overflow issues due to incorrect type, and this PR fixes that problem.
  • Loading branch information
Yukang-Lian authored Mar 26, 2024
1 parent 6a6da0f commit 49995aa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
8 changes: 4 additions & 4 deletions be/src/olap/primary_key_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ class PrimaryKeyIndexReader {
PrimaryKeyIndexReader() : _index_parsed(false), _bf_parsed(false) {}

~PrimaryKeyIndexReader() {
segment_v2::g_pk_total_bloom_filter_num << -_bf_num;
segment_v2::g_pk_total_bloom_filter_total_bytes << -_bf_bytes;
segment_v2::g_pk_read_bloom_filter_num << -_bf_num;
segment_v2::g_pk_read_bloom_filter_total_bytes << -_bf_bytes;
segment_v2::g_pk_total_bloom_filter_num << -static_cast<int64_t>(_bf_num);
segment_v2::g_pk_total_bloom_filter_total_bytes << -static_cast<int64_t>(_bf_bytes);
segment_v2::g_pk_read_bloom_filter_num << -static_cast<int64_t>(_bf_num);
segment_v2::g_pk_read_bloom_filter_total_bytes << -static_cast<int64_t>(_bf_bytes);
}

Status parse_index(io::FileReaderSPtr file_reader,
Expand Down
44 changes: 26 additions & 18 deletions be/src/olap/rowset/segment_v2/bloom_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,34 @@
#include <memory>

#include "common/status.h"
#include "gutil/integral_types.h"
#include "util/murmur_hash3.h"

namespace doris {
namespace segment_v2 {

inline bvar::Adder<size_t> g_total_bloom_filter_num("doris_total_bloom_filter_num");
inline bvar::Adder<size_t> g_read_bloom_filter_num("doris_read_bloom_filter_num");
inline bvar::Adder<size_t> g_write_bloom_filter_num("doris_write_bloom_filter_num");

inline bvar::Adder<size_t> g_total_bloom_filter_total_bytes("doris_total_bloom_filter_bytes");
inline bvar::Adder<size_t> g_read_bloom_filter_total_bytes("doris_read_bloom_filter_bytes");
inline bvar::Adder<size_t> g_write_bloom_filter_total_bytes("doris_write_bloom_filter_bytes");

inline bvar::Adder<size_t> g_pk_total_bloom_filter_num("doris_pk_total_bloom_filter_num");
inline bvar::Adder<size_t> g_pk_read_bloom_filter_num("doris_pk_read_bloom_filter_num");
inline bvar::Adder<size_t> g_pk_write_bloom_filter_num("doris_pk_write_bloom_filter_num");

inline bvar::Adder<size_t> g_pk_total_bloom_filter_total_bytes("doris_pk_total_bloom_filter_bytes");
inline bvar::Adder<size_t> g_pk_read_bloom_filter_total_bytes("doris_pk_read_bloom_filter_bytes");
inline bvar::Adder<size_t> g_pk_write_bloom_filter_total_bytes("doris_pk_write_bloom_filter_bytes");
inline bvar::Adder<int64_t> g_total_bloom_filter_num("doris_total_bloom_filter_num");
inline bvar::Adder<int64_t> g_read_bloom_filter_num("doris_read_bloom_filter_num");
inline bvar::Adder<int64_t> g_write_bloom_filter_num("doris_write_bloom_filter_num");

inline bvar::Adder<int64_t> g_total_bloom_filter_total_bytes("doris_total_bloom_filter_bytes");
inline bvar::Adder<int64_t> g_read_bloom_filter_total_bytes("doris_read_bloom_filter_bytes");
inline bvar::Adder<int64_t> g_write_bloom_filter_total_bytes("doris_write_bloom_filter_bytes");

inline bvar::Adder<int64_t> g_pk_total_bloom_filter_num("doris_pk_total_bloom_filter_num");
inline bvar::Adder<int64_t> g_pk_read_bloom_filter_num("doris_pk_read_bloom_filter_num");
inline bvar::Adder<int64_t> g_pk_write_bloom_filter_increase_num(
"doris_pk_write_bloom_filter_increase_num");
inline bvar::Adder<int64_t> g_pk_write_bloom_filter_decrease_num(
"doris_pk_write_bloom_filter_decrease_num");

inline bvar::Adder<int64_t> g_pk_total_bloom_filter_total_bytes(
"doris_pk_total_bloom_filter_bytes");
inline bvar::Adder<int64_t> g_pk_read_bloom_filter_total_bytes("doris_pk_read_bloom_filter_bytes");
inline bvar::Adder<int64_t> g_pk_write_bloom_filter_increase_bytes(
"doris_pk_write_bloom_filter_increase_bytes");
inline bvar::Adder<int64_t> g_pk_write_bloom_filter_decrease_bytes(
"doris_pk_write_bloom_filter_decrease_bytes");

struct BloomFilterOptions {
// false positive probability
Expand Down Expand Up @@ -79,13 +87,13 @@ class BloomFilter {
virtual ~BloomFilter() {
if (_data) {
if (_is_write) {
g_write_bloom_filter_total_bytes << -_size;
g_write_bloom_filter_total_bytes << -static_cast<int64_t>(_size);
g_write_bloom_filter_num << -1;
} else {
g_read_bloom_filter_total_bytes << -_size;
g_read_bloom_filter_total_bytes << -static_cast<int64_t>(_size);
g_read_bloom_filter_num << -1;
}
g_total_bloom_filter_total_bytes << -_size;
g_total_bloom_filter_total_bytes << -static_cast<int64_t>(_size);
delete[] _data;
}
g_total_bloom_filter_num << -1;
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/rowset/segment_v2/bloom_filter_index_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ Status PrimaryKeyBloomFilterIndexWriterImpl::flush() {
_bf_buffer_size += bf->size();
g_pk_total_bloom_filter_num << 1;
g_pk_total_bloom_filter_total_bytes << bf->size();
g_pk_write_bloom_filter_num << 1;
g_pk_write_bloom_filter_total_bytes << bf->size();
g_pk_write_bloom_filter_increase_num << 1;
g_pk_write_bloom_filter_increase_bytes << bf->size();
_bfs.push_back(std::move(bf));
_values.clear();
_has_null = false;
Expand Down
6 changes: 3 additions & 3 deletions be/src/olap/rowset/segment_v2/bloom_filter_index_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ class PrimaryKeyBloomFilterIndexWriterImpl : public BloomFilterIndexWriter {
~PrimaryKeyBloomFilterIndexWriterImpl() override {
for (auto& bf : _bfs) {
g_pk_total_bloom_filter_num << -1;
g_pk_total_bloom_filter_total_bytes << -bf->size();
g_pk_write_bloom_filter_num << -1;
g_pk_write_bloom_filter_total_bytes << -bf->size();
g_pk_total_bloom_filter_total_bytes << -static_cast<int64_t>(bf->size());
g_pk_write_bloom_filter_decrease_num << 1;
g_pk_write_bloom_filter_decrease_bytes << bf->size();
}
};

Expand Down

0 comments on commit 49995aa

Please sign in to comment.