From e6f7e59ba4cd7f5547fbd5dc578d988c9ebaec87 Mon Sep 17 00:00:00 2001 From: jerolba Date: Mon, 30 Nov 2026 20:20:59 +0100 Subject: [PATCH] GH-4006: Remove the unused fastutil dependency from parquet-hadoop ### Rationale for this change parquet-hadoop declares and shades it.unimi.dsi:fastutil, but only uses it for a single IntArrayList in ColumnIndexFilterUtils, plus a LongArrayList in one test. That adds roughly 1 MB to the artifact for a single code path. ### What changes are included in this PR? - Replace IntArrayList/IntList in ColumnIndexFilterUtils.filterOffsetIndex with a plain int[] sized by the page count and Arrays.copyOf. - Remove the it.unimi.dsi:fastutil dependency from parquet-hadoop/pom.xml. - Drop the fastutil notice from parquet-hadoop's META-INF/LICENSE, since the jar no longer bundles it. - Update TestParquetMetadataConverter to use Arrays.asList so tests do not need fastutil either. The parquet-hadoop jar shrinks from 1,660,550 to 641,746 bytes and no longer contains shaded/parquet/it/unimi entries. The removed classes remain available at runtime from parquet-column, a compile-scope dependency that shades the same fastutil version under the same shaded.parquet prefix. ### Are these changes tested? Yes. TestParquetMetadataConverter#testColumnIndexConversion and TestColumnIndexFiltering pass; spotless:check and dependency:analyze-only pass. parquet-avro and parquet-hadoop-bundle still build and keep their own fastutil copies. ### Are there any user-facing changes? The parquet-hadoop jar is about 1 MB smaller and no longer duplicates fastutil classes that parquet-column already provides. There is no API or behavior change. Closes #4006 --- parquet-hadoop/pom.xml | 5 ----- .../apache/parquet/hadoop/ColumnIndexFilterUtils.java | 9 +++------ parquet-hadoop/src/main/resources/META-INF/LICENSE | 9 --------- .../format/converter/TestParquetMetadataConverter.java | 7 +++---- 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/parquet-hadoop/pom.xml b/parquet-hadoop/pom.xml index da8bf5eb63..ad8fc1c454 100644 --- a/parquet-hadoop/pom.xml +++ b/parquet-hadoop/pom.xml @@ -164,11 +164,6 @@ commons-pool 1.6 - - it.unimi.dsi - fastutil - ${fastutil.version} - com.github.luben zstd-jni diff --git a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnIndexFilterUtils.java b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnIndexFilterUtils.java index 9c9e2a6cfa..0ef6a5bd6e 100644 --- a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnIndexFilterUtils.java +++ b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnIndexFilterUtils.java @@ -21,8 +21,6 @@ import static org.apache.parquet.hadoop.ParquetFileReaderMetrics.PagesIncluded; import static org.apache.parquet.hadoop.ParquetFileReaderMetrics.PagesSkipped; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntList; import java.util.ArrayList; import java.util.Arrays; import java.util.Formatter; @@ -137,14 +135,13 @@ static OffsetIndex filterOffsetIndex( RowRanges rowRanges, long totalRowCount, org.apache.parquet.ParquetReadOptions options) { - IntList indexMap = new IntArrayList(); + int[] indexMap = new int[offsetIndex.getPageCount()]; int pagesIncluded = 0; int pagesSkipped = 0; for (int i = 0, n = offsetIndex.getPageCount(); i < n; ++i) { long from = offsetIndex.getFirstRowIndex(i); if (rowRanges.isOverlapping(from, offsetIndex.getLastRowIndex(i, totalRowCount))) { - indexMap.add(i); - pagesIncluded++; + indexMap[pagesIncluded++] = i; } else { pagesSkipped++; } @@ -156,7 +153,7 @@ static OffsetIndex filterOffsetIndex( metricsCallback.setValueInt(PagesSkipped.name(), pagesSkipped); } - return new FilteredOffsetIndex(offsetIndex, indexMap.toIntArray()); + return new FilteredOffsetIndex(offsetIndex, Arrays.copyOf(indexMap, pagesIncluded)); } static List calculateOffsetRanges( diff --git a/parquet-hadoop/src/main/resources/META-INF/LICENSE b/parquet-hadoop/src/main/resources/META-INF/LICENSE index 906156fc71..28dd44ab14 100644 --- a/parquet-hadoop/src/main/resources/META-INF/LICENSE +++ b/parquet-hadoop/src/main/resources/META-INF/LICENSE @@ -187,12 +187,3 @@ Copyright: 2012-2014 Twitter Home page: https://github.com/twitter/elephant-bird License: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0) --------------------------------------------------------------------------------- - -This product bundles fastutil in this binary artifact. fastutil provides -type-specific collection implementations. - -Copyright: 2002-2024 Sebastiano Vigna -Home page: https://fastutil.di.unimi.it/ -License: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0) - diff --git a/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java b/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java index 0034f289dc..641c4a8b2f 100644 --- a/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java +++ b/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java @@ -50,7 +50,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import it.unimi.dsi.fastutil.longs.LongArrayList; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -1642,18 +1641,18 @@ public void testColumnIndexConversion() { stats.updateStats(100l); builder.add( stats, - withSizeStats ? new SizeStatistics(type, 0, LongArrayList.of(1, 2), LongArrayList.of(6, 5)) : null); + withSizeStats ? new SizeStatistics(type, 0, Arrays.asList(1L, 2L), Arrays.asList(6L, 5L)) : null); stats = Statistics.createStats(type); stats.incrementNumNulls(111); builder.add( stats, - withSizeStats ? new SizeStatistics(type, 0, LongArrayList.of(3, 4), LongArrayList.of(4, 3)) : null); + withSizeStats ? new SizeStatistics(type, 0, Arrays.asList(3L, 4L), Arrays.asList(4L, 3L)) : null); stats = Statistics.createStats(type); stats.updateStats(200l); stats.updateStats(500l); builder.add( stats, - withSizeStats ? new SizeStatistics(type, 0, LongArrayList.of(5, 6), LongArrayList.of(2, 1)) : null); + withSizeStats ? new SizeStatistics(type, 0, Arrays.asList(5L, 6L), Arrays.asList(2L, 1L)) : null); org.apache.parquet.format.ColumnIndex parquetColumnIndex = ParquetMetadataConverter.toParquetColumnIndex(type, builder.build()); ColumnIndex columnIndex = ParquetMetadataConverter.fromParquetColumnIndex(type, parquetColumnIndex);