Skip to content

Commit c590a01

Browse files
authored
minor improvements (#17446)
1 parent e9d1574 commit c590a01

File tree

10 files changed

+28
-27
lines changed

10 files changed

+28
-27
lines changed

ydb/core/tx/columnshard/background_controller.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33

44
namespace NKikimr::NColumnShard {
55

6-
bool TBackgroundController::StartCompaction(const NOlap::TPlanCompactionInfo& info) {
7-
auto it = ActiveCompactionInfo.find(info.GetPathId());
8-
if (it == ActiveCompactionInfo.end()) {
9-
it = ActiveCompactionInfo.emplace(info.GetPathId(), info.GetPathId()).first;
10-
}
6+
bool TBackgroundController::StartCompaction(const TInternalPathId pathId) {
7+
auto [it, _] = ActiveCompactionInfo.emplace(pathId, NOlap::TPlanCompactionInfo{pathId});
118
it->second.Start();
129
return true;
1310
}
1411

12+
void TBackgroundController::FinishCompaction(const TInternalPathId pathId) {
13+
auto it = ActiveCompactionInfo.find(pathId);
14+
AFL_VERIFY(it != ActiveCompactionInfo.end());
15+
if (it->second.Finish()) {
16+
ActiveCompactionInfo.erase(it);
17+
}
18+
Counters->OnCompactionFinish(pathId);
19+
}
20+
1521
void TBackgroundController::CheckDeadlines() {
1622
for (auto&& i : ActiveCompactionInfo) {
1723
if (TMonotonic::Now() - i.second.GetStartTime() > NOlap::TCompactionLimits::CompactionTimeout) {

ydb/core/tx/columnshard/background_controller.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,9 @@ class TBackgroundController {
4747
void CheckDeadlines();
4848
void CheckDeadlinesIndexation();
4949

50-
bool StartCompaction(const NOlap::TPlanCompactionInfo& info);
51-
void FinishCompaction(const NOlap::TPlanCompactionInfo& info) {
52-
auto it = ActiveCompactionInfo.find(info.GetPathId());
53-
AFL_VERIFY(it != ActiveCompactionInfo.end());
54-
if (it->second.Finish()) {
55-
ActiveCompactionInfo.erase(it);
56-
}
57-
Counters->OnCompactionFinish(info.GetPathId());
58-
}
50+
bool StartCompaction(const TInternalPathId pathId);
51+
void FinishCompaction(const TInternalPathId pathId);
52+
5953
ui32 GetCompactionsCount() const {
6054
return ActiveCompactionInfo.size();
6155
}

ydb/core/tx/columnshard/columnshard_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ void TColumnShard::SetupCompaction(const std::set<TInternalPathId>& pathIds) {
835835
if (BackgroundController.GetCompactionsCount()) {
836836
return;
837837
}
838-
const ui64 priority = TablesManager.MutablePrimaryIndex().GetCompactionPriority(DataLocksManager, pathIds, BackgroundController.GetWaitingPriorityOptional());
838+
const ui64 priority = TablesManager.GetPrimaryIndexSafe().GetCompactionPriority(DataLocksManager, pathIds, BackgroundController.GetWaitingPriorityOptional());
839839
if (priority) {
840840
BackgroundController.UpdateWaitingPriority(priority);
841841
if (pathIds.size()) {

ydb/core/tx/columnshard/data_accessor/request.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class TPathFetchingState {
127127
return sb;
128128
}
129129

130-
TPathFetchingState(const TInternalPathId pathId)
130+
explicit TPathFetchingState(const TInternalPathId pathId)
131131
: PathId(pathId) {
132132
}
133133

@@ -286,11 +286,12 @@ class TDataAccessorsRequest: public NColumnShard::TMonitoringObjectsCounter<TDat
286286
AFL_VERIFY(portion);
287287
AFL_VERIFY(FetchStage <= 1);
288288
AFL_VERIFY(PortionIds.emplace(portion->GetPortionId()).second);
289-
PathIds.emplace(portion->GetPathId());
290-
auto it = PathIdStatus.find(portion->GetPathId());
289+
const auto& pathId = portion->GetPathId();
290+
PathIds.emplace(pathId);
291+
auto it = PathIdStatus.find(pathId);
291292
if (it == PathIdStatus.end()) {
292293
PreparingCount.Inc();
293-
it = PathIdStatus.emplace(portion->GetPathId(), portion->GetPathId()).first;
294+
it = PathIdStatus.emplace(pathId, TPathFetchingState{pathId}).first;
294295
}
295296
it->second.AddPortion(portion);
296297
}

ydb/core/tx/columnshard/engines/changes/abstract/compaction_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TPlanCompactionInfo {
3030
return StartTime;
3131
}
3232

33-
TPlanCompactionInfo(const TInternalPathId pathId)
33+
explicit TPlanCompactionInfo(const TInternalPathId pathId)
3434
: PathId(pathId) {
3535
}
3636

ydb/core/tx/columnshard/engines/changes/compaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void TCompactColumnEngineChanges::DoCompile(TFinalizationContext& context) {
3232
void TCompactColumnEngineChanges::DoStart(NColumnShard::TColumnShard& self) {
3333
TBase::DoStart(self);
3434

35-
self.BackgroundController.StartCompaction(NKikimr::NOlap::TPlanCompactionInfo(GranuleMeta->GetPathId()));
35+
self.BackgroundController.StartCompaction(GranuleMeta->GetPathId());
3636
NeedGranuleStatusProvide = true;
3737
GranuleMeta->OnCompactionStarted();
3838
}
@@ -45,7 +45,7 @@ void TCompactColumnEngineChanges::DoWriteIndexOnComplete(NColumnShard::TColumnSh
4545
}
4646

4747
void TCompactColumnEngineChanges::DoOnFinish(NColumnShard::TColumnShard& self, TChangesFinishContext& context) {
48-
self.BackgroundController.FinishCompaction(TPlanCompactionInfo(GranuleMeta->GetPathId()));
48+
self.BackgroundController.FinishCompaction(GranuleMeta->GetPathId());
4949
Y_ABORT_UNLESS(NeedGranuleStatusProvide);
5050
if (context.FinishedSuccessfully) {
5151
GranuleMeta->OnCompactionFinished();

ydb/core/tx/columnshard/engines/column_engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class IColumnEngine {
150150
virtual std::shared_ptr<TInsertColumnEngineChanges> StartInsert(std::vector<TCommittedData>&& dataToIndex) noexcept = 0;
151151
virtual std::shared_ptr<TColumnEngineChanges> StartCompaction(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager) noexcept = 0;
152152
virtual ui64 GetCompactionPriority(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager, const std::set<TInternalPathId>& pathIds,
153-
const std::optional<ui64> waitingPriority) noexcept = 0;
153+
const std::optional<ui64> waitingPriority) const noexcept = 0;
154154
virtual std::shared_ptr<TCleanupPortionsColumnEngineChanges> StartCleanupPortions(const TSnapshot& snapshot,
155155
const THashSet<TInternalPathId>& pathsToDrop, const std::shared_ptr<NDataLocks::TManager>& dataLocksManager) noexcept = 0;
156156
virtual std::shared_ptr<TCleanupTablesColumnEngineChanges> StartCleanupTables(const THashSet<TInternalPathId>& pathsToDrop) noexcept = 0;

ydb/core/tx/columnshard/engines/column_engine_logs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ std::shared_ptr<TInsertColumnEngineChanges> TColumnEngineForLogs::StartInsert(st
189189
}
190190

191191
ui64 TColumnEngineForLogs::GetCompactionPriority(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager, const std::set<TInternalPathId>& pathIds,
192-
const std::optional<ui64> waitingPriority) noexcept {
192+
const std::optional<ui64> waitingPriority) const noexcept {
193193
auto priority = GranulesStorage->GetCompactionPriority(dataLocksManager, pathIds, waitingPriority);
194194
if (!priority) {
195195
return 0;

ydb/core/tx/columnshard/engines/column_engine_logs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class TColumnEngineForLogs: public IColumnEngine {
147147
}
148148
std::shared_ptr<TInsertColumnEngineChanges> StartInsert(std::vector<TCommittedData>&& dataToIndex) noexcept override;
149149
ui64 GetCompactionPriority(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager, const std::set<TInternalPathId>& pathIds,
150-
const std::optional<ui64> waitingPriority) noexcept override;
150+
const std::optional<ui64> waitingPriority) const noexcept override;
151151
std::shared_ptr<TColumnEngineChanges> StartCompaction(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager) noexcept override;
152152
std::shared_ptr<TCleanupPortionsColumnEngineChanges> StartCleanupPortions(const TSnapshot& snapshot, const THashSet<TInternalPathId>& pathsToDrop,
153153
const std::shared_ptr<NDataLocks::TManager>& dataLocksManager) noexcept override;

ydb/core/tx/columnshard/engines/storage/optimizer/lbuckets/planner/optimizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,8 +1246,8 @@ class TOptimizerPlanner: public IOptimizerPlanner {
12461246
}
12471247

12481248
virtual TOptimizationPriority DoGetUsefulMetric() const override {
1249-
if (Buckets.GetWeight()) {
1250-
return TOptimizationPriority::Critical(Buckets.GetWeight());
1249+
if (const auto weight = Buckets.GetWeight()) {
1250+
return TOptimizationPriority::Critical(weight);
12511251
} else {
12521252
return TOptimizationPriority::Zero();
12531253
}

0 commit comments

Comments
 (0)