@Override public void validate(PCollection<KV<K, V>> input) { try { GroupByKey.applicableTo(input); } catch (IllegalStateException e) { throw new IllegalStateException("Unable to create a side-input view from input", e); } }
@Override public PCollection<KV<ReferenceShard, Iterable<GATKRead>>> apply(PCollection<GATKRead> input) { PCollection<KV<ReferenceShard, GATKRead>> keyReadByReferenceShard = input.apply( ParDo.of( new DoFn<GATKRead, KV<ReferenceShard, GATKRead>>() { private static final long serialVersionUID = 1L; @Override public void processElement(ProcessContext c) throws Exception { // Apply our reference window function to each read before deciding which // reference shard it belongs to. ReferenceShard shard = ReferenceShard.getShardNumberFromInterval( referenceWindowFunction.apply(c.element())); c.output(KV.of(shard, c.element())); } }) .named("KeyReadByRefShard")); return keyReadByReferenceShard.apply(GroupByKey.<ReferenceShard, GATKRead>create()); }