Skip to content

Commit ae99943

Browse files
author
litongxin
committed
fix reviewDog
1 parent 4ffa37c commit ae99943

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/storage/disk_table.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "storage/disk_table.h"
1818
#include <utility>
19+
#include <set>
1920
#include "base/file_util.h"
2021
#include "base/glog_wapper.h" // NOLINT
2122
#include "base/hash.h"
@@ -331,7 +332,8 @@ bool DiskTable::Delete(const std::string& pk, uint32_t idx) {
331332
}
332333
it->Next();
333334
}
334-
batch.DeleteRange(cf_hs_[index_def->GetInnerPos() + 1], rocksdb::Slice(combine_key1), rocksdb::Slice(combine_key2));
335+
batch.DeleteRange(cf_hs_[index_def->GetInnerPos() + 1], rocksdb::Slice(combine_key1),
336+
rocksdb::Slice(combine_key2));
335337
}
336338
} else {
337339
std::string combine_key1 = CombineKeyTs(pk, UINT64_MAX);
@@ -352,7 +354,8 @@ bool DiskTable::Delete(const std::string& pk, uint32_t idx) {
352354
}
353355
it->Next();
354356
}
355-
rocksdb::Status s = batch.DeleteRange(cf_hs_[index_def->GetInnerPos() + 1], rocksdb::Slice(combine_key1), rocksdb::Slice(combine_key2));
357+
rocksdb::Status s = batch.DeleteRange(cf_hs_[index_def->GetInnerPos() + 1], rocksdb::Slice(combine_key1),
358+
rocksdb::Slice(combine_key2));
356359
}
357360
rocksdb::Status s = db_->Write(write_opts_, &batch);
358361
if (s.ok()) {
@@ -475,10 +478,13 @@ void DiskTable::GcHead() {
475478
for (auto ts_idx_iter = key_cnt.begin(); ts_idx_iter != key_cnt.end(); ts_idx_iter++) {
476479
auto index_iterator = idx_map.find(ts_idx_iter->first);
477480
auto ttl_iter = ttl_map.find(ts_idx_iter->first);
478-
if (ttl_iter != ttl_map.end() && ttl_iter->second > 0 && ts_idx_iter->second <= ttl_iter->second) {
479-
idx_cnt_vec_[index_iterator->second]->fetch_add(ts_idx_iter->second, std::memory_order_relaxed);
481+
if (ttl_iter != ttl_map.end() && ttl_iter->second > 0 &&
482+
ts_idx_iter->second <= ttl_iter->second) {
483+
idx_cnt_vec_[index_iterator->second]->fetch_add(ts_idx_iter->second,
484+
std::memory_order_relaxed);
480485
} else {
481-
idx_cnt_vec_[index_iterator->second]->fetch_add(ttl_iter->second, std::memory_order_relaxed);
486+
idx_cnt_vec_[index_iterator->second]->fetch_add(ttl_iter->second,
487+
std::memory_order_relaxed);
482488
}
483489
}
484490
if (key_cnt.size() > 0) {

src/storage/table_test.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,9 +1951,10 @@ TEST_F(TableTest, GetRecordAbsTTL) {
19511951
SchemaCodec::SetColumnDesc(table_meta.add_column_desc(), "ts3", ::openmldb::type::kBigInt);
19521952

19531953
SchemaCodec::SetIndex(table_meta.add_column_key(), "index0", "test", "ts1", ::openmldb::type::kAbsoluteTime, 90, 0);
1954-
SchemaCodec::SetIndex(table_meta.add_column_key(), "index1", "testnew", "ts2", ::openmldb::type::kAbsoluteTime, 50, 0);
1955-
SchemaCodec::SetIndex(table_meta.add_column_key(), "index2", "testnew", "ts3", ::openmldb::type::kAbsoluteTime, 40, 0);
1956-
1954+
SchemaCodec::SetIndex(table_meta.add_column_key(), "index1", "testnew", "ts2", ::openmldb::type::kAbsoluteTime, 50,
1955+
0);
1956+
SchemaCodec::SetIndex(table_meta.add_column_key(), "index2", "testnew", "ts3", ::openmldb::type::kAbsoluteTime, 40,
1957+
0);
19571958

19581959
Table* table = CreateTable(table_meta, table_path);
19591960
table->Init();
@@ -2193,7 +2194,8 @@ TEST_F(TableTest, GetRecordAbsAndLatTTL) {
21932194
SchemaCodec::SetColumnDesc(table_meta.add_column_desc(), "ts3", ::openmldb::type::kBigInt);
21942195

21952196
SchemaCodec::SetIndex(table_meta.add_column_key(), "index0", "test", "ts1", ::openmldb::type::kLatestTime, 0, 7);
2196-
SchemaCodec::SetIndex(table_meta.add_column_key(), "index1", "testnew", "ts2", ::openmldb::type::kAbsoluteTime, 50, 0);
2197+
SchemaCodec::SetIndex(table_meta.add_column_key(), "index1", "testnew", "ts2", ::openmldb::type::kAbsoluteTime, 50,
2198+
0);
21972199
SchemaCodec::SetIndex(table_meta.add_column_key(), "index2", "testnew", "ts3", ::openmldb::type::kLatestTime, 0, 4);
21982200

21992201

0 commit comments

Comments
 (0)