Skip to content

Conversation

@tejasapatil
Copy link
Contributor

@tejasapatil tejasapatil commented May 27, 2016

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 [SPARK-14400] [SQL] ScriptTransformation does not fail the job for bad user command #12194 (comment))
  3. Simplified toString()

How was this patch tested?

Added new test case

@tejasapatil
Copy link
Contributor Author

ok to test

@SparkQA
Copy link

SparkQA commented May 27, 2016

Test build #59470 has finished for PR 13351 at commit 24e50bb.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

private[spark] class CircularBuffer(sizeInBytes: Int = 10240) extends java.io.OutputStream {
var pos: Int = 0
var isBufferFull = false
var buffer = new Array[Int](sizeInBytes)
Copy link
Member

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.

Copy link
Contributor Author

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.

@srowen
Copy link
Member

srowen commented May 27, 2016

CC @chenghao-intel

@SparkQA
Copy link

SparkQA commented May 30, 2016

Test build #59602 has finished for PR 13351 at commit 3a1e7ff.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 30, 2016

Test build #59603 has finished for PR 13351 at commit 76b6e3c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

var pos: Int = 0
var buffer = new Array[Int](sizeInBytes)
var isBufferFull = false
var buffer = new Array[Byte](sizeInBytes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be val?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@srowen
Copy link
Member

srowen commented May 31, 2016

Yeah that LGTM

@SparkQA
Copy link

SparkQA commented May 31, 2016

Test build #59622 has finished for PR 13351 at commit a0ae62e.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@tejasapatil
Copy link
Contributor Author

ok to test.

I ran sbt core/test:test locally and it worked. Not sure what failed over Jenkins because it says [info] Passed: Total 1832, Failed 0, Errors 0, Passed 1832, Ignored 591

@tejasapatil
Copy link
Contributor Author

Jenkins, retest this please

@SparkQA
Copy link

SparkQA commented May 31, 2016

Test build #59628 has finished for PR 13351 at commit a0ae62e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@sameeragarwal
Copy link
Member

Thanks Tejas!

asfgit pushed a commit that referenced this pull request Jun 1, 2016
…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>
@asfgit asfgit closed this in ac38bdc Jun 1, 2016
asfgit pushed a commit that referenced this pull request Jun 1, 2016
…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>
@srowen
Copy link
Member

srowen commented Jun 1, 2016

Merged to master/2.0/1.6

zzcclp pushed a commit to zzcclp/spark that referenced this pull request Jun 1, 2016
…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)
@tejasapatil tejasapatil deleted the circular_buffer branch July 6, 2016 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants