If I use groupBy ( get field) instead of groupByKey, it changes the type from
Iterator[(com.ikanow.aleph2.data_model.interfaces.data_analytics.IBatchRecord, Iterable[(Long, com.ikanow.aleph2.data_model.interfaces.data_analytics.IBatchRecord)])], that .inMapPartitionsPostGroup expects to
Iterator[(com.ikanow.aleph2.core.shared.utils.BatchRecordUtils.JsonBatchRecord, Iterable[(com.ikanow.aleph2.data_model.interfaces.data_analytics.IBatchRecord, (Long, com.ikanow.aleph2.data_model.interfaces.data_analytics.IBatchRecord))])]
It makes sense after I found an obscure reference in the doc: groupBy( func key) treats the source RDD as NOT-Paired. So it pairs it by adding that key. Which of course breaks .inMapPartitionsPostGroup
(fixed by this commit)inMapPartitions(Post|PrePost)Groupfails if any of the partitions receive an empty iteratorinMapPartitions(Post|PrePost)Groupmethods take java iterables as there input, meaning that it is necessary to insert an extra map stage after thegroupBycall, looking something like.map { case (o, it) => (o. it.asScala)inMapPartitons*code)onObjectBatchcalls (looking at the unit tests, that is not tested).inMapPartitionsPreGroup("key")generates empty keys (in the first element of the return 2-tuple)See the linked test code, in JavaRDDs I have a
groupByimmediately followed byinMapPartitionsPrePostGroupwhich has the same "input" type asinMapPartitionsPostGroup(code)