Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/6882#discussion_r33325875
--- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
@@ -2333,3 +2333,48 @@ private[spark] class RedirectThread(
}
}
}
+
+/**
+ * An [[OutputStream]] that will store the last 10 kilobytes (by default)
written to it
+ * in a circular buffer. The current contents of the buffer can be
accessed using
+ * the toString method.
+ */
+private[spark] class CircularBuffer(sizeInBytes: Int = 10240) extends
java.io.OutputStream {
+ var pos: Int = 0
+ var buffer = new Array[Byte](sizeInBytes)
+
+ /**
+ * Writes the specified byte to this output stream. The general
+ * contract for [[write]] is that one byte is written
+ * to the output stream. The byte to be written is the eight
+ * low-order bits of the argument `i`. The 24
+ * high-order bits of `i` are ignored.
+ *
+ * Subclasses of [[OutputStream]] must provide an
+ * implementation for this method.
+ *
+ * @param i the byte to be written.
+ */
+ override def write(i: Int): Unit = {
+ buffer(pos) = i.asInstanceOf[Byte]
--- End diff --
Yes, I know this, this is the most confusing part as it's defined by
`java.io.OutputStream.write(b: Int)`, the integer will be converted to byte.
For example in the `ByteOutputStream`
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/io/ByteArrayOutputStream.java#90
Anyway, I agree with you the PR should focus on the bug fixing. Code will
be updated soon.
---
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]