|
29 | 29 | import io.trino.parquet.writer.ColumnWriter.BufferData;
|
30 | 30 | import io.trino.spi.Page;
|
31 | 31 | import io.trino.spi.type.Type;
|
32 |
| -import it.unimi.dsi.fastutil.ints.IntArrays; |
33 | 32 | import org.apache.parquet.column.ParquetProperties;
|
34 | 33 | import org.apache.parquet.format.ColumnMetaData;
|
35 | 34 | import org.apache.parquet.format.CompressionCodec;
|
|
46 | 45 | import java.io.Closeable;
|
47 | 46 | import java.io.IOException;
|
48 | 47 | import java.io.OutputStream;
|
49 |
| -import java.util.Arrays; |
50 | 48 | import java.util.List;
|
51 | 49 | import java.util.Map;
|
52 | 50 | import java.util.Optional;
|
@@ -312,27 +310,16 @@ private void flush()
|
312 | 310 | .map(BufferData::getMetaData)
|
313 | 311 | .collect(toImmutableList());
|
314 | 312 |
|
315 |
| - // Since the reader coalesces nearby small reads, it is beneficial to |
316 |
| - // reorder data streams to group columns with small size together |
317 |
| - int[] indexes = new int[columns.size()]; |
318 |
| - Arrays.setAll(indexes, index -> index); |
319 |
| - IntArrays.quickSort(indexes, (index, otherIndex) -> |
320 |
| - Long.compare(columns.get(index).getTotal_compressed_size(), columns.get(otherIndex).getTotal_compressed_size())); |
321 |
| - |
322 |
| - // Ordering of columns in the metadata should remain unchanged. |
323 |
| - // Only the offsets in file at which the columns start may change as a result |
324 |
| - // of reordering column data streams by their compressed size |
325 | 313 | long currentOffset = stripeStartOffset;
|
326 |
| - for (int index : indexes) { |
327 |
| - ColumnMetaData columnMetaData = columns.get(index); |
| 314 | + for (ColumnMetaData columnMetaData : columns) { |
328 | 315 | columnMetaData.setData_page_offset(currentOffset);
|
329 | 316 | currentOffset += columnMetaData.getTotal_compressed_size();
|
330 | 317 | }
|
331 | 318 | updateRowGroups(columns);
|
332 | 319 |
|
333 | 320 | // flush pages
|
334 |
| - for (int index : indexes) { |
335 |
| - bufferDataList.get(index).getData() |
| 321 | + for (BufferData bufferData : bufferDataList) { |
| 322 | + bufferData.getData() |
336 | 323 | .forEach(data -> data.writeData(outputStream));
|
337 | 324 | }
|
338 | 325 | }
|
|
0 commit comments