fhan688 commented on code in PR #18882:
URL: https://github.com/apache/hudi/pull/18882#discussion_r3333361951
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieMergeOnReadRDDV2.scala:
##########
@@ -259,6 +255,34 @@ class HoodieMergeOnReadRDDV2(@transient sc: SparkContext,
}
}
+ private def withInputMetrics(iter: Iterator[InternalRow],
+ closeableIter: Iterator[InternalRow],
+ context: TaskContext,
+ bytesReadCallback: () => Long):
Iterator[InternalRow] = {
+ val metricIter = new Iterator[InternalRow] with Closeable {
+ override def hasNext: Boolean = iter.hasNext
+
+ override def next(): InternalRow = {
+ val row = iter.next()
+ HoodieSparkInputMetricsUtils.incRecordsRead(context, 1)
+ row
+ }
+
+ override def close(): Unit = {
Review Comment:
Spark will not automatically close a returned `Closeable` iterator. The
wrapper is closed explicitly through the `TaskContext` completion listener
registered below. This is intentional because `resultIter` may be a filtered
iterator that does not preserve `Closeable`, so we keep `closeableIter`
separately and close it from the listener.
--
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]