@@ -58,7 +58,7 @@ class TDqOutputChannel : public IDqOutputChannel {
58
58
}
59
59
60
60
ui64 GetValuesCount () const override {
61
- return SpilledRowCount + PackedRowCount + ChunkRowCount ;
61
+ return SpilledRowCount + PackedRowCount + PackerCurrentRowCount ;
62
62
}
63
63
64
64
const TDqOutputStats& GetPushStats () const override {
@@ -95,8 +95,12 @@ class TDqOutputChannel : public IDqOutputChannel {
95
95
return ;
96
96
}
97
97
98
+ ui32 rows = Packer.IsBlock () ?
99
+ NKikimr::NMiniKQL::TArrowBlock::From (values[width - 1 ]).GetDatum ().scalar_as <arrow::UInt64Scalar>().value
100
+ : 1 ;
101
+
98
102
if (PushStats.CollectBasic ()) {
99
- PushStats.Rows ++ ;
103
+ PushStats.Rows += rows ;
100
104
PushStats.Chunks ++;
101
105
PushStats.Resume ();
102
106
}
@@ -110,7 +114,8 @@ class TDqOutputChannel : public IDqOutputChannel {
110
114
values[i] = {};
111
115
}
112
116
113
- ChunkRowCount++;
117
+ PackerCurrentRowCount += rows;
118
+ PackerCurrentChunkCount++;
114
119
115
120
size_t packerSize = Packer.PackedSizeEstimate ();
116
121
if (packerSize >= MaxChunkBytes) {
@@ -120,9 +125,12 @@ class TDqOutputChannel : public IDqOutputChannel {
120
125
PushStats.Bytes += Data.back ().Buffer .Size ();
121
126
}
122
127
PackedDataSize += Data.back ().Buffer .Size ();
123
- PackedRowCount += ChunkRowCount;
124
- Data.back ().RowCount = ChunkRowCount;
125
- ChunkRowCount = 0 ;
128
+ PackedRowCount += PackerCurrentRowCount;
129
+ PackedChunkCount += PackerCurrentChunkCount;
130
+ Data.back ().RowCount = PackerCurrentRowCount;
131
+ Data.back ().ChunkCount = PackerCurrentChunkCount;
132
+ PackerCurrentRowCount = 0 ;
133
+ PackerCurrentChunkCount = 0 ;
126
134
packerSize = 0 ;
127
135
}
128
136
@@ -134,11 +142,13 @@ class TDqOutputChannel : public IDqOutputChannel {
134
142
TDqSerializedBatch data;
135
143
data.Proto .SetTransportVersion (TransportVersion);
136
144
data.Proto .SetRows (head.RowCount );
145
+ data.Proto .SetChunks (head.ChunkCount );
137
146
data.SetPayload (std::move (head.Buffer ));
138
147
Storage->Put (NextStoredId++, SaveForSpilling (std::move (data)));
139
148
140
149
PackedDataSize -= bufSize;
141
150
PackedRowCount -= head.RowCount ;
151
+ PackedChunkCount -= head.ChunkCount ;
142
152
143
153
SpilledRowCount += head.RowCount ;
144
154
@@ -199,22 +209,29 @@ class TDqOutputChannel : public IDqOutputChannel {
199
209
} else if (!Data.empty ()) {
200
210
auto & packed = Data.front ();
201
211
PackedRowCount -= packed.RowCount ;
212
+ PackedChunkCount -= packed.ChunkCount ;
202
213
PackedDataSize -= packed.Buffer .Size ();
203
214
data.Proto .SetRows (packed.RowCount );
215
+ data.Proto .SetChunks (packed.ChunkCount );
204
216
data.SetPayload (std::move (packed.Buffer ));
205
217
Data.pop_front ();
206
218
} else {
207
- data.Proto .SetRows (ChunkRowCount);
219
+ data.Proto .SetRows (PackerCurrentRowCount);
220
+ data.Proto .SetChunks (PackerCurrentChunkCount);
208
221
data.SetPayload (FinishPackAndCheckSize ());
209
- ChunkRowCount = 0 ;
222
+ if (PushStats.CollectBasic ()) {
223
+ PushStats.Bytes += data.Payload .Size ();
224
+ }
225
+ PackerCurrentRowCount = 0 ;
226
+ PackerCurrentChunkCount = 0 ;
210
227
}
211
228
212
229
DLOG (" Took " << data.RowCount () << " rows" );
213
230
214
231
if (PopStats.CollectBasic ()) {
215
232
PopStats.Bytes += data.Size ();
216
- PopStats.Rows += data.RowCount ();
217
- PopStats.Chunks ++;
233
+ PopStats.Rows += data.RowCount ();
234
+ PopStats.Chunks ++; // pop chunks do not match push chunks
218
235
if (!IsFull () || FirstStoredId == NextStoredId) {
219
236
PopStats.Resume ();
220
237
}
@@ -256,20 +273,31 @@ class TDqOutputChannel : public IDqOutputChannel {
256
273
data.Clear ();
257
274
data.Proto .SetTransportVersion (TransportVersion);
258
275
if (SpilledRowCount == 0 && PackedRowCount == 0 ) {
259
- data.Proto .SetRows (ChunkRowCount);
276
+ data.Proto .SetRows (PackerCurrentRowCount);
277
+ data.Proto .SetChunks (PackerCurrentChunkCount);
260
278
data.SetPayload (FinishPackAndCheckSize ());
261
- ChunkRowCount = 0 ;
279
+ if (PushStats.CollectBasic ()) {
280
+ PushStats.Bytes += data.Payload .Size ();
281
+ }
282
+ PackerCurrentRowCount = 0 ;
283
+ PackerCurrentChunkCount = 0 ;
262
284
return true ;
263
285
}
264
286
265
287
// Repack all - thats why PopAll should never be used
266
- if (ChunkRowCount ) {
288
+ if (PackerCurrentRowCount ) {
267
289
Data.emplace_back ();
268
290
Data.back ().Buffer = FinishPackAndCheckSize ();
291
+ if (PushStats.CollectBasic ()) {
292
+ PushStats.Bytes += Data.back ().Buffer .Size ();
293
+ }
269
294
PackedDataSize += Data.back ().Buffer .Size ();
270
- PackedRowCount += ChunkRowCount;
271
- Data.back ().RowCount = ChunkRowCount;
272
- ChunkRowCount = 0 ;
295
+ PackedRowCount += PackerCurrentRowCount;
296
+ PackedChunkCount += PackerCurrentChunkCount;
297
+ Data.back ().RowCount = PackerCurrentRowCount;
298
+ Data.back ().ChunkCount = PackerCurrentChunkCount;
299
+ PackerCurrentRowCount = 0 ;
300
+ PackerCurrentChunkCount = 0 ;
273
301
}
274
302
275
303
NKikimr::NMiniKQL::TUnboxedValueBatch rows (OutputType);
@@ -332,7 +360,9 @@ class TDqOutputChannel : public IDqOutputChannel {
332
360
ui64 rows = GetValuesCount ();
333
361
Data.clear ();
334
362
Packer.Clear ();
335
- SpilledRowCount = PackedDataSize = PackedRowCount = ChunkRowCount = 0 ;
363
+ PackedDataSize = 0 ;
364
+ SpilledRowCount = PackedRowCount = PackerCurrentRowCount = 0 ;
365
+ PackedChunkCount = PackerCurrentChunkCount = 0 ;
336
366
FirstStoredId = NextStoredId;
337
367
return rows;
338
368
}
@@ -359,6 +389,7 @@ class TDqOutputChannel : public IDqOutputChannel {
359
389
struct TSerializedBatch {
360
390
TChunkedBuffer Buffer;
361
391
ui64 RowCount = 0 ;
392
+ ui64 ChunkCount = 0 ;
362
393
};
363
394
std::deque<TSerializedBatch> Data;
364
395
@@ -368,8 +399,10 @@ class TDqOutputChannel : public IDqOutputChannel {
368
399
369
400
size_t PackedDataSize = 0 ;
370
401
size_t PackedRowCount = 0 ;
402
+ size_t PackedChunkCount = 0 ;
371
403
372
- size_t ChunkRowCount = 0 ;
404
+ size_t PackerCurrentRowCount = 0 ;
405
+ size_t PackerCurrentChunkCount = 0 ;
373
406
374
407
bool Finished = false ;
375
408
0 commit comments