attilapiros commented on a change in pull request #33628:
URL: https://github.com/apache/spark/pull/33628#discussion_r771268550



##########
File path: 
core/src/test/scala/org/apache/spark/storage/DiskBlockObjectWriterSuite.scala
##########
@@ -184,4 +184,20 @@ class DiskBlockObjectWriterSuite extends SparkFunSuite 
with BeforeAndAfterEach {
     writer.close()
     assert(segment.length === 0)
   }
+
+  test("calling closeAndDelete() on a partial write file") {
+    val (writer, file, writeMetrics) = createWriter()
+
+    writer.write(Long.box(20), Long.box(30))
+    val firstSegment = writer.commitAndGet()
+    assert(firstSegment.length === file.length())
+    assert(writeMetrics.bytesWritten === file.length())
+
+    writer.write(Long.box(40), Long.box(50))
+
+    writer.closeAndDelete()
+    assert(!file.exists())
+    assert(writeMetrics.bytesWritten === firstSegment.length)

Review comment:
       In the test it must be 0 but we should decrease the metric by the sum of 
all records written by the writer.
   
   What about counting how many records were committed successfully and 
decrement the `recordsWritten` by the sum of committed records and current 
`numRecordsWritten`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to