Skip to content

Commit 825f560

Browse files
authored
Merge 12ab234 into 10a3ce3
2 parents 10a3ce3 + 12ab234 commit 825f560

13 files changed

+239
-240
lines changed

ydb/core/tablet_flat/flat_part_index_iter.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ class TPartIndexIt : public IIndexIter, public IStatsPartGroupIterator {
9797
return bool(Iter);
9898
}
9999

100+
void AddLastDeltaDataSize(TChanneledDataSize& dataSize) override {
101+
Y_DEBUG_ABORT_UNLESS(Index);
102+
Y_DEBUG_ABORT_UNLESS(Iter.Off());
103+
TPageId pageId = (Iter - 1)->GetPageId();
104+
ui64 delta = Part->GetPageSize(pageId, GroupId);
105+
ui8 channel = Part->GetGroupChannel(GroupId);
106+
dataSize.Add(delta, channel);
107+
}
108+
100109
// for precharge and TForward only
101110
TIndex* TryLoadRaw() {
102111
return TryGetIndex();

ydb/core/tablet_flat/flat_part_store.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ class TPartStore : public TPart, public IBundle {
8585
return EPage(PageCollections[groupId.Index]->PageCollection->Page(id).Type);
8686
}
8787

88-
ui8 GetPageChannel(NPage::TPageId id, NPage::TGroupId groupId) const override
88+
ui8 GetGroupChannel(NPage::TGroupId groupId) const override
8989
{
90-
Y_UNUSED(id);
9190
Y_ABORT_UNLESS(groupId.Index < PageCollections.size());
9291
return PageCollections[groupId.Index]->Id.Channel();
9392
}

ydb/core/tablet_flat/flat_stat_part.h

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,6 @@
1111
namespace NKikimr {
1212
namespace NTable {
1313

14-
struct TPartDataSize {
15-
ui64 Size = 0;
16-
TVector<ui64> ByChannel = { };
17-
18-
void Add(ui64 size, ui8 channel) {
19-
Size += size;
20-
if (!(channel < ByChannel.size())) {
21-
ByChannel.resize(channel + 1);
22-
}
23-
ByChannel[channel] += size;
24-
}
25-
};
26-
27-
struct TPartDataStats {
28-
ui64 RowCount = 0;
29-
TPartDataSize DataSize = { };
30-
};
31-
3214
// Iterates over part index and calculates total row count and data size
3315
// This iterator skips pages that are screened. Currently the logic is simple:
3416
// if page start key is screened then we assume that the whole previous page is screened
@@ -82,59 +64,62 @@ class TStatsScreenedPartIterator {
8264
return Groups[0]->IsValid();
8365
}
8466

85-
EReady Next(TPartDataStats& stats) {
67+
EReady Next(TDataStats& stats) {
8668
Y_ABORT_UNLESS(IsValid());
8769

88-
auto curPageId = Groups[0]->GetPageId();
8970
LastRowId = Groups[0]->GetRowId();
9071
auto ready = Groups[0]->Next();
9172
if (ready == EReady::Page) {
73+
Y_DEBUG_ABORT_UNLESS(false, "Shouldn't really happen");
9274
return ready;
9375
}
9476

9577
ui64 rowCount = CountUnscreenedRows(GetLastRowId(), GetCurrentRowId());
9678
stats.RowCount += rowCount;
9779
if (rowCount) {
98-
AddPageSize(stats.DataSize, curPageId, TGroupId(0));
80+
Groups[0]->AddLastDeltaDataSize(stats.DataSize);
9981
}
10082

10183
TRowId nextRowId = ready == EReady::Data ? Groups[0]->GetRowId() : Max<TRowId>();
10284
for (auto groupIndex : xrange<ui32>(1, Groups.size())) {
10385
while (Groups[groupIndex]->IsValid() && Groups[groupIndex]->GetRowId() < nextRowId) {
10486
// eagerly include all data up to the next row id
105-
if (rowCount) {
106-
AddPageSize(stats.DataSize, Groups[groupIndex]->GetPageId(), TGroupId(groupIndex));
107-
}
10887
if (Groups[groupIndex]->Next() == EReady::Page) {
88+
Y_DEBUG_ABORT_UNLESS(false, "Shouldn't really happen");
10989
ready = EReady::Page;
11090
break;
11191
}
92+
if (rowCount) {
93+
Groups[groupIndex]->AddLastDeltaDataSize(stats.DataSize);
94+
}
11295
}
11396
}
11497

11598
if (HistoricGroups) {
11699
Y_DEBUG_ABORT_UNLESS(Part->Scheme->HistoryGroup.ColsKeyIdx.size() == 3);
117100
while (HistoricGroups[0]->IsValid() && (!HistoricGroups[0]->GetKeyCellsCount() || HistoricGroups[0]->GetKeyCell(0).AsValue<TRowId>() < nextRowId)) {
118101
// eagerly include all history up to the next row id
119-
if (rowCount) {
120-
AddPageSize(stats.DataSize, HistoricGroups[0]->GetPageId(), TGroupId(0, true));
121-
}
122102
if (HistoricGroups[0]->Next() == EReady::Page) {
103+
Y_DEBUG_ABORT_UNLESS(false, "Shouldn't really happen");
123104
ready = EReady::Page;
124105
break;
125106
}
107+
if (rowCount) {
108+
HistoricGroups[0]->AddLastDeltaDataSize(stats.DataSize);
109+
}
126110
}
127111
TRowId nextHistoryRowId = HistoricGroups[0]->IsValid() ? HistoricGroups[0]->GetRowId() : Max<TRowId>();
128112
for (auto groupIndex : xrange<ui32>(1, Groups.size())) {
129113
while (HistoricGroups[groupIndex]->IsValid() && HistoricGroups[groupIndex]->GetRowId() < nextHistoryRowId) {
130114
// eagerly include all data up to the next row id
131-
if (rowCount) {
132-
AddPageSize(stats.DataSize, HistoricGroups[groupIndex]->GetPageId(), TGroupId(groupIndex, true));
133-
}
134115
if (HistoricGroups[groupIndex]->Next() == EReady::Page) {
116+
Y_DEBUG_ABORT_UNLESS(false, "Shouldn't really happen");
135117
ready = EReady::Page;
136118
break;
137119
}
120+
if (rowCount) {
121+
HistoricGroups[groupIndex]->AddLastDeltaDataSize(stats.DataSize);
122+
}
138123
}
139124
}
140125
}
@@ -174,13 +159,6 @@ class TStatsScreenedPartIterator {
174159
return LastRowId;
175160
}
176161

177-
void AddPageSize(TPartDataSize& stats, TPageId pageId, TGroupId groupId) const {
178-
// TODO: move to IStatsPartGroupIterator
179-
ui64 size = Part->GetPageSize(pageId, groupId);
180-
ui8 channel = Part->GetPageChannel(pageId, groupId);
181-
stats.Add(size, channel);
182-
}
183-
184162
void FillKey() {
185163
CurrentKey.clear();
186164

@@ -229,7 +207,7 @@ class TStatsScreenedPartIterator {
229207
return rowCount;
230208
}
231209

232-
void AddBlobsSize(TPartDataSize& stats, const TFrames* frames, ELargeObj lob, ui32 &prevPage) noexcept {
210+
void AddBlobsSize(TChanneledDataSize& stats, const TFrames* frames, ELargeObj lob, ui32 &prevPage) noexcept {
233211
const auto row = GetLastRowId();
234212
const auto end = GetCurrentRowId();
235213

0 commit comments

Comments
 (0)