sarutak opened a new pull request, #56596: URL: https://github.com/apache/spark/pull/56596
### What changes were proposed in this pull request? This PR replaces `listBatches.sorted.lastOption` with `listBatches.maxOption` in `HDFSMetadataLog.getLatestBatchId()` and `HDFSMetadataLog.getLatest()`. ### Why are the changes needed? The intent of the code is to find the maximum batch ID. `sorted.lastOption` sorts the entire array in O(n log n) to retrieve only the maximum element, while `maxOption` achieves the same result in O(n). These methods are called on every micro-batch in Structured Streaming, so avoiding unnecessary sorting reduces overhead for long-running streaming jobs with many batches. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? GA ### Was this patch authored or co-authored using generative AI tooling? Kiro CLI / Claude -- 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]
