-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-17876] Write StructuredStreaming WAL to a stream instead of materializing all at once #15437
Conversation
Test build #66754 has finished for PR 15437 at commit
|
import org.apache.hadoop.conf.Configuration | ||
import org.apache.hadoop.fs._ | ||
import org.apache.hadoop.fs.permission.FsPermission | ||
import org.apache.hadoop.io.IOUtils |
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.
nit: use org.apache.commons.io.IOUtils instead. Hadoop's IOUtils is @InterfaceStability.Evolving
which can break compatibility at minor release
val lines = new String(bytes, UTF_8).split("\n") | ||
if (lines.length == 0) { | ||
override def deserialize(in: InputStream): Array[T] = { | ||
val lines = IOUtils.lineIterator(in, UTF_8).asScala |
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.
nit: why not use Source.getLines
since this is Scala.
out.write('\n') | ||
out.write(serializeData(data).getBytes(UTF_8)) | ||
} | ||
out.flush() |
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.
nit: no need to flush since it will be closed at once.
@@ -17,6 +17,8 @@ | |||
|
|||
package org.apache.spark.sql.execution.streaming | |||
|
|||
import java.io.OutputStream |
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.
nit: unused import
@@ -17,6 +17,7 @@ | |||
|
|||
package org.apache.spark.sql.execution.streaming | |||
|
|||
import java.io.OutputStream |
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.
nit: unused import
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.
Looks pretty good. Just some nits
Thanks @zsxwing addressed your comments |
Test build #66855 has finished for PR 15437 at commit
|
Test build #66856 has finished for PR 15437 at commit
|
LGTM. Thanks! Merging to master and 2.0. |
…terializing all at once ## What changes were proposed in this pull request? The CompactibleFileStreamLog materializes the whole metadata log in memory as a String. This can cause issues when there are lots of files that are being committed, especially during a compaction batch. You may come across stacktraces that look like: ``` java.lang.OutOfMemoryError: Requested array size exceeds VM limit at java.lang.StringCoding.encode(StringCoding.java:350) at java.lang.String.getBytes(String.java:941) at org.apache.spark.sql.execution.streaming.FileStreamSinkLog.serialize(FileStreamSinkLog.scala:127) ``` The safer way is to write to an output stream so that we don't have to materialize a huge string. ## How was this patch tested? Existing unit tests Author: Burak Yavuz <brkyvz@gmail.com> Closes #15437 from brkyvz/ser-to-stream. (cherry picked from commit edeb51a) Signed-off-by: Shixiong Zhu <shixiong@databricks.com>
…terializing all at once ## What changes were proposed in this pull request? The CompactibleFileStreamLog materializes the whole metadata log in memory as a String. This can cause issues when there are lots of files that are being committed, especially during a compaction batch. You may come across stacktraces that look like: ``` java.lang.OutOfMemoryError: Requested array size exceeds VM limit at java.lang.StringCoding.encode(StringCoding.java:350) at java.lang.String.getBytes(String.java:941) at org.apache.spark.sql.execution.streaming.FileStreamSinkLog.serialize(FileStreamSinkLog.scala:127) ``` The safer way is to write to an output stream so that we don't have to materialize a huge string. ## How was this patch tested? Existing unit tests Author: Burak Yavuz <brkyvz@gmail.com> Closes apache#15437 from brkyvz/ser-to-stream.
What changes were proposed in this pull request?
The CompactibleFileStreamLog materializes the whole metadata log in memory as a String. This can cause issues when there are lots of files that are being committed, especially during a compaction batch.
You may come across stacktraces that look like:
The safer way is to write to an output stream so that we don't have to materialize a huge string.
How was this patch tested?
Existing unit tests