nastra commented on code in PR #16363: URL: https://github.com/apache/iceberg/pull/16363#discussion_r3529857481
########## parquet/src/test/java/org/apache/iceberg/parquet/TestParquetAdaptiveBloomFilter.java: ########## @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.parquet; + +import static org.apache.iceberg.TableProperties.PARQUET_BLOOM_FILTER_ADAPTIVE_ENABLED; +import static org.apache.iceberg.TableProperties.PARQUET_BLOOM_FILTER_COLUMN_ENABLED_PREFIX; +import static org.apache.iceberg.TableProperties.PARQUET_BLOOM_FILTER_MAX_BYTES; +import static org.apache.iceberg.types.Types.NestedField.required; +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import org.apache.avro.generic.GenericData; +import org.apache.avro.generic.GenericRecordBuilder; +import org.apache.iceberg.Files; +import org.apache.iceberg.Schema; +import org.apache.iceberg.avro.AvroSchemaUtil; +import org.apache.iceberg.io.FileAppender; +import org.apache.iceberg.io.OutputFile; +import org.apache.iceberg.types.Types; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +/** + * Tests for the adaptive bloom filter sizing TBLPROPERTY ({@code + * write.parquet.bloom-filter-adaptive-enabled}). + * + * <p>Without adaptive sizing, parquet-mr's {@code ColumnValueCollector.initBloomFilter} allocates a + * fixed {@code bloom-filter-max-bytes} buffer per bloom-enabled column regardless of actual NDV + * (the {@code !ndv.isPresent() && !adaptive} branch calls {@code new BlockSplitBloomFilter( + * maxBloomFilterSize, maxBloomFilterSize)}). For low-row-count writes this produces a file + * dominated by an empty bloom filter buffer. The adaptive flag (PARQUET-2254) makes parquet-mr pick + * the smallest of N candidate filter sizes that satisfies actual NDV at FPP. + * + * <p>These tests use the createWriterFunc code path because that is the path Iceberg uses for Spark + * and Flink data writes; the legacy ParquetWriteBuilder path goes through parquet-mr directly + * without consulting Iceberg-specific properties. + */ +public class TestParquetAdaptiveBloomFilter { + + private static final Schema SCHEMA = new Schema(required(1, "id", Types.LongType.get())); + + @TempDir private Path temp; + + /** + * Writes a parquet file via the createWriterFunc code path with bloom filter enabled on the + * {@code id} column and a 4 MiB max-bytes cap. Returns the resulting file size. + */ + private long writeAndMeasure(boolean adaptive) throws IOException { Review Comment: nit: this doesn't really measure anything but only returns the file length after writing -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
