@@ -309,6 +309,27 @@ class TPartitionStatsCollector : public TActorBootstrapped<TPartitionStatsCollec
309
309
}
310
310
311
311
bool includePathColumn = !record.HasIncludePathColumn () || record.GetIncludePathColumn ();
312
+ bool hasFilter = record.HasFilter ();
313
+ auto matchesFilter = [&](const NKikimrSysView::TPartitionStats& stats) {
314
+ const auto & filter = record.GetFilter ();
315
+ if (filter.HasNotLess ()) {
316
+ if (filter.GetNotLess ().HasCPUCores () && stats.GetCPUCores () < filter.GetNotLess ().GetCPUCores ()) {
317
+ return false ;
318
+ }
319
+ }
320
+ return true ;
321
+ };
322
+ auto addStats = [&](const auto & pathId, const auto & tableStats, ui64 partIdx) {
323
+ auto stats = result->Record .AddStats ();
324
+ auto * key = stats->MutableKey ();
325
+ key->SetOwnerId (pathId.OwnerId );
326
+ key->SetPathId (pathId.LocalPathId );
327
+ key->SetPartIdx (partIdx);
328
+ if (includePathColumn) {
329
+ stats->SetPath (tableStats.Path );
330
+ }
331
+ return stats;
332
+ };
312
333
313
334
auto matchesFilter = [&](const NKikimrSysView::TPartitionStats& stats) {
314
335
if (record.HasFilter ()) {
@@ -335,35 +356,24 @@ class TPartitionStatsCollector : public TActorBootstrapped<TPartitionStatsCollec
335
356
336
357
for (ui64 partIdx = startPartIdx; partIdx < end; ++partIdx) {
337
358
NKikimrSysView::TPartitionStatsResult* stats = nullptr ;
359
+ if (!hasFilter) {
360
+ stats = addStats (pathId, tableStats, partIdx);
361
+ }
338
362
auto shardIdx = tableStats.ShardIndices [partIdx];
339
363
auto part = tableStats.Partitions .find (shardIdx);
340
364
if (part != tableStats.Partitions .end ()) {
341
365
for (const auto & followerStat : part->second .FollowerStats ) {
342
- if (!matchesFilter (followerStat.second )) {
366
+ if (hasFilter && !matchesFilter (followerStat.second )) {
343
367
continue ;
344
368
}
345
- if (stats == nullptr ) {
346
- stats = result-> Record . AddStats ( );
369
+ if (! stats) {
370
+ stats = addStats (pathId, tableStats, partIdx );
347
371
}
348
372
*stats->AddStats () = followerStat.second ;
349
373
}
350
374
}
351
375
352
- if (!stats) {
353
- continue ;
354
- }
355
-
356
- auto * key = stats->MutableKey ();
357
-
358
- key->SetOwnerId (pathId.OwnerId );
359
- key->SetPathId (pathId.LocalPathId );
360
- key->SetPartIdx (partIdx);
361
-
362
- if (includePathColumn) {
363
- stats->SetPath (tableStats.Path );
364
- }
365
-
366
- if (++count == BatchSize) {
376
+ if (stats && ++count == BatchSize) {
367
377
auto * next = result->Record .MutableNext ();
368
378
next->SetOwnerId (pathId.OwnerId );
369
379
next->SetPathId (pathId.LocalPathId );
0 commit comments