Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compaction policy modification #12384

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading