squito commented on a change in pull request #23453: [SPARK-26089][CORE] Handle 
corruption in large shuffle blocks
URL: https://github.com/apache/spark/pull/23453#discussion_r253134604
 
 

 ##########
 File path: core/src/test/scala/org/apache/spark/util/UtilsSuite.scala
 ##########
 @@ -211,6 +213,49 @@ class UtilsSuite extends SparkFunSuite with 
ResetSystemProperties with Logging {
     assert(os.toByteArray.toList.equals(bytes.toList))
   }
 
+  test("copyStreamUpTo") {
+    // input array initialization
+    val bytes = Array.ofDim[Byte](1200)
+    Random.nextBytes(bytes)
+
+    val limit = 1000
+    // testing for inputLength less than, equal to and greater than limit
+    List(900, 1000, 1100).foreach { inputLength =>
+      val in = new ByteArrayInputStream(bytes.take(inputLength))
+      val (fullyCopied: Boolean, mergedStream: InputStream) = 
Utils.copyStreamUpTo(in, limit, true)
+      try {
+        val byteBufferInputStream = if 
(mergedStream.isInstanceOf[ChunkedByteBufferInputStream]) {
 
 Review comment:
   Add some comments here, like "Get a handle on the buffered data, to make 
sure the memory gets freed once we read past the end of it.  Need to use 
refelction to get handle on inner structures for this check"

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to