You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/11/02 06:06:03 UTC

[GitHub] [spark] mridulm commented on a diff in pull request #38428: [SPARK-40912][CORE][WIP] Overhead of Exceptions in KryoDeserializationStream

mridulm commented on code in PR #38428:
URL: https://github.com/apache/spark/pull/38428#discussion_r1011229019


##########
core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala:
##########
@@ -324,6 +326,36 @@ class KryoDeserializationStream(
       }
     }
   }
+
+  final override def asIterator: Iterator[Any] = new NextIterator[Any] {
+    override protected def getNext() = {
+      if (KryoDeserializationStream.this.hasNext) {
+        readValue[Any]()
+      } else {
+        finished = true
+        null
+      }
+    }
+
+    override protected def close(): Unit = {
+      KryoDeserializationStream.this.close()
+    }
+  }
+
+  final override def asKeyValueIterator: Iterator[(Any, Any)] = new NextIterator[(Any, Any)] {
+    override protected def getNext() = {
+      if (KryoDeserializationStream.this.hasNext) {
+        (readKey[Any](), readValue[Any]())

Review Comment:
   Or potentially do something better.
   
   ```
     if (hasNext) {
       val key = readKey()
       if (hasNext) {
         return (key, readValue())
       }
     }
   ```
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org