rdblue commented on code in PR #12298:
URL: https://github.com/apache/iceberg/pull/12298#discussion_r1996050564
##########
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:
I think we should take a look at how ORC and Parquet are configured and
avoid different ways to pass this.
--
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]