Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6882#discussion_r33118093
  
    --- 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 --
    
    Thank you @marmbrus , updated!
    The `java.io.OutputStream.write(i: Int)` method is actually quite 
confusing, so I copied the comments here, even the parameter type is `Int`, but 
we should take it as `byte`, So I change the `buffer = new 
Array[Int](sizeInBytes / 4)` => `buffer = new Array[Byte](sizeInBytes)`.


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