Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/16357#discussion_r93323712
--- Diff:
core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeInMemorySorter.java
---
@@ -256,6 +259,14 @@ public boolean hasNext() {
@Override
public void loadNext() {
+ // Kill the task in case it has been marked as killed. This logic is
from
+ // InterruptibleIterator, but we inline it here instead of wrapping
the iterator in order
+ // to avoid performance overhead. This check is added here in
`loadNext()` instead of in
+ // `hasNext()` because it's technically possible for the caller to
be relying on
+ // `getNumRecords()` instead of `hasNext()` to know when to stop.
+ if (taskContext != null && taskContext.isInterrupted()) {
+ throw new TaskKilledException();
+ }
--- End diff --
We already have this in tight loops in the form of `InterruptibleIterator`
wrapping all over the place.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]