Skip to content

Commit 40f20e3

Browse files
committed
rename some functions and methods
1 parent 58dc383 commit 40f20e3

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

src/flags.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ DEFINE_int32(snapshot_pool_size, 1, "the size of tablet thread pool for making s
121121

122122
DEFINE_uint32(load_index_max_wait_time, 120 * 60 * 1000, "config the max wait time of load index");
123123

124-
DEFINE_uint32(bloom_filter_bitset_size, 10000, "config the size of bitset in bloom filter");
125-
DEFINE_uint32(bloom_filter_hash_seed, 7, "config the count of hash seed in bloom filter, max 7");
124+
DEFINE_uint32(disk_stat_bloom_filter_bitset_size, 10000, "config the size of bitset in bloom filter");
125+
DEFINE_uint32(disk_stat_bloom_filter_hash_seed, 7, "config the count of hash seed in bloom filter, max 7");
126126

127127
DEFINE_string(recycle_bin_root_path, "/tmp/recycle", "specify the root path of recycle bin");
128128
DEFINE_string(recycle_bin_ssd_root_path, "", "specify the root path of recycle bin in ssd");

src/storage/disk_table.cc

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ DECLARE_uint32(write_buffer_mb);
3131
DECLARE_uint32(block_cache_shardbits);
3232
DECLARE_bool(verify_compression);
3333

34-
DECLARE_uint32(bloom_filter_bitset_size);
35-
DECLARE_uint32(bloom_filter_hash_seed);
36-
3734
namespace openmldb {
3835
namespace storage {
3936

@@ -392,13 +389,13 @@ bool DiskTable::Get(uint32_t idx, const std::string& pk, uint64_t ts, std::strin
392389
bool DiskTable::Get(const std::string& pk, uint64_t ts, std::string& value) { return Get(0, pk, ts, value); }
393390

394391
void DiskTable::SchedGc() {
395-
ClearRecord();
392+
ResetRecordCnt();
396393
GcHead();
397394
GcTTL();
398395
UpdateTTL();
399396
}
400397

401-
void DiskTable::ClearRecord() {
398+
void DiskTable::ResetRecordCnt() {
402399
auto indexs = table_index_.GetAllIndex();
403400
for (const auto& index : indexs) {
404401
idx_cnt_vec_[index->GetId()]->store(0, std::memory_order_relaxed);
@@ -426,7 +423,7 @@ void DiskTable::GcHead() {
426423
if (indexs.size() > 1) {
427424
std::map<uint32_t, uint64_t> ttl_map;
428425
std::map<uint32_t, uint32_t> idx_map;
429-
std::set<uint32_t> other_TTL_set;
426+
std::set<uint32_t> other_ttl_set;
430427
for (const auto& index : indexs) {
431428
auto ts_col = index->GetTsColumn();
432429
if (ts_col) {
@@ -436,7 +433,7 @@ void DiskTable::GcHead() {
436433
}
437434
auto TTL_type = index->GetTTLType();
438435
if (TTL_type != openmldb::storage::TTLType::kLatestTime) {
439-
other_TTL_set.insert(ts_col->GetId());
436+
other_ttl_set.insert(ts_col->GetId());
440437
}
441438
idx_map.emplace(ts_col->GetId(), index->GetId());
442439
}
@@ -449,7 +446,7 @@ void DiskTable::GcHead() {
449446
uint64_t ts = 0;
450447
uint32_t ts_idx = 0;
451448
ParseKeyAndTs(true, it->key(), cur_pk, ts, ts_idx);
452-
if (other_TTL_set.find(ts_idx) != other_TTL_set.end()) {
449+
if (other_ttl_set.find(ts_idx) != other_ttl_set.end()) {
453450
it->Next();
454451
continue;
455452
}
@@ -1335,7 +1332,7 @@ int DiskTable::GetCount(uint32_t index, const std::string& pk, uint64_t& count)
13351332
return 0;
13361333
}
13371334

1338-
uint32_t BloomFilter::hash(const char* str, uint32_t seed) {
1335+
uint32_t BloomFilter::Hash(const char* str, uint32_t seed) {
13391336
uint a = 63689;
13401337
uint hash = 0;
13411338

@@ -1347,31 +1344,31 @@ uint32_t BloomFilter::hash(const char* str, uint32_t seed) {
13471344
return (hash & 0x7FFFFFFF);
13481345
}
13491346

1350-
void BloomFilter::setBit(uint32_t bit) {
1347+
void BloomFilter::SetBit(uint32_t bit) {
13511348
uint32_t bits_num = bit / 64;
13521349
uint32_t bits_left = bit % 64;
13531350

13541351
bits_[bits_num]->fetch_or((uint64_t)1 << bits_left, std::memory_order_relaxed);
13551352
}
13561353

1357-
bool BloomFilter::getBit(uint32_t bit) {
1354+
bool BloomFilter::GetBit(uint32_t bit) {
13581355
uint32_t bits_num = bit / 64;
13591356
uint32_t bits_left = bit % 64;
13601357

13611358
return (bits_[bits_num]->load(std::memory_order_relaxed) >> bits_left) & 1;
13621359
}
13631360

13641361
void BloomFilter::Set(const char* str) {
1365-
for (uint32_t i = 0; i < FLAGS_bloom_filter_hash_seed; ++i) {
1366-
uint32_t p = hash(str, base_[i]) % FLAGS_bloom_filter_bitset_size;
1367-
setBit(p);
1362+
for (uint32_t i = 0; i < FLAGS_disk_stat_bloom_filter_hash_seed; ++i) {
1363+
uint32_t p = Hash(str, base_[i]) % FLAGS_disk_stat_bloom_filter_bitset_size;
1364+
SetBit(p);
13681365
}
13691366
}
13701367

13711368
bool BloomFilter::Valid(const char* str) {
1372-
for (uint32_t i = 0; i < FLAGS_bloom_filter_hash_seed; ++i) {
1373-
uint32_t p = hash(str, base_[i]) % FLAGS_bloom_filter_bitset_size;
1374-
if (!getBit(p)) {
1369+
for (uint32_t i = 0; i < FLAGS_disk_stat_bloom_filter_hash_seed; ++i) {
1370+
uint32_t p = Hash(str, base_[i]) % FLAGS_disk_stat_bloom_filter_bitset_size;
1371+
if (!GetBit(p)) {
13751372
return false;
13761373
}
13771374
}

src/storage/disk_table.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
#include "storage/table.h"
4242
#include "base/glog_wapper.h" // NOLINT
4343

44-
DECLARE_uint32(bloom_filter_bitset_size);
45-
DECLARE_uint32(bloom_filter_hash_seed);
44+
DECLARE_uint32(disk_stat_bloom_filter_bitset_size);
45+
DECLARE_uint32(disk_stat_bloom_filter_hash_seed);
4646

4747
namespace openmldb {
4848
namespace storage {
@@ -133,7 +133,7 @@ class KeyTSComparator : public rocksdb::Comparator {
133133
class BloomFilter {
134134
public:
135135
BloomFilter() {
136-
for (uint32_t i = 0; i < FLAGS_bloom_filter_bitset_size; i++) {
136+
for (uint32_t i = 0; i < FLAGS_disk_stat_bloom_filter_bitset_size; i++) {
137137
bits_.push_back(std::make_shared<std::atomic<uint64_t>>(0));
138138
}
139139
}
@@ -144,9 +144,9 @@ class BloomFilter {
144144
void Reset();
145145

146146
private:
147-
uint32_t hash(const char* str, uint32_t seed);
148-
void setBit(uint32_t bit);
149-
bool getBit(uint32_t bit);
147+
uint32_t Hash(const char* str, uint32_t seed);
148+
void SetBit(uint32_t bit);
149+
bool GetBit(uint32_t bit);
150150

151151
std::vector<std::shared_ptr<std::atomic<uint64_t>>> bits_;
152152
uint32_t base_[7] = {5, 7, 11, 13, 31, 37, 61};
@@ -520,7 +520,7 @@ class DiskTable : public Table {
520520

521521
void SchedGc() override;
522522

523-
void ClearRecord();
523+
void ResetRecordCnt();
524524
void GcHead();
525525
void GcTTL();
526526
void GcTTLAndHead();

0 commit comments

Comments
 (0)