|
11 | 11 | namespace NKikimr { |
12 | 12 | namespace NTable { |
13 | 13 |
|
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 | | - |
32 | 14 | // Iterates over part index and calculates total row count and data size |
33 | 15 | // This iterator skips pages that are screened. Currently the logic is simple: |
34 | 16 | // if page start key is screened then we assume that the whole previous page is screened |
@@ -82,59 +64,62 @@ class TStatsScreenedPartIterator { |
82 | 64 | return Groups[0]->IsValid(); |
83 | 65 | } |
84 | 66 |
|
85 | | - EReady Next(TPartDataStats& stats) { |
| 67 | + EReady Next(TDataStats& stats) { |
86 | 68 | Y_ABORT_UNLESS(IsValid()); |
87 | 69 |
|
88 | | - auto curPageId = Groups[0]->GetPageId(); |
89 | 70 | LastRowId = Groups[0]->GetRowId(); |
90 | 71 | auto ready = Groups[0]->Next(); |
91 | 72 | if (ready == EReady::Page) { |
| 73 | + Y_DEBUG_ABORT_UNLESS(false, "Shouldn't really happen"); |
92 | 74 | return ready; |
93 | 75 | } |
94 | 76 |
|
95 | 77 | ui64 rowCount = CountUnscreenedRows(GetLastRowId(), GetCurrentRowId()); |
96 | 78 | stats.RowCount += rowCount; |
97 | 79 | if (rowCount) { |
98 | | - AddPageSize(stats.DataSize, curPageId, TGroupId(0)); |
| 80 | + Groups[0]->AddLastDeltaDataSize(stats.DataSize); |
99 | 81 | } |
100 | 82 |
|
101 | 83 | TRowId nextRowId = ready == EReady::Data ? Groups[0]->GetRowId() : Max<TRowId>(); |
102 | 84 | for (auto groupIndex : xrange<ui32>(1, Groups.size())) { |
103 | 85 | while (Groups[groupIndex]->IsValid() && Groups[groupIndex]->GetRowId() < nextRowId) { |
104 | 86 | // eagerly include all data up to the next row id |
105 | | - if (rowCount) { |
106 | | - AddPageSize(stats.DataSize, Groups[groupIndex]->GetPageId(), TGroupId(groupIndex)); |
107 | | - } |
108 | 87 | if (Groups[groupIndex]->Next() == EReady::Page) { |
| 88 | + Y_DEBUG_ABORT_UNLESS(false, "Shouldn't really happen"); |
109 | 89 | ready = EReady::Page; |
110 | 90 | break; |
111 | 91 | } |
| 92 | + if (rowCount) { |
| 93 | + Groups[groupIndex]->AddLastDeltaDataSize(stats.DataSize); |
| 94 | + } |
112 | 95 | } |
113 | 96 | } |
114 | 97 |
|
115 | 98 | if (HistoricGroups) { |
116 | 99 | Y_DEBUG_ABORT_UNLESS(Part->Scheme->HistoryGroup.ColsKeyIdx.size() == 3); |
117 | 100 | while (HistoricGroups[0]->IsValid() && (!HistoricGroups[0]->GetKeyCellsCount() || HistoricGroups[0]->GetKeyCell(0).AsValue<TRowId>() < nextRowId)) { |
118 | 101 | // eagerly include all history up to the next row id |
119 | | - if (rowCount) { |
120 | | - AddPageSize(stats.DataSize, HistoricGroups[0]->GetPageId(), TGroupId(0, true)); |
121 | | - } |
122 | 102 | if (HistoricGroups[0]->Next() == EReady::Page) { |
| 103 | + Y_DEBUG_ABORT_UNLESS(false, "Shouldn't really happen"); |
123 | 104 | ready = EReady::Page; |
124 | 105 | break; |
125 | 106 | } |
| 107 | + if (rowCount) { |
| 108 | + HistoricGroups[0]->AddLastDeltaDataSize(stats.DataSize); |
| 109 | + } |
126 | 110 | } |
127 | 111 | TRowId nextHistoryRowId = HistoricGroups[0]->IsValid() ? HistoricGroups[0]->GetRowId() : Max<TRowId>(); |
128 | 112 | for (auto groupIndex : xrange<ui32>(1, Groups.size())) { |
129 | 113 | while (HistoricGroups[groupIndex]->IsValid() && HistoricGroups[groupIndex]->GetRowId() < nextHistoryRowId) { |
130 | 114 | // eagerly include all data up to the next row id |
131 | | - if (rowCount) { |
132 | | - AddPageSize(stats.DataSize, HistoricGroups[groupIndex]->GetPageId(), TGroupId(groupIndex, true)); |
133 | | - } |
134 | 115 | if (HistoricGroups[groupIndex]->Next() == EReady::Page) { |
| 116 | + Y_DEBUG_ABORT_UNLESS(false, "Shouldn't really happen"); |
135 | 117 | ready = EReady::Page; |
136 | 118 | break; |
137 | 119 | } |
| 120 | + if (rowCount) { |
| 121 | + HistoricGroups[groupIndex]->AddLastDeltaDataSize(stats.DataSize); |
| 122 | + } |
138 | 123 | } |
139 | 124 | } |
140 | 125 | } |
@@ -174,13 +159,6 @@ class TStatsScreenedPartIterator { |
174 | 159 | return LastRowId; |
175 | 160 | } |
176 | 161 |
|
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 | | - |
184 | 162 | void FillKey() { |
185 | 163 | CurrentKey.clear(); |
186 | 164 |
|
@@ -229,7 +207,7 @@ class TStatsScreenedPartIterator { |
229 | 207 | return rowCount; |
230 | 208 | } |
231 | 209 |
|
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 { |
233 | 211 | const auto row = GetLastRowId(); |
234 | 212 | const auto end = GetCurrentRowId(); |
235 | 213 |
|
|
0 commit comments