80
80
import static com .google .common .base .Preconditions .checkState ;
81
81
import static com .google .common .collect .ImmutableList .toImmutableList ;
82
82
import static com .google .common .collect .ImmutableSet .toImmutableSet ;
83
+ import static io .airlift .slice .SizeOf .instanceSize ;
84
+ import static io .airlift .slice .SizeOf .sizeOf ;
83
85
import static io .airlift .slice .Slices .utf8Slice ;
84
86
import static io .trino .parquet .ParquetValidationUtils .validateParquet ;
85
87
import static io .trino .parquet .ParquetWriteValidation .StatisticsValidation ;
@@ -276,6 +278,8 @@ public SourcePage nextPage()
276
278
private class ParquetSourcePage
277
279
implements SourcePage
278
280
{
281
+ private static final long INSTANCE_SIZE = instanceSize (ParquetSourcePage .class );
282
+
279
283
private final int expectedPageId = currentPageId ;
280
284
private final Block [] blocks = new Block [columnFields .size () + (appendRowNumberColumn ? 1 : 0 )];
281
285
private final int rowNumberColumnIndex = appendRowNumberColumn ? columnFields .size () : -1 ;
@@ -287,6 +291,7 @@ private class ParquetSourcePage
287
291
public ParquetSourcePage (int positionCount )
288
292
{
289
293
selectedPositions = new SelectedPositions (positionCount , null );
294
+ retainedSizeInBytes = shallowRetainedSizeInBytes ();
290
295
}
291
296
292
297
@ Override
@@ -307,9 +312,19 @@ public long getRetainedSizeInBytes()
307
312
return retainedSizeInBytes ;
308
313
}
309
314
315
+ private long shallowRetainedSizeInBytes ()
316
+ {
317
+ return INSTANCE_SIZE +
318
+ sizeOf (blocks ) +
319
+ selectedPositions .retainedSizeInBytes ();
320
+ }
321
+
310
322
@ Override
311
323
public void retainedBytesForEachPart (ObjLongConsumer <Object > consumer )
312
324
{
325
+ consumer .accept (this , INSTANCE_SIZE );
326
+ consumer .accept (blocks , sizeOf (blocks ));
327
+ consumer .accept (selectedPositions , selectedPositions .retainedSizeInBytes ());
313
328
for (Block block : blocks ) {
314
329
if (block != null ) {
315
330
block .retainedBytesForEachPart (consumer );
@@ -363,7 +378,7 @@ public Page getPage()
363
378
public void selectPositions (int [] positions , int offset , int size )
364
379
{
365
380
selectedPositions = selectedPositions .selectPositions (positions , offset , size );
366
- retainedSizeInBytes = 0 ;
381
+ retainedSizeInBytes = shallowRetainedSizeInBytes () ;
367
382
for (int i = 0 ; i < blocks .length ; i ++) {
368
383
Block block = blocks [i ];
369
384
if (block != null ) {
@@ -377,6 +392,13 @@ public void selectPositions(int[] positions, int offset, int size)
377
392
378
393
private record SelectedPositions (int positionCount , @ Nullable int [] positions )
379
394
{
395
+ private static final long INSTANCE_SIZE = instanceSize (SelectedPositions .class );
396
+
397
+ public long retainedSizeInBytes ()
398
+ {
399
+ return INSTANCE_SIZE + sizeOf (positions );
400
+ }
401
+
380
402
@ CheckReturnValue
381
403
public Block apply (Block block )
382
404
{
0 commit comments