Github user marmbrus commented on the pull request:
https://github.com/apache/spark/pull/9346#issuecomment-152149587
I'm a little confused. If `GroupedIterator.hasNext` isn't idempotent then
we should fix that instead of working around it. However, as of master I
wasn't able to reproduce a problem with it (but maybe my test case is
insufficient?
```scala
val schema = new StructType().add("i", IntegerType).add("s", StringType)
val encoder = RowEncoder(schema)
val input = Seq(Row(1, "a"), Row(1, "b"), Row(2, "c"))
val grouped = GroupedIterator(input.iterator.map(encoder.toRow),
Seq('i.int.at(0)), schema.toAttributes)
val result = grouped.map {
case (key, data) =>
assert(key.numFields == 1)
key.getInt(0) -> data.map(encoder.fromRow).toSeq
}
assert(result.hasNext)
assert(result.hasNext)
assert(result.hasNext)
assert(result.next === 1 -> Seq(input(0), input(1)))
assert(result.hasNext)
assert(result.hasNext)
assert(result.hasNext)
assert(result.next === 2 -> Seq(input(2)))
assert(!result.hasNext)
assert(!result.hasNext)
```
---
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]