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 2020/11/03 13:39:14 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #30221: [SPARK-33314][SQL] Avoid dropping rows in Avro reader

HyukjinKwon commented on a change in pull request #30221:
URL: https://github.com/apache/spark/pull/30221#discussion_r515851255



##########
File path: external/avro/src/main/scala/org/apache/spark/sql/avro/AvroUtils.scala
##########
@@ -171,9 +171,15 @@ private[sql] object AvroUtils extends Logging {
     protected val stopPosition: Long
 
     private[this] var completed = false
+    private[this] var interveningNext = true
+    private[this] var prevHasNextRow = false
     private[this] var currentRow: Option[InternalRow] = None
 
     def hasNextRow: Boolean = {
+      if (!interveningNext) {
+        // until a row is consumed, return previous result of hasNextRow
+        return prevHasNextRow
+      }

Review comment:
       I had the same thought initially but then I realised that @bersprockets wanted to do the least aggressive way. For example, previously we could get the same row from the next call of `nextRow`. After the approach above, we cannot although I think it's fine. I don't mind either way.

##########
File path: external/avro/src/main/scala/org/apache/spark/sql/avro/AvroUtils.scala
##########
@@ -171,9 +171,15 @@ private[sql] object AvroUtils extends Logging {
     protected val stopPosition: Long
 
     private[this] var completed = false
+    private[this] var interveningNext = true
+    private[this] var prevHasNextRow = false
     private[this] var currentRow: Option[InternalRow] = None
 
     def hasNextRow: Boolean = {
+      if (!interveningNext) {
+        // until a row is consumed, return previous result of hasNextRow
+        return prevHasNextRow
+      }

Review comment:
       I had the same thought initially but then I realised that @bersprockets might have wanted to do the least aggressive way. For example, previously we could get the same row from the next call of `nextRow`. After the approach above, we cannot although I think it's fine. I don't mind either way.




----------------------------------------------------------------
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.

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