Commit 714f4d7
[SPARK-15601][CORE] CircularBuffer's toString() to print only the contents 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 <[email protected]>
Closes #13351 from tejasapatil/circular_buffer.
(cherry picked from commit ac38bdc)
Signed-off-by: Sean Owen <[email protected]>1 parent ea84b33 commit 714f4d7
File tree
2 files changed
+44
-25
lines changed- core/src
- main/scala/org/apache/spark/util
- test/scala/org/apache/spark/util
2 files changed
+44
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
2308 | 2309 | | |
2309 | 2310 | | |
2310 | 2311 | | |
2311 | | - | |
2312 | | - | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
2313 | 2315 | | |
2314 | | - | |
2315 | | - | |
| 2316 | + | |
| 2317 | + | |
2316 | 2318 | | |
| 2319 | + | |
2317 | 2320 | | |
2318 | 2321 | | |
2319 | 2322 | | |
2320 | | - | |
2321 | | - | |
2322 | | - | |
2323 | | - | |
2324 | | - | |
2325 | | - | |
2326 | | - | |
2327 | | - | |
2328 | | - | |
2329 | | - | |
2330 | | - | |
2331 | | - | |
2332 | | - | |
| 2323 | + | |
| 2324 | + | |
2333 | 2325 | | |
2334 | | - | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
2335 | 2331 | | |
2336 | 2332 | | |
Lines changed: 30 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
679 | 679 | | |
680 | 680 | | |
681 | 681 | | |
682 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
683 | 708 | | |
684 | | - | |
| 709 | + | |
685 | 710 | | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
| 711 | + | |
| 712 | + | |
690 | 713 | | |
691 | 714 | | |
692 | 715 | | |
| |||
0 commit comments