{"action":"opened","issue":{"url":"https://api.github.com/repos/bigdatagenomics/adam/issues/661","labels_url":"https://api.github.com/repos/bigdatagenomics/adam/issues/661/labels{/name}","comments_url":"https://api.github.com/repos/bigdatagenomics/adam/issues/661/comments","events_url":"https://api.github.com/repos/bigdatagenomics/adam/issues/661/events","html_url":"https://github.com/bigdatagenomics/adam/issues/661","id":71750676,"number":661,"title":"Next on empty iterator in BroadcastRegionJoin","user":{"login":"fnothaft","id":3752466,"avatar_url":"https://avatars.githubusercontent.com/u/3752466?v=3","gravatar_id":"","url":"https://api.github.com/users/fnothaft","html_url":"https://github.com/fnothaft","followers_url":"https://api.github.com/users/fnothaft/followers","following_url":"https://api.github.com/users/fnothaft/following{/other_user}","gists_url":"https://api.github.com/users/fnothaft/gists{/gist_id}","starred_url":"https://api.github.com/users/fnothaft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fnothaft/subscriptions","organizations_url":"https://api.github.com/users/fnothaft/orgs","repos_url":"https://api.github.com/users/fnothaft/repos","events_url":"https://api.github.com/users/fnothaft/events{/privacy}","received_events_url":"https://api.github.com/users/fnothaft/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bigdatagenomics/adam/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-29T01:13:48Z","updated_at":"2015-04-29T01:13:48Z","closed_at":null,"body":"Not sure why this is happening, but I'm getting this:\r\n\r\n```\r\njava.util.NoSuchElementException: next on empty iterator\r\n        at scala.collection.Iterator$$anon$2.next(Iterator.scala:39)\r\n        at scala.collection.Iterator$$anon$2.next(Iterator.scala:37)\r\n        at scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:64)\r\n        at scala.collection.IterableLike$class.head(IterableLike.scala:91)\r\n        at scala.collection.mutable.ArrayBuffer.scala$collection$IndexedSeqOptimized$$super$head(ArrayBuffer.scala:47)\r\n        at scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:120)\r\n        at scala.collection.mutable.ArrayBuffer.head(ArrayBuffer.scala:47)\r\n        at org.bdgenomics.adam.rdd.BroadcastRegionJoin$$anonfun$4.apply(BroadcastRegionJoin.scala:114)\r\n        at org.bdgenomics.adam.rdd.BroadcastRegionJoin$$anonfun$4.apply(BroadcastRegionJoin.scala:114)\r\n```\r\n\r\nIt is coming from [this line](https://github.com/bigdatagenomics/adam/blob/master/adam-core/src/main/scala/org/bdgenomics/adam/rdd/BroadcastRegionJoin.scala#L114):\r\n\r\n```\r\n// each element of the left-side RDD should have exactly one partition.\r\n    val smallerKeyed: RDD[(ReferenceRegion, (ReferenceRegion, T))] =\r\n      baseRDD.map(t => (regions.value.regionsFor(t).head, t))\r\n```\r\n\r\nI'm not sure exactly what's going on here. I've made a local hack to get my code to run that changes this to an optional `flatMap`, which lets things run forward; I'll take more of a look later this week. @tdanford do you have any intuition as to what the single-partition invariant is here? I'm thinking that this should be changed to either a `flatMap` with a log warning, or at least a more clear assert message (the stack trace isn't terribly helpful)."}}