-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-15601][CORE] CircularBuffer's toString() to print only the contents written if buffer isn't full #13351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…tents written if buffer isn't full
|
ok to test |
|
Test build #59470 has finished for PR 13351 at commit
|
| private[spark] class CircularBuffer(sizeInBytes: Int = 10240) extends java.io.OutputStream { | ||
| var pos: Int = 0 | ||
| var isBufferFull = false | ||
| var buffer = new Array[Int](sizeInBytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have more problems with this class. This should be val buffer = new Array[Byte](sizeInBytes). It's 4x larger than it needs to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch !! Its definitely worth fixing this.
|
Test build #59602 has finished for PR 13351 at commit
|
|
Test build #59603 has finished for PR 13351 at commit
|
| var pos: Int = 0 | ||
| var buffer = new Array[Int](sizeInBytes) | ||
| var isBufferFull = false | ||
| var buffer = new Array[Byte](sizeInBytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be val?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
|
Yeah that LGTM |
|
Test build #59622 has finished for PR 13351 at commit
|
|
ok to test. I ran |
|
Jenkins, retest this please |
|
Test build #59628 has finished for PR 13351 at commit
|
|
Thanks Tejas! |
…tents written if buffer isn't full ## What changes were proposed in this pull request? 1. The class allocated 4x space than needed as it was using `Int` to store the `Byte` values 2. If CircularBuffer isn't full, currently toString() will print some garbage chars along with the content written as is tries to print the entire array allocated for the buffer. The fix is to keep track of buffer getting full and don't print the tail of the buffer if it isn't full (suggestion by sameeragarwal over #12194 (comment)) 3. Simplified `toString()` ## How was this patch tested? Added new test case Author: Tejas Patil <tejasp@fb.com> Closes #13351 from tejasapatil/circular_buffer. (cherry picked from commit ac38bdc) Signed-off-by: Sean Owen <sowen@cloudera.com>
…tents written if buffer isn't full 1. The class allocated 4x space than needed as it was using `Int` to store the `Byte` values 2. If CircularBuffer isn't full, currently toString() will print some garbage chars along with the content written as is tries to print the entire array allocated for the buffer. The fix is to keep track of buffer getting full and don't print the tail of the buffer if it isn't full (suggestion by sameeragarwal over #12194 (comment)) 3. Simplified `toString()` Added new test case Author: Tejas Patil <tejasp@fb.com> Closes #13351 from tejasapatil/circular_buffer. (cherry picked from commit ac38bdc) Signed-off-by: Sean Owen <sowen@cloudera.com>
|
Merged to master/2.0/1.6 |
…tents written if buffer isn't full 1. The class allocated 4x space than needed as it was using `Int` to store the `Byte` values 2. If CircularBuffer isn't full, currently toString() will print some garbage chars along with the content written as is tries to print the entire array allocated for the buffer. The fix is to keep track of buffer getting full and don't print the tail of the buffer if it isn't full (suggestion by sameeragarwal over apache#12194 (comment)) 3. Simplified `toString()` Added new test case Author: Tejas Patil <tejasp@fb.com> Closes apache#13351 from tejasapatil/circular_buffer. (cherry picked from commit ac38bdc) Signed-off-by: Sean Owen <sowen@cloudera.com> (cherry picked from commit 714f4d7)
What changes were proposed in this pull request?
Intto store theBytevaluestoString()How was this patch tested?
Added new test case