yihua commented on code in PR #20079:
URL: https://github.com/apache/hudi/pull/20079#discussion_r4170324351
##########
hudi-hadoop-common/src/main/java/org/apache/hudi/common/util/ParquetUtils.java:
##########
@@ -196,6 +198,23 @@ public void close() {
}
}
+ /**
+ * Sets the Hadoop read options of a reader built with {@code
ParquetReader.Builder(InputFile)} from the
+ * file's {@link Configuration}, as {@code ParquetReader.Builder(Path)}
followed by {@code withConf} does,
+ * without creating a new {@link Configuration}. On parquet 1.15+ that
constructor builds plain
+ * {@code ParquetReadOptions}, which never consult the {@code
parquet.crypto.factory.class} decryption
+ * factory, and {@code withConf} drops the file path, so the decryption
properties are resolved here with it.
+ */
+ public static <T> ParquetReader.Builder<T>
withHadoopReadOptions(ParquetReader.Builder<T> builder, HadoopInputFile file) {
+ Configuration conf = file.getConfiguration();
+ builder.withConf(conf);
+ DecryptionPropertiesFactory decryptionFactory =
DecryptionPropertiesFactory.loadFactory(conf);
+ if (decryptionFactory != null) {
+
builder.withDecryption(decryptionFactory.getFileDecryptionProperties(conf,
file.getPath()));
+ }
Review Comment:
Addressed. Decryption is the only path-dependent option, since `withConf`
rebuilds every other read option from the configuration;
`TestParquetUtils#testWithHadoopReadOptionsMatchesPathBasedReader` now compares
the reader's options field by field with `HadoopReadOptions.builder(conf,
path)` and its rows with the path-based builder on parquet 1.12.2 through
1.17.0, so a new path-dependent option in a future parquet fails CI.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/io/storage/ParquetPerFileReadBenchmark.scala:
##########
@@ -0,0 +1,175 @@
+/*
+ * 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.hudi.io.storage
+
+import org.apache.hudi.SparkAdapterSupport.sparkAdapter
+import org.apache.hudi.common.util.{HoodieStorageUtils, Option => HOption}
+import org.apache.hudi.hadoop.fs.HadoopFSUtils
+import org.apache.hudi.storage.StoragePath
+import org.apache.hudi.util.CloseableInternalRowIterator
+
+import org.apache.hadoop.conf.Configuration
+import
org.apache.parquet.avro.HoodieAvroParquetSchemaConverter.getAvroSchemaConverter
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.avro.HoodieSparkSchemaConverters
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.execution.datasources.FileFormat
+import org.apache.spark.sql.types.StructType
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.io.TempDir
+
+import java.lang.management.ManagementFactory
+import java.nio.file.{Files, Path}
+
+import scala.collection.JavaConverters._
+
+/**
+ * Manual benchmark of the per-file CPU cost of the Spark parquet read paths:
the log-file reader
+ * ([[HoodieSparkParquetReader]]) and the base-file reader built by the Spark
adapter. Not run in CI
+ * (the class name matches no surefire include). Every round reads the same
small files and checks
+ * the row count and a checksum, so a faster but wrong reader fails the run.
+ *
+ * {{{
+ * mvn test -pl hudi-spark-datasource/hudi-spark
-Dtest=ParquetPerFileReadBenchmark \
+ * -Dbenchmark.files=400 -Dbenchmark.rounds=10 -Dbenchmark.warmupRounds=3
+ * }}}
+ */
+class ParquetPerFileReadBenchmark {
Review Comment:
Done, gated with `@EnabledIfSystemProperty` on `benchmark.files` rather than
`@Disabled`, which would also skip the documented `-Dtest` run.
--
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]