pvary commented on code in PR #12298: URL: https://github.com/apache/iceberg/pull/12298#discussion_r2001616111
########## spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/BaseBatchReader.java: ########## @@ -65,76 +59,32 @@ protected CloseableIterable<ColumnarBatch> newBatchIterable( Expression residual, Map<Integer, ?> idToConstant, SparkDeleteFilter deleteFilter) { - switch (format) { - case PARQUET: - return newParquetIterable(inputFile, start, length, residual, idToConstant, deleteFilter); - - case ORC: - return newOrcIterable(inputFile, start, length, residual, idToConstant); - - default: - throw new UnsupportedOperationException( - "Format: " + format + " not supported for batched reads"); - } - } - - private CloseableIterable<ColumnarBatch> newParquetIterable( - InputFile inputFile, - long start, - long length, - Expression residual, - Map<Integer, ?> idToConstant, - SparkDeleteFilter deleteFilter) { - // get required schema if there are deletes Schema requiredSchema = deleteFilter != null ? deleteFilter.requiredSchema() : expectedSchema(); + ReadBuilder<?, ?> readBuilder = + DataFileServiceRegistry.<InternalRow>readBuilder( + format, + ColumnarBatch.class.getName(), + parquetConf != null ? parquetConf.readerType().name() : null, + inputFile) + .project(requiredSchema) + .idToConstant(idToConstant) + .withDeleteFilter(deleteFilter) + .split(start, length) + .filter(residual) + .caseSensitive(caseSensitive()) + // Spark eagerly consumes the batches. So the underlying memory allocated could be + // reused + // without worrying about subsequent reads clobbering over each other. This improves + // read performance as every batch read doesn't have to pay the cost of allocating + // memory. + .reuseContainers() + .withNameMapping(nameMapping()); + if (parquetConf != null) { + readBuilder = readBuilder.recordsPerBatch(parquetConf.batchSize()); + } else if (orcConf != null) { + readBuilder = readBuilder.recordsPerBatch(orcConf.batchSize()); Review Comment: What should we do with this @aokolnychyi, @rdblue. I'm open for whatever directions you want this to move ########## spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/DataFileServices.java: ########## @@ -0,0 +1,132 @@ +/* + * 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.spark.source; + +import static org.apache.iceberg.MetadataColumns.DELETE_FILE_ROW_FIELD_NAME; + +import org.apache.iceberg.FileFormat; +import org.apache.iceberg.avro.Avro; +import org.apache.iceberg.io.datafile.DataFileServiceRegistry; +import org.apache.iceberg.io.datafile.DeleteFilter; +import org.apache.iceberg.orc.ORC; +import org.apache.iceberg.parquet.Parquet; +import org.apache.iceberg.spark.ParquetReaderType; +import org.apache.iceberg.spark.data.SparkAvroWriter; +import org.apache.iceberg.spark.data.SparkOrcReader; +import org.apache.iceberg.spark.data.SparkOrcWriter; +import org.apache.iceberg.spark.data.SparkParquetReaders; +import org.apache.iceberg.spark.data.SparkParquetWriters; +import org.apache.iceberg.spark.data.SparkPlannedAvroReader; +import org.apache.iceberg.spark.data.vectorized.VectorizedSparkOrcReaders; +import org.apache.iceberg.spark.data.vectorized.VectorizedSparkParquetReaders; +import org.apache.spark.sql.catalyst.InternalRow; +import org.apache.spark.sql.types.StructType; +import org.apache.spark.sql.vectorized.ColumnarBatch; +import org.apache.spark.unsafe.types.UTF8String; + +public class DataFileServices { Review Comment: Renamed -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org