rdblue commented on code in PR #12298:
URL: https://github.com/apache/iceberg/pull/12298#discussion_r1996049790
##########
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.
Review Comment:
Looks like this was auto-formatted. Can you fix it?
--
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]