Skip to content

Commit 214dda5

Browse files
authored
separate evicted and split_compacted portion stats (#14543)
1 parent 60c6e13 commit 214dda5

22 files changed

+302
-375
lines changed

ydb/core/tx/columnshard/columnshard.cpp

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -306,39 +306,53 @@ void TColumnShard::UpdateIndexCounters() {
306306
return;
307307
}
308308

309-
auto& stats = TablesManager.MutablePrimaryIndex().GetTotalStats();
310309
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());
342356
}
343357

344358
ui64 TColumnShard::MemoryUsage() const {
@@ -387,17 +401,13 @@ void TColumnShard::FillOlapStats(const TActorContext& ctx, std::unique_ptr<TEvDa
387401
resourceMetrics->Fill(*ev->Record.MutableTabletMetrics());
388402
}
389403

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());
394406
}
395407

396408
void TColumnShard::FillColumnTableStats(const TActorContext& ctx, std::unique_ptr<TEvDataShard::TEvPeriodicTableStats>& ev) {
397409
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());
401411

402412
LOG_S_DEBUG("There are stats for " << tables.size() << " tables");
403413
for (const auto& [pathId, _] : tables) {
@@ -415,9 +425,7 @@ void TColumnShard::FillColumnTableStats(const TActorContext& ctx, std::unique_pt
415425
resourceMetrics->Fill(*periodicTableStats->MutableTabletMetrics());
416426
}
417427

418-
if (tableStatsBuilder) {
419-
tableStatsBuilder->FillTableStats(pathId, *(periodicTableStats->MutableTableStats()));
420-
}
428+
tableStatsBuilder.FillTableStats(pathId, *(periodicTableStats->MutableTableStats()));
421429

422430
LOG_S_TRACE("Add stats for table, tableLocalID=" << pathId);
423431
}

ydb/core/tx/columnshard/columnshard_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ TColumnShard::TColumnShard(TTabletStorageInfo* info, const TActorId& tablet)
8686
, StatsReportInterval(NYDBTest::TControllers::GetColumnShardController()->GetStatsReportInterval())
8787
, InFlightReadsTracker(StoragesManager, Counters.GetRequestsTracingCounters())
8888
, TablesManager(StoragesManager, std::make_shared<NOlap::NDataAccessorControl::TLocalManager>(nullptr),
89-
std::make_shared<NOlap::TSchemaObjectsCache>(), info->TabletID)
89+
std::make_shared<NOlap::TSchemaObjectsCache>(), Counters.GetPortionIndexCounters(), info->TabletID)
9090
, Subscribers(std::make_shared<NSubscriber::TManager>(*this))
9191
, PipeClientCache(NTabletPipe::CreateBoundedClientCache(new NTabletPipe::TBoundedClientCacheConfig(), GetPipeClientConfig()))
9292
, InsertTable(std::make_unique<NOlap::TInsertTable>())

