Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/6707#discussion_r32297750
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/receiver/ReceivedBlockHandler.scala
---
@@ -199,3 +223,16 @@ private[streaming] object
WriteAheadLogBasedBlockHandler {
new Path(checkpointDir, new Path("receivedData",
streamId.toString)).toString
}
}
+
+/**
+ * A utility that will wrap the Iterator to get the count
+ */
+private class CountingIterator[T](iterator: Iterator[T]) extends
Iterator[T] {
+ var count = 0
+ def hasNext(): Boolean = iterator.hasNext
+ def isFullyConsumed: Boolean = !iterator.hasNext
--- End diff --
As a good design pattern, could you put the count as a private variable
(rename as _count) and then make public def count() which checks if it is fully
consumed and returns Some(_count) or None?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]