diff --git a/lib/trino-parquet/src/main/java/io/trino/parquet/reader/PrimitiveColumnReader.java b/lib/trino-parquet/src/main/java/io/trino/parquet/reader/PrimitiveColumnReader.java index 68b6b8b6d2eb..6eba0774a0e8 100644 --- a/lib/trino-parquet/src/main/java/io/trino/parquet/reader/PrimitiveColumnReader.java +++ b/lib/trino-parquet/src/main/java/io/trino/parquet/reader/PrimitiveColumnReader.java @@ -212,8 +212,10 @@ public void prepareNextRead(int batchSize) public ColumnChunk readPrimitive(Field field) { - IntList definitionLevels = new IntArrayList(); - IntList repetitionLevels = new IntArrayList(); + // Pre-allocate these arrays to the necessary size. This saves a substantial amount of + // CPU time by avoiding container resizing. + IntList definitionLevels = new IntArrayList(nextBatchSize); + IntList repetitionLevels = new IntArrayList(nextBatchSize); seek(); BlockBuilder blockBuilder = field.getType().createBlockBuilder(null, nextBatchSize); int valueCount = 0;