ydb/core/tx/columnshard/counters/aggregation/table_stats.h

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,28 @@ class TTableStatsBuilder {
1111
private:
1212
TCountersManager& Counters;
1313
const NTabletFlatExecutor::NFlatExecutorSetup::IExecutor& Executor;
14-
NOlap::IColumnEngine& ColumnEngine;
1514

16-
void FillPortionStats(::NKikimrTableStats::TTableStats& to, const NOlap::TColumnEngineStats::TPortionsStats& from) const {
17-
to.SetRowCount(from.Rows);
18-
ui64 bytesInBlobStorage = 0;
19-
for (const auto& [channel, bytes] : from.BytesByChannel) {
15+
void FillPortionStats(::NKikimrTableStats::TTableStats& to, const NOlap::TSimplePortionsGroupInfo& from) const {
16+
to.SetRowCount(from.GetRecordsCount());
17+
for (const auto& [channel, bytes] : from.GetBytesByChannel()) {
2018
auto item = to.AddChannels();
2119
item->SetChannel(channel);
2220
item->SetDataSize(bytes);
23-
bytesInBlobStorage += bytes;
2421
}
25-
to.SetDataSize(bytesInBlobStorage);
22+
to.SetDataSize(from.GetBlobBytes());
2623
}
2724

2825
public:
29-
TTableStatsBuilder(
30-
TCountersManager& counters, const NTabletFlatExecutor::NFlatExecutorSetup::IExecutor* executor, NOlap::IColumnEngine& columnEngine)
26+
TTableStatsBuilder(TCountersManager& counters, const NTabletFlatExecutor::NFlatExecutorSetup::IExecutor* executor)
3127
: Counters(counters)
32-
, Executor(*executor)
33-
, ColumnEngine(columnEngine) {
28+
, Executor(*executor) {
3429
}
3530

3631
void FillTableStats(ui64 pathId, ::NKikimrTableStats::TTableStats& tableStats) {
3732
Counters.FillTableStats(pathId, tableStats);
3833

39-
auto columnEngineStats = ColumnEngine.GetStats().FindPtr(pathId);
40-
if (columnEngineStats && *columnEngineStats) {
41-
auto activeStats = (*columnEngineStats)->Active();
42-
FillPortionStats(tableStats, activeStats);
43-
}
34+
auto activeStats = Counters.GetPortionIndexCounters()->GetTableStats(pathId, TPortionIndexStats::TActivePortions());
35+
FillPortionStats(tableStats, activeStats);
4436
}
4537

4638
void FillTotalTableStats(::NKikimrTableStats::TTableStats& tableStats) {
@@ -49,7 +41,7 @@ class TTableStatsBuilder {
4941
tableStats.SetInFlightTxCount(Executor.GetStats().TxInFly);
5042
tableStats.SetHasLoanedParts(Executor.HasLoanedParts());
5143

52-
auto activeStats = ColumnEngine.GetTotalStats().Active();
44+
auto activeStats = Counters.GetPortionIndexCounters()->GetTotalStats(TPortionIndexStats::TActivePortions());
5345
FillPortionStats(tableStats, activeStats);
5446
}
5547
};

ydb/core/tx/columnshard/counters/counters_manager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "column_tables.h"
55
#include "columnshard.h"
66
#include "indexation.h"
7+
#include "portion_index.h"
78
#include "req_tracer.h"
89
#include "scan.h"
910
#include "tablet_counters.h"
@@ -28,6 +29,7 @@ class TCountersManager {
2829

2930
YDB_READONLY_DEF(std::shared_ptr<TBackgroundControllerCounters>, BackgroundControllerCounters);
3031
YDB_READONLY_DEF(std::shared_ptr<TColumnTablesCounters>, ColumnTablesCounters);
32+
YDB_READONLY_DEF(std::shared_ptr<TPortionIndexStats>, PortionIndexCounters);
3133

3234
YDB_READONLY(TCSCounters, CSCounters, TCSCounters());
3335
YDB_READONLY(TIndexationCounters, EvictionCounters, TIndexationCounters("Eviction"));
@@ -43,6 +45,7 @@ class TCountersManager {
4345
, WritesMonitor(std::make_shared<TWritesMonitor>(tabletCounters))
4446
, BackgroundControllerCounters(std::make_shared<TBackgroundControllerCounters>())
4547
, ColumnTablesCounters(std::make_shared<TColumnTablesCounters>())
48+
, PortionIndexCounters(std::make_shared<TPortionIndexStats>())
4649
, RequestsTracingCounters(std::make_shared<TRequestsTracerCounters>())
4750
, SubscribeCounters(std::make_shared<NOlap::NResourceBroker::NSubscribe::TSubscriberCounters>()) {
4851
}

ydb/core/tx/columnshard/counters/engine_logs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void TEngineLogsCounters::OnActualizationTask(const ui32 evictCount, const ui32
8181
}
8282

8383
void TEngineLogsCounters::TPortionsInfoGuard::OnNewPortion(const std::shared_ptr<NOlap::TPortionInfo>& portion) const {
84-
const ui32 producedId = (ui32)(portion->HasRemoveSnapshot() ? NOlap::NPortion::EProduced::INACTIVE : portion->GetMeta().Produced);
84+
const ui32 producedId = (ui32)portion->GetProduced();
8585
Y_ABORT_UNLESS(producedId < BlobGuards.size());
8686
for (auto&& blobId : portion->GetBlobIds()) {
8787
BlobGuards[producedId]->Add(blobId.BlobSize(), blobId.BlobSize());
@@ -91,7 +91,7 @@ void TEngineLogsCounters::TPortionsInfoGuard::OnNewPortion(const std::shared_ptr
9191
}
9292

9393
void TEngineLogsCounters::TPortionsInfoGuard::OnDropPortion(const std::shared_ptr<NOlap::TPortionInfo>& portion) const {
94-
const ui32 producedId = (ui32)(portion->HasRemoveSnapshot() ? NOlap::NPortion::EProduced::INACTIVE : portion->GetMeta().Produced);
94+
const ui32 producedId = (ui32)portion->GetProduced();
9595
Y_ABORT_UNLESS(producedId < BlobGuards.size());
9696
THashSet<NOlap::TUnifiedBlobId> blobIds;
9797
for (auto&& blobId : portion->GetBlobIds()) {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include "portion_index.h"
2+
3+
#include <ydb/core/tx/columnshard/engines/portions/portion_info.h>
4+
5+
namespace NKikimr::NColumnShard {
6+
7+
TPortionIndexStats::TPortionClass::TPortionClass(const NOlap::TPortionInfo& portion) {
8+
if (portion.HasRemoveSnapshot()) {
9+
Produced = NOlap::NPortion::EProduced::INACTIVE;
10+
} else if (portion.GetTierNameDef(NOlap::NBlobOperations::TGlobal::DefaultStorageId) != NOlap::NBlobOperations::TGlobal::DefaultStorageId) {
11+
Produced = NOlap::NPortion::EProduced::EVICTED;
12+
} else {
13+
Produced = portion.GetMeta().GetProduced();
14+
}
15+
}
16+
17+
void TPortionIndexStats::AddPortion(const NOlap::TPortionInfo& portion) {
18+
TPortionClass portionClass(portion);
19+
TotalStats[portionClass].AddPortion(portion);
20+
StatsByPathId[portion.GetPathId()][portionClass].AddPortion(portion);
21+
}
22+
23+
void TPortionIndexStats::RemovePortion(const NOlap::TPortionInfo& portion) {
24+
TPortionClass portionClass(portion);
25+
26+
{
27+
auto findClass = TotalStats.find(portionClass);
28+
AFL_VERIFY(!findClass.IsEnd())("path_id", portion.GetPathId());
29+
findClass->second.RemovePortion(portion);
30+
if (findClass->second.IsEmpty()) {
31+
TotalStats.erase(findClass);
32+
}
33+
}
34+
35+
{
36+
auto findPathId = StatsByPathId.find(portion.GetPathId());
37+
AFL_VERIFY(!findPathId.IsEnd())("path_id", portion.GetPathId());
38+
auto findClass = findPathId->second.find(portionClass);
39+
AFL_VERIFY(!findClass.IsEnd())("path_id", portion.GetPathId());
40+
findClass->second.RemovePortion(portion);
41+
if (findClass->second.IsEmpty()) {
42+
findPathId->second.erase(findClass);
43+
if (findPathId->second.empty()) {
44+
StatsByPathId.erase(findPathId);
45+
}
46+
}
47+
}
48+
}
49+
50+
} // namespace NKikimr::NColumnShard
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#pragma once
2+
3+
#include "portions.h"
4+
#include <ydb/core/tx/columnshard/common/portion.h>
5+
6+
namespace NKikimr::NColumnShard {
7+
8+
class TPortionIndexStats {
9+
public:
10+
class TPortionClass {
11+
private:
12+
YDB_READONLY_DEF(NOlap::NPortion::EProduced, Produced);
13+
14+
public:
15+
TPortionClass(const NOlap::TPortionInfo& portion);
16+
17+
operator size_t() const {
18+
return (ui64)Produced;
19+
}
20+
};
21+
22+
class IStatsSelector {
23+
public:
24+
~IStatsSelector() = default;
25+
26+
public:
27+
virtual bool Select(const TPortionClass& portionClass) const = 0;
28+
};
29+
30+
private:
31+
using TStatsByClass = THashMap<TPortionClass, NOlap::TSimplePortionsGroupInfo>;
32+
TStatsByClass TotalStats;
33+
THashMap<ui64, TStatsByClass> StatsByPathId;
34+
35+
static NOlap::TSimplePortionsGroupInfo SelectStats(const TStatsByClass& container, const IStatsSelector& selector) {
36+
NOlap::TSimplePortionsGroupInfo result;
37+
for (const auto& [portionClass, stats] : container) {
38+
if (selector.Select(portionClass)) {
39+
result += stats;
40+
}
41+
}
42+
return result;
43+
}
44+
45+
public:
46+
void AddPortion(const NOlap::TPortionInfo& portion);
47+
void RemovePortion(const NOlap::TPortionInfo& portion);
48+
49+
NOlap::TSimplePortionsGroupInfo GetTotalStats(const IStatsSelector& selector) const {
50+
return SelectStats(TotalStats, selector);
51+
}
52+
53+
NOlap::TSimplePortionsGroupInfo GetTableStats(const ui64 pathId, const IStatsSelector& selector) const {
54+
if (auto* findTable = StatsByPathId.FindPtr(pathId)) {
55+
return SelectStats(*findTable, selector);
56+
}
57+
return {};
58+
}
59+
60+
ui64 GetTablesCount() const {
61+
return StatsByPathId.size();
62+
}
63+
64+
public:
65+
class TActivePortions : public IStatsSelector {
66+
public:
67+
bool Select(const TPortionClass& portionClass) const override {
68+
return portionClass.GetProduced() == NOlap::NPortion::EProduced::INSERTED ||
69+
portionClass.GetProduced() == NOlap::NPortion::EProduced::COMPACTED ||
70+
portionClass.GetProduced() == NOlap::NPortion::EProduced::SPLIT_COMPACTED;
71+
}
72+
};
73+
74+
template <NOlap::NPortion::EProduced Type>
75+
class TPortionsByType : public IStatsSelector {
76+
public:
77+
bool Select(const TPortionClass& portionClass) const override {
78+
return portionClass.GetProduced() == Type;
79+
}
80+
};
81+
};
82+
83+
}

ydb/core/tx/columnshard/counters/portions.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,40 @@ void TSimplePortionsGroupInfo::AddPortion(const std::shared_ptr<const NOlap::TPo
2626
AddPortion(*p);
2727
}
2828
void TSimplePortionsGroupInfo::AddPortion(const TPortionInfo& p) {
29+
Blobs += p.GetBlobIdsCount();
2930
BlobBytes += p.GetTotalBlobBytes();
3031
RawBytes += p.GetTotalRawBytes();
3132
Count += 1;
3233
RecordsCount += p.GetRecordsCount();
34+
for (const auto& blob : p.GetBlobIds()) {
35+
BytesByChannel[blob.Channel()] += blob.BlobSize();
36+
}
3337
}
3438

3539
void TSimplePortionsGroupInfo::RemovePortion(const std::shared_ptr<const NOlap::TPortionInfo>& p) {
3640
AFL_VERIFY(p);
3741
RemovePortion(*p);
3842
}
3943
void TSimplePortionsGroupInfo::RemovePortion(const TPortionInfo& p) {
44+
Blobs -= p.GetBlobIdsCount();
4045
BlobBytes -= p.GetTotalBlobBytes();
4146
RawBytes -= p.GetTotalRawBytes();
4247
Count -= 1;
4348
RecordsCount -= p.GetRecordsCount();
49+
AFL_VERIFY(Blobs >= 0);
4450
AFL_VERIFY(RawBytes >= 0);
4551
AFL_VERIFY(BlobBytes >= 0);
4652
AFL_VERIFY(Count >= 0);
4753
AFL_VERIFY(RecordsCount >= 0);
54+
for (const auto& blob : p.GetBlobIds()) {
55+
auto findChannel = BytesByChannel.find(blob.Channel());
56+
AFL_VERIFY(!findChannel.IsEnd())("blob", blob.ToStringLegacy());
57+
findChannel->second -= blob.BlobSize();
58+
AFL_VERIFY(findChannel->second >= 0);
59+
if (!findChannel->second) {
60+
BytesByChannel.erase(findChannel);
61+
}
62+
}
4863
}
4964

5065
} // namespace NKikimr::NOlap

0 commit comments

Comments
 (0)