@@ -36,6 +36,10 @@ class TOptimizationPriority {
36
36
}
37
37
38
38
public:
39
+ void Mul (const ui32 kff) {
40
+ InternalLevelWeight *= kff;
41
+ }
42
+
39
43
ui64 GetGeneralPriority () const {
40
44
return ((ui64)Level << 56 ) + InternalLevelWeight;
41
45
}
@@ -88,13 +92,15 @@ using TPortionInfoForCompaction = NPortion::TPortionInfoForCompaction;
88
92
89
93
class IOptimizerPlanner {
90
94
private:
95
+ friend class IOptimizerPlannerConstructor ;
91
96
const TInternalPathId PathId;
92
97
YDB_READONLY (TInstant, ActualizationInstant, TInstant::Zero());
93
98
94
99
virtual bool DoIsOverloaded () const {
95
100
return false ;
96
101
}
97
102
const ui32 NodePortionsCountLimit = 0 ;
103
+ double WeightKff = 1 ;
98
104
static inline TAtomicCounter NodePortionsCounter = 0 ;
99
105
TPositiveControlInteger LocalPortionsCount;
100
106
std::shared_ptr<TCounters> Counters = std::make_shared<TCounters>();
@@ -191,7 +197,9 @@ class IOptimizerPlanner {
191
197
std::shared_ptr<TColumnEngineChanges> GetOptimizationTask (
192
198
std::shared_ptr<TGranuleMeta> granule, const std::shared_ptr<NDataLocks::TManager>& dataLocksManager) const ;
193
199
TOptimizationPriority GetUsefulMetric () const {
194
- return DoGetUsefulMetric ();
200
+ auto result = DoGetUsefulMetric ();
201
+ result.Mul (WeightKff);
202
+ return result;
195
203
}
196
204
void Actualize (const TInstant currentInstant) {
197
205
ActualizationInstant = currentInstant;
@@ -228,6 +236,7 @@ class IOptimizerPlannerConstructor {
228
236
229
237
private:
230
238
ui32 NodePortionsCountLimit = 1000000 ;
239
+ double WeightKff = 1.0 ;
231
240
232
241
virtual TConclusion<std::shared_ptr<IOptimizerPlanner>> DoBuildPlanner (const TBuildContext& context) const = 0;
233
242
virtual void DoSerializeToProto (TProto& proto) const = 0;
@@ -263,16 +272,29 @@ class IOptimizerPlannerConstructor {
263
272
}
264
273
NodePortionsCountLimit = jsonValue.GetUInteger ();
265
274
}
275
+ if (jsonInfo.Has (" weight_kff" )) {
276
+ const auto & jsonValue = jsonInfo[" weight_kff" ];
277
+ if (!jsonValue.IsDouble ()) {
278
+ return TConclusionStatus::Fail (" incorrect weight_kff value have to be double" );
279
+ }
280
+ WeightKff = jsonValue.GetDouble ();
281
+ }
266
282
return DoDeserializeFromJson (jsonInfo);
267
283
}
268
284
269
285
TConclusion<std::shared_ptr<IOptimizerPlanner>> BuildPlanner (const TBuildContext& context) const {
270
- return DoBuildPlanner (context);
286
+ auto result = DoBuildPlanner (context);
287
+ if (result.IsFail ()) {
288
+ return result;
289
+ }
290
+ (*result)->WeightKff = WeightKff;
291
+ return result;
271
292
}
272
293
273
294
virtual TString GetClassName () const = 0;
274
295
void SerializeToProto (TProto& proto) const {
275
296
proto.SetNodePortionsCountLimit (NodePortionsCountLimit);
297
+ proto.SetWeightKff (WeightKff);
276
298
DoSerializeToProto (proto);
277
299
}
278
300
@@ -292,6 +314,9 @@ class IOptimizerPlannerConstructor {
292
314
if (proto.HasNodePortionsCountLimit ()) {
293
315
NodePortionsCountLimit = proto.GetNodePortionsCountLimit ();
294
316
}
317
+ if (proto.HasWeightKff ()) {
318
+ WeightKff = proto.GetWeightKff ();
319
+ }
295
320
return DoDeserializeFromProto (proto);
296
321
}
297
322
};
0 commit comments