Skip to content

Commit

Permalink
fix compaction policy modification (#12384)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored Dec 9, 2024
1 parent 2020867 commit 1382681
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ bool TOptimizerPlannerConstructor::DoApplyToCurrentObject(IOptimizerPlanner& cur
bool TOptimizerPlannerConstructor::DoIsEqualTo(const IOptimizerPlannerConstructor& item) const {
const auto* itemClass = dynamic_cast<const TOptimizerPlannerConstructor*>(&item);
AFL_VERIFY(itemClass);
if (Levels.size() != itemClass->Levels.size()) {
return false;
}
for (ui32 i = 0; i < Levels.size(); ++i) {
if (!Levels[i]->IsEqualTo(*itemClass->Levels[i].GetObjectPtrVerified())) {
return false;
}
}
return true;
}

Expand Down Expand Up @@ -61,8 +69,8 @@ NKikimr::TConclusionStatus TOptimizerPlannerConstructor::DoDeserializeFromJson(c
if (!level) {
return TConclusionStatus::Fail("incorrect level class_name: " + className);
}
if (!level->DeserializeFromJson(i["description"])) {
return TConclusionStatus::Fail("cannot parse level: " + className + ": " + i["description"].GetStringRobust());
if (!level->DeserializeFromJson(i)) {
return TConclusionStatus::Fail("cannot parse level: " + i.GetStringRobust());
}
Levels.emplace_back(TLevelConstructorContainer(std::shared_ptr<ILevelConstructor>(level.Release())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ class ILevelConstructor {
virtual TConclusionStatus DoDeserializeFromJson(const NJson::TJsonValue& json) = 0;
virtual bool DoDeserializeFromProto(const NKikimrSchemeOp::TCompactionLevelConstructorContainer& proto) = 0;
virtual void DoSerializeToProto(NKikimrSchemeOp::TCompactionLevelConstructorContainer& proto) const = 0;
virtual bool IsEqualToSameClass(const ILevelConstructor& item) const = 0;

public:
using TFactory = NObjectFactory::TObjectFactory<ILevelConstructor, TString>;
using TProto = NKikimrSchemeOp::TCompactionLevelConstructorContainer;

virtual ~ILevelConstructor() = default;

bool IsEqualTo(const ILevelConstructor& item) const {
if (GetClassName() != item.GetClassName()) {
return false;
}
return IsEqualToSameClass(item);
}

std::shared_ptr<IPortionsLevel> BuildLevel(
const std::shared_ptr<IPortionsLevel>& nextLevel, const ui32 indexLevel, const TLevelCounters& counters) const {
return DoBuildLevel(nextLevel, indexLevel, counters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
namespace NKikimr::NOlap::NStorageOptimizer::NLCBuckets {

TConclusionStatus TZeroLevelConstructor::DoDeserializeFromJson(const NJson::TJsonValue& json) {
if (!json.IsMap()) {
return TConclusionStatus::Fail("incorrect level description");
}
if (json.Has("portions_live_duration")) {
const auto& jsonValue = json["portions_live_duration"];
if (!jsonValue.IsString()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class TZeroLevelConstructor: public ILevelConstructor {
virtual TConclusionStatus DoDeserializeFromJson(const NJson::TJsonValue& json) override;
virtual bool DoDeserializeFromProto(const NKikimrSchemeOp::TCompactionLevelConstructorContainer& proto) override;
virtual void DoSerializeToProto(NKikimrSchemeOp::TCompactionLevelConstructorContainer& proto) const override;
virtual bool IsEqualToSameClass(const ILevelConstructor& item) const override {
const auto& itemCast = dynamic_cast<const TZeroLevelConstructor&>(item);
return PortionsLiveDuration == itemCast.PortionsLiveDuration && ExpectedBlobsSize == itemCast.ExpectedBlobsSize;
}

static const inline TFactory::TRegistrator<TZeroLevelConstructor> Registrator = TFactory::TRegistrator<TZeroLevelConstructor>(GetClassNameStatic());

Expand Down

0 comments on commit 1382681

Please sign in to comment.