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

    https://github.com/apache/spark/pull/397#discussion_r11561006
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/util/RawTextSender.scala ---
    @@ -43,15 +45,15 @@ object RawTextSender extends Logging {
     
         // Repeat the input data multiple times to fill in a buffer
         val lines = Source.fromFile(file).getLines().toArray
    -    val bufferStream = new ByteArrayOutputStream(blockSize + 1000)
    +    val bufferStream = new FastByteArrayOutputStream(blockSize + 1000)
         val ser = new KryoSerializer(new SparkConf()).newInstance()
         val serStream = ser.serializeStream(bufferStream)
         var i = 0
    -    while (bufferStream.size < blockSize) {
    +    while (bufferStream.length < blockSize) {
           serStream.writeObject(lines(i))
           i = (i + 1) % lines.length
         }
    -    val array = bufferStream.toByteArray
    +    val array = bufferStream.trim().array
    --- End diff --
    
    can avoid using trim (/an array copy) here by using 
RateLimitedOutputStream#write(bytes, offset, length)


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to