Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6423#discussion_r31361865
  
    --- Diff: 
core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala 
---
    @@ -298,11 +294,9 @@ final class ShuffleBlockFetcherIterator(
             // not exist, SPARK-4085). In that case, we should propagate the 
right exception so
             // the scheduler gets a FetchFailedException.
             Try(buf.createInputStream()).map { is0 =>
    -          val is = blockManager.wrapForCompression(blockId, is0)
    -          val iter = 
serializerInstance.deserializeStream(is).asKeyValueIterator
    -          CompletionIterator[Any, Iterator[Any]](iter, {
    -            // Once the iterator is exhausted, release the buffer and set 
currentResult to null
    -            // so we don't release it again in cleanup.
    +          // Once the single-element (is0) iterator is exhausted, release 
the buffer so that we
    +          // don't release it again in cleanup.
    +          CompletionIterator[InputStream, 
Iterator[InputStream]](Iterator(is0), {
    --- End diff --
    
    I'm actually a bit confused about the `Try[Iterator[InputStream]]` here.  
In the old code, we had `next()` return a `(BlockId, Try[Iterator[Any]]) ` 
which, if the fetch successful, would contain an iterator of the elements in 
that individual block.  Here, it looks like we're now returning a 
single-element iterator that contains an InputStream.  I think that this is 
confusing for consumers of this class since the public 
`Try[Iterator[InputStream]]` signature might lead them to believe that they 
have to handle the possibility of multiple input streams being returned.  In 
fact, this is inconsistent with the class-level Scaladoc above, which says that 
this returns an iterator of "(BlockID, InputStream)".
    
    It sounds like the motivation for returning an iterator here was to try to 
ensure proper release of the buffer.  I'd like to understand if there's a 
cleaner way to do this, though.


---
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]

Reply via email to