Skip to content

Commit

Permalink
3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukang-Lian committed Oct 31, 2024
1 parent 40ca326 commit 4c87a4c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
6 changes: 2 additions & 4 deletions be/src/olap/olap_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ using ColumnId = uint32_t;
using UniqueIdSet = std::set<uint32_t>;
// Column unique Id -> column id map
using UniqueIdToColumnIdMap = std::map<ColumnId, ColumnId>;
int64_t unique_rowset_id_next_high();

// 8 bit rowset id version
// 56 bit, inc number from 1
Expand All @@ -418,10 +419,7 @@ struct RowsetId {
rowset_id_str.data() + rowset_id_str.length(), high);
if (ec != std::errc {}) [[unlikely]] {
LOG(WARNING) << "failed to init rowset id: " << rowset_id_str;
high = []() {
std::mt19937_64 rg(std::random_device {}());
return std::uniform_int_distribution<int64_t>()(rg);
}();
high = unique_rowset_id_next_high();
}
init(1, high, 0, 0);
} else {
Expand Down
1 change: 1 addition & 0 deletions be/src/olap/rowset/rowset_id_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class RowsetIdGenerator {

// generate and return the next global unique rowset id
virtual RowsetId next_id() = 0;
virtual int64_t next_high() = 0;
}; // RowsetIdGenerator

} // namespace doris
13 changes: 13 additions & 0 deletions be/src/olap/rowset/unique_rowset_id_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@

#include "olap/rowset/unique_rowset_id_generator.h"

#include <atomic>

#include "olap/storage_engine.h"
#include "runtime/exec_env.h"

namespace doris {

int64_t unique_rowset_id_next_high() {
return ExecEnv::GetInstance()->storage_engine().next_rowset_id_high();
}

UniqueRowsetIdGenerator::UniqueRowsetIdGenerator(const UniqueId& backend_uid)
: _backend_uid(backend_uid), _inc_id(1) {}

Expand All @@ -31,4 +40,8 @@ RowsetId UniqueRowsetIdGenerator::next_id() {
return rowset_id;
}

int64_t UniqueRowsetIdGenerator::next_high() {
return _inc_id.fetch_add(1, std::memory_order_relaxed);
}

} // namespace doris
1 change: 1 addition & 0 deletions be/src/olap/rowset/unique_rowset_id_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class UniqueRowsetIdGenerator : public RowsetIdGenerator {
~UniqueRowsetIdGenerator() override;

RowsetId next_id() override;
int64_t next_high() override;

private:
const UniqueId _backend_uid;
Expand Down
4 changes: 4 additions & 0 deletions be/src/olap/storage_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ RowsetId BaseStorageEngine::next_rowset_id() {
return _rowset_id_generator->next_id();
}

int64_t BaseStorageEngine::next_rowset_id_high() {
return _rowset_id_generator->next_high();
}

StorageEngine& BaseStorageEngine::to_local() {
CHECK_EQ(_type, Type::LOCAL);
return *static_cast<StorageEngine*>(this);
Expand Down
1 change: 1 addition & 0 deletions be/src/olap/storage_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class BaseStorageEngine {
int32_t effective_cluster_id() const { return _effective_cluster_id; }

RowsetId next_rowset_id();
int64_t next_rowset_id_high();

MemTableFlushExecutor* memtable_flush_executor() { return _memtable_flush_executor.get(); }
CalcDeleteBitmapExecutor* calc_delete_bitmap_executor() {
Expand Down

0 comments on commit 4c87a4c

Please sign in to comment.