Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/9417#discussion_r43869486
--- Diff:
core/src/main/scala/org/apache/spark/input/PortableDataStream.scala ---
@@ -177,39 +170,24 @@ class PortableDataStream(
}
/**
- * Create a new DataInputStream from the split and context
+ * Create a new DataInputStream from the split and context. The user of
this method is responsible
+ * for closing the stream after usage.
*/
def open(): DataInputStream = {
- if (!isOpen) {
- val pathp = split.getPath(index)
- val fs = pathp.getFileSystem(conf)
- fileIn = fs.open(pathp)
- isOpen = true
- }
- fileIn
+ val pathp = split.getPath(index)
+ val fs = pathp.getFileSystem(conf)
+ fs.open(pathp)
}
/**
* Read the file as a byte array
*/
def toArray(): Array[Byte] = {
- open()
- val innerBuffer = ByteStreams.toByteArray(fileIn)
- close()
- innerBuffer
- }
-
- /**
- * Close the file (if it is currently open)
- */
- def close(): Unit = {
--- End diff --
My only last concern here is removing this method. It's `@Experimental`
though it has been around a while. We could just keep the method as a no-op, in
case some caller out there is calling it. Maybe deprecate it, and log a warning
too. I'm not so fussed about the behavior change since it's again
`@Experimental` and I think callers should have been closing the stream
directly anyway.
---
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]