@@ -306,39 +306,53 @@ void TColumnShard::UpdateIndexCounters() {
306
306
return ;
307
307
}
308
308
309
- auto & stats = TablesManager.MutablePrimaryIndex ().GetTotalStats ();
310
309
const std::shared_ptr<const TTabletCountersHandle>& counters = Counters.GetTabletCounters ();
311
- counters->SetCounter (COUNTER_INDEX_TABLES, stats.Tables );
312
- counters->SetCounter (COUNTER_INSERTED_PORTIONS, stats.GetInsertedStats ().Portions );
313
- counters->SetCounter (COUNTER_INSERTED_BLOBS, stats.GetInsertedStats ().Blobs );
314
- counters->SetCounter (COUNTER_INSERTED_ROWS, stats.GetInsertedStats ().Rows );
315
- counters->SetCounter (COUNTER_INSERTED_BYTES, stats.GetInsertedStats ().Bytes );
316
- counters->SetCounter (COUNTER_INSERTED_RAW_BYTES, stats.GetInsertedStats ().RawBytes );
317
- counters->SetCounter (COUNTER_COMPACTED_PORTIONS, stats.GetCompactedStats ().Portions );
318
- counters->SetCounter (COUNTER_COMPACTED_BLOBS, stats.GetCompactedStats ().Blobs );
319
- counters->SetCounter (COUNTER_COMPACTED_ROWS, stats.GetCompactedStats ().Rows );
320
- counters->SetCounter (COUNTER_COMPACTED_BYTES, stats.GetCompactedStats ().Bytes );
321
- counters->SetCounter (COUNTER_COMPACTED_RAW_BYTES, stats.GetCompactedStats ().RawBytes );
322
- counters->SetCounter (COUNTER_SPLIT_COMPACTED_PORTIONS, stats.GetSplitCompactedStats ().Portions );
323
- counters->SetCounter (COUNTER_SPLIT_COMPACTED_BLOBS, stats.GetSplitCompactedStats ().Blobs );
324
- counters->SetCounter (COUNTER_SPLIT_COMPACTED_ROWS, stats.GetSplitCompactedStats ().Rows );
325
- counters->SetCounter (COUNTER_SPLIT_COMPACTED_BYTES, stats.GetSplitCompactedStats ().Bytes );
326
- counters->SetCounter (COUNTER_SPLIT_COMPACTED_RAW_BYTES, stats.GetSplitCompactedStats ().RawBytes );
327
- counters->SetCounter (COUNTER_INACTIVE_PORTIONS, stats.GetInactiveStats ().Portions );
328
- counters->SetCounter (COUNTER_INACTIVE_BLOBS, stats.GetInactiveStats ().Blobs );
329
- counters->SetCounter (COUNTER_INACTIVE_ROWS, stats.GetInactiveStats ().Rows );
330
- counters->SetCounter (COUNTER_INACTIVE_BYTES, stats.GetInactiveStats ().Bytes );
331
- counters->SetCounter (COUNTER_INACTIVE_RAW_BYTES, stats.GetInactiveStats ().RawBytes );
332
- counters->SetCounter (COUNTER_EVICTED_PORTIONS, stats.GetEvictedStats ().Portions );
333
- counters->SetCounter (COUNTER_EVICTED_BLOBS, stats.GetEvictedStats ().Blobs );
334
- counters->SetCounter (COUNTER_EVICTED_ROWS, stats.GetEvictedStats ().Rows );
335
- counters->SetCounter (COUNTER_EVICTED_BYTES, stats.GetEvictedStats ().Bytes );
336
- counters->SetCounter (COUNTER_EVICTED_RAW_BYTES, stats.GetEvictedStats ().RawBytes );
337
-
338
- LOG_S_DEBUG (" Index: tables " << stats.Tables << " inserted " << stats.GetInsertedStats ().DebugString () << " compacted "
339
- << stats.GetCompactedStats ().DebugString () << " s-compacted " << stats.GetSplitCompactedStats ().DebugString ()
340
- << " inactive " << stats.GetInactiveStats ().DebugString () << " evicted "
341
- << stats.GetEvictedStats ().DebugString () << " at tablet " << TabletID ());
310
+ counters->SetCounter (COUNTER_INDEX_TABLES, Counters.GetPortionIndexCounters ()->GetTablesCount ());
311
+
312
+ auto insertedStats =
313
+ Counters.GetPortionIndexCounters ()->GetTotalStats (TPortionIndexStats::TPortionsByType<NOlap::NPortion::EProduced::INSERTED>());
314
+ counters->SetCounter (COUNTER_INSERTED_PORTIONS, insertedStats.GetCount ());
315
+ counters->SetCounter (COUNTER_INSERTED_BLOBS, insertedStats.GetBlobs ());
316
+ counters->SetCounter (COUNTER_INSERTED_ROWS, insertedStats.GetRecordsCount ());
317
+ counters->SetCounter (COUNTER_INSERTED_BYTES, insertedStats.GetBlobBytes ());
318
+ counters->SetCounter (COUNTER_INSERTED_RAW_BYTES, insertedStats.GetRawBytes ());
319
+
320
+ auto compactedStats =
321
+ Counters.GetPortionIndexCounters ()->GetTotalStats (TPortionIndexStats::TPortionsByType<NOlap::NPortion::EProduced::COMPACTED>());
322
+ counters->SetCounter (COUNTER_COMPACTED_PORTIONS, compactedStats.GetCount ());
323
+ counters->SetCounter (COUNTER_COMPACTED_BLOBS, compactedStats.GetBlobs ());
324
+ counters->SetCounter (COUNTER_COMPACTED_ROWS, compactedStats.GetRecordsCount ());
325
+ counters->SetCounter (COUNTER_COMPACTED_BYTES, compactedStats.GetBlobBytes ());
326
+ counters->SetCounter (COUNTER_COMPACTED_RAW_BYTES, compactedStats.GetRawBytes ());
327
+
328
+ auto splitCompactedStats =
329
+ Counters.GetPortionIndexCounters ()->GetTotalStats (TPortionIndexStats::TPortionsByType<NOlap::NPortion::EProduced::SPLIT_COMPACTED>());
330
+ counters->SetCounter (COUNTER_SPLIT_COMPACTED_PORTIONS, splitCompactedStats.GetCount ());
331
+ counters->SetCounter (COUNTER_SPLIT_COMPACTED_BLOBS, splitCompactedStats.GetBlobs ());
332
+ counters->SetCounter (COUNTER_SPLIT_COMPACTED_ROWS, splitCompactedStats.GetRecordsCount ());
333
+ counters->SetCounter (COUNTER_SPLIT_COMPACTED_BYTES, splitCompactedStats.GetBlobBytes ());
334
+ counters->SetCounter (COUNTER_SPLIT_COMPACTED_RAW_BYTES, splitCompactedStats.GetRawBytes ());
335
+
336
+ auto inactiveStats =
337
+ Counters.GetPortionIndexCounters ()->GetTotalStats (TPortionIndexStats::TPortionsByType<NOlap::NPortion::EProduced::INACTIVE>());
338
+ counters->SetCounter (COUNTER_INACTIVE_PORTIONS, inactiveStats.GetCount ());
339
+ counters->SetCounter (COUNTER_INACTIVE_BLOBS, inactiveStats.GetBlobs ());
340
+ counters->SetCounter (COUNTER_INACTIVE_ROWS, inactiveStats.GetRecordsCount ());
341
+ counters->SetCounter (COUNTER_INACTIVE_BYTES, inactiveStats.GetBlobBytes ());
342
+ counters->SetCounter (COUNTER_INACTIVE_RAW_BYTES, inactiveStats.GetRawBytes ());
343
+
344
+ auto evictedStats =
345
+ Counters.GetPortionIndexCounters ()->GetTotalStats (TPortionIndexStats::TPortionsByType<NOlap::NPortion::EProduced::EVICTED>());
346
+ counters->SetCounter (COUNTER_EVICTED_PORTIONS, evictedStats.GetCount ());
347
+ counters->SetCounter (COUNTER_EVICTED_BLOBS, evictedStats.GetBlobs ());
348
+ counters->SetCounter (COUNTER_EVICTED_ROWS, evictedStats.GetRecordsCount ());
349
+ counters->SetCounter (COUNTER_EVICTED_BYTES, evictedStats.GetBlobBytes ());
350
+ counters->SetCounter (COUNTER_EVICTED_RAW_BYTES, evictedStats.GetRawBytes ());
351
+
352
+ LOG_S_DEBUG (" Index: tables " << Counters.GetPortionIndexCounters ()->GetTablesCount () << " inserted " << insertedStats.DebugString ()
353
+ << " compacted " << compactedStats.DebugString () << " s-compacted " << splitCompactedStats.DebugString ()
354
+ << " inactive " << inactiveStats.DebugString () << " evicted " << evictedStats.DebugString () << " at tablet "
355
+ << TabletID ());
342
356
}
343
357
344
358
ui64 TColumnShard::MemoryUsage () const {
@@ -387,17 +401,13 @@ void TColumnShard::FillOlapStats(const TActorContext& ctx, std::unique_ptr<TEvDa
387
401
resourceMetrics->Fill (*ev->Record .MutableTabletMetrics ());
388
402
}
389
403
390
- if (TablesManager.HasPrimaryIndex ()) {
391
- TTableStatsBuilder statsBuilder (Counters, Executor (), TablesManager.MutablePrimaryIndex ());
392
- statsBuilder.FillTotalTableStats (*ev->Record .MutableTableStats ());
393
- }
404
+ TTableStatsBuilder statsBuilder (Counters, Executor ());
405
+ statsBuilder.FillTotalTableStats (*ev->Record .MutableTableStats ());
394
406
}
395
407
396
408
void TColumnShard::FillColumnTableStats (const TActorContext& ctx, std::unique_ptr<TEvDataShard::TEvPeriodicTableStats>& ev) {
397
409
auto tables = TablesManager.GetTables ();
398
- std::optional<TTableStatsBuilder> tableStatsBuilder =
399
- TablesManager.HasPrimaryIndex () ? std::make_optional<TTableStatsBuilder>(Counters, Executor (), TablesManager.MutablePrimaryIndex ())
400
- : std::nullopt;
410
+ TTableStatsBuilder tableStatsBuilder (Counters, Executor ());
401
411
402
412
LOG_S_DEBUG (" There are stats for " << tables.size () << " tables" );
403
413
for (const auto & [pathId, _] : tables) {
@@ -415,9 +425,7 @@ void TColumnShard::FillColumnTableStats(const TActorContext& ctx, std::unique_pt
415
425
resourceMetrics->Fill (*periodicTableStats->MutableTabletMetrics ());
416
426
}
417
427
418
- if (tableStatsBuilder) {
419
- tableStatsBuilder->FillTableStats (pathId, *(periodicTableStats->MutableTableStats ()));
420
- }
428
+ tableStatsBuilder.FillTableStats (pathId, *(periodicTableStats->MutableTableStats ()));
421
429
422
430
LOG_S_TRACE (" Add stats for table, tableLocalID=" << pathId);
423
431
}
0 commit comments