Skip to content

Conversation

@zsxwing
Copy link
Member

@zsxwing zsxwing commented Dec 1, 2015

JavaSerializerInstance.serialize uses ByteArrayOutputStream.toByteArray to get the serialized data. ByteArrayOutputStream.toByteArray needs to copy the content in the internal array to a new array. However, since the array will be converted to ByteBuffer at once, we can avoid the memory copy.

This PR added ByteBufferOutputStream to access the protected buf and convert it to a ByteBuffer directly.

@vanzin
Copy link
Contributor

vanzin commented Dec 1, 2015

LGTM pending tests.

@zsxwing
Copy link
Member Author

zsxwing commented Dec 1, 2015

retest this please

@SparkQA
Copy link

SparkQA commented Dec 1, 2015

Test build #46912 has finished for PR 10051 at commit 4711b83.

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

@SparkQA
Copy link

SparkQA commented Dec 1, 2015

Test build #46917 has finished for PR 10051 at commit 4f35437.

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

@srowen
Copy link
Member

srowen commented Dec 1, 2015

Yeah that looks nice, low-touch too.

@zsxwing
Copy link
Member Author

zsxwing commented Dec 1, 2015

Merging to master and 1.6

asfgit pushed a commit that referenced this pull request Dec 1, 2015
…lize

`JavaSerializerInstance.serialize` uses `ByteArrayOutputStream.toByteArray` to get the serialized data. `ByteArrayOutputStream.toByteArray` needs to copy the content in the internal array to a new array. However, since the array will be converted to `ByteBuffer` at once, we can avoid the memory copy.

This PR added `ByteBufferOutputStream` to access the protected `buf` and convert it to a `ByteBuffer` directly.

Author: Shixiong Zhu <[email protected]>

Closes #10051 from zsxwing/SPARK-12060.

(cherry picked from commit 1401166)
Signed-off-by: Shixiong Zhu <[email protected]>
@asfgit asfgit closed this in 1401166 Dec 1, 2015
@zsxwing zsxwing deleted the SPARK-12060 branch December 1, 2015 17:50
@zsxwing
Copy link
Member Author

zsxwing commented Dec 1, 2015

Just found a lot places use ByteBuffer.array directly and this patch will break them. Just reverted it before fixing the ByteBuffer.array issue.

asfgit pushed a commit that referenced this pull request Dec 7, 2015
…lize

Merged #10051 again since #10083 is resolved.

This reverts commit 328b757.

Author: Shixiong Zhu <[email protected]>

Closes #10167 from zsxwing/merge-SPARK-12060.
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