Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private[spark] class DiskBlockObjectWriter(
/**
* Keep track of number of records written and also use this to periodically
* output bytes written since the latter is expensive to do for each record.
* And we reset it after every commitAndGet called.
*/
private var numRecordsWritten = 0

Expand Down Expand Up @@ -185,6 +186,7 @@ private[spark] class DiskBlockObjectWriter(
// In certain compression codecs, more bytes are written after streams are closed
writeMetrics.incBytesWritten(committedPosition - reportedPosition)
reportedPosition = committedPosition
numRecordsWritten = 0
fileSegment
} else {
new FileSegment(file, committedPosition, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class DiskBlockObjectWriterSuite extends SparkFunSuite with BeforeAndAfterEach {
writer.revertPartialWritesAndClose()
assert(firstSegment.length === file.length())
assert(writeMetrics.bytesWritten === file.length())
assert(writeMetrics.recordsWritten == 1)
}

test("calling revertPartialWritesAndClose() after commit() should have no effect") {
Expand Down