Program: 170081
Project: 170081
Buggy source:
int compute(String arg) throws Exception {
  ComputeConfig config=parseComputeConfig(arg);
  Pipeline p=new MRPipeline(ExhibitTool.class,getConf());
  Dataset<GenericRecord> data=Datasets.load(config.uri);
  PCollection<GenericRecord> input=p.read(CrunchDatasets.asSource(data));
  RecordToExhibit rte=new RecordToExhibit(config.frames);
  ExhibitDescriptor descriptor=rte.getDescriptor(input.getPType());
  PCollection<Exhibit> exhibits=rte.apply(input);
  List<OutputGen> outputGens=Lists.newArrayList();
  Set<Schema> keySchemas=Sets.newHashSet();
  Set<Schema> valueSchemas=Sets.newHashSet();
  List<Schema> outputSchemas=Lists.newArrayList();
  for (int i=0; i < config.outputs.size(); i++) {
    OutputConfig output=config.outputs.get(i);
    OutputGen gen=new OutputGen(output,descriptor);
    Schema keySchema=gen.getKeySchema();
    List<Schema> valueSchema=gen.getValueSchemas();
    List<Schema.Field> outputFields=Lists.newArrayList();
    for (    Schema.Field sf : keySchema.getFields()) {
      outputFields.add(new Schema.Field(sf.name(),sf.schema(),sf.doc(),sf.defaultValue()));
    }
    for (    Schema s : valueSchema) {
      for (      Schema.Field sf : s.getFields()) {
        outputFields.add(new Schema.Field(sf.name(),sf.schema(),sf.doc(),sf.defaultValue()));
      }
    }
    Schema outputSchema=Schema.createRecord("String_Node_Str" + i,"String_Node_Str","String_Node_Str",false);
    outputSchema.setFields(outputFields);
    keySchemas.add(keySchema);
    valueSchemas.addAll(valueSchema);
    outputGens.add(gen);
    outputSchemas.add(outputSchema);
  }
  Schema keySchema=unionKeySchema("String_Node_Str",keySchemas);
  Schema valueSchema=unionValueSchema("String_Node_Str",valueSchemas);
  SchemaProvider sp=new SchemaProvider(ImmutableList.of(keySchema,valueSchema));
  PTableType<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> ptt=Avros.tableOf(Avros.pairs(Avros.generics(keySchema),Avros.ints()),Avros.pairs(Avros.ints(),Avros.generics(valueSchema)));
  PTable<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> mapside=null;
  for (int i=0; i < outputGens.size(); i++) {
    PTable<GenericData.Record,Pair<Integer,GenericData.Record>> out=outputGens.get(i).apply(exhibits);
    PTable<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> m=out.parallelDo(new SchemaMapFn(i,sp),ptt);
    mapside=(mapside == null) ? m : mapside.union(m);
  }
  GroupingOptions opts=GroupingOptions.builder().numReducers(config.parallelism).partitionerClass(JoinUtils.AvroIndexedRecordPartitioner.class).groupingComparatorClass(JoinUtils.AvroPairGroupingComparator.class).build();
  PType<GenericData.Record> outputUnion=Avros.generics(Schema.createUnion(outputSchemas));
  PTable<Integer,GenericData.Record> reduced=mapside.groupByKey(opts).combineValues(new ExCombiner(config.outputs)).parallelDo(new MergeRowsFn(outputSchemas),Avros.tableOf(Avros.ints(),outputUnion));
  for (int i=0; i < config.outputs.size(); i++) {
    OutputConfig output=config.outputs.get(i);
    PCollection<GenericData.Record> out=reduced.parallelDo(new FilterOutFn(i),Avros.generics(outputSchemas.get(i)));
    DatasetDescriptor dd=new DatasetDescriptor.Builder().schema(((AvroType)out.getPType()).getSchema()).format(Formats.PARQUET).build();
    Dataset<GenericRecord> outputDataset=Datasets.create(output.uri,dd);
    out.write(CrunchDatasets.asTarget(outputDataset),output.writeMode);
  }
  PipelineResult res=p.done();
  return res.succeeded() ? 0 : 1;
}

Fixed version (ground truth):
int compute(String arg) throws Exception {
  ComputeConfig config=parseComputeConfig(arg);
  Pipeline p=new MRPipeline(ExhibitTool.class,getConf());
  Dataset<GenericRecord> data=Datasets.load(config.uri);
  PCollection<GenericRecord> input=p.read(CrunchDatasets.asSource(data));
  RecordToExhibit rte=new RecordToExhibit(config.frames);
  ExhibitDescriptor descriptor=rte.getDescriptor(input.getPType());
  PCollection<Exhibit> exhibits=rte.apply(input);
  List<OutputGen> outputGens=Lists.newArrayList();
  Set<Schema> keySchemas=Sets.newHashSet();
  Set<Schema> valueSchemas=Sets.newHashSet();
  List<Schema> outputSchemas=Lists.newArrayList();
  for (int i=0; i < config.outputs.size(); i++) {
    OutputConfig output=config.outputs.get(i);
    OutputGen gen=new OutputGen(i,output,descriptor);
    Schema keySchema=gen.getKeySchema();
    List<Schema> valueSchema=gen.getValueSchemas();
    List<Schema.Field> outputFields=Lists.newArrayList();
    for (    Schema.Field sf : keySchema.getFields()) {
      outputFields.add(new Schema.Field(sf.name(),sf.schema(),sf.doc(),sf.defaultValue()));
    }
    for (    Schema s : valueSchema) {
      for (      Schema.Field sf : s.getFields()) {
        outputFields.add(new Schema.Field(sf.name(),sf.schema(),sf.doc(),sf.defaultValue()));
      }
    }
    Schema outputSchema=Schema.createRecord("String_Node_Str" + i,"String_Node_Str","String_Node_Str",false);
    outputSchema.setFields(outputFields);
    System.out.println("String_Node_Str" + i + "String_Node_Str"+ outputSchema.toString(true));
    keySchemas.add(keySchema);
    valueSchemas.addAll(valueSchema);
    outputGens.add(gen);
    outputSchemas.add(outputSchema);
  }
  Schema keySchema=unionKeySchema("String_Node_Str",Lists.newArrayList(keySchemas));
  Schema valueSchema=unionValueSchema("String_Node_Str",Lists.newArrayList(valueSchemas));
  SchemaProvider sp=new SchemaProvider(ImmutableList.of(keySchema,valueSchema));
  PTableType<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> ptt=Avros.tableOf(Avros.pairs(Avros.generics(keySchema),Avros.ints()),Avros.pairs(Avros.ints(),Avros.generics(valueSchema)));
  PTable<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> mapside=null;
  for (int i=0; i < outputGens.size(); i++) {
    PTable<GenericData.Record,Pair<Integer,GenericData.Record>> out=outputGens.get(i).apply(exhibits);
    PTable<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> m=out.parallelDo(new SchemaMapFn(i,sp),ptt);
    mapside=(mapside == null) ? m : mapside.union(m);
  }
  GroupingOptions opts=GroupingOptions.builder().numReducers(config.parallelism).partitionerClass(JoinUtils.AvroIndexedRecordPartitioner.class).groupingComparatorClass(JoinUtils.AvroPairGroupingComparator.class).build();
  Schema outputUnionSchema=unionValueSchema("String_Node_Str",outputSchemas);
  PType<GenericData.Record> outputUnion=Avros.generics(outputUnionSchema);
  PTable<Integer,GenericData.Record> reduced=mapside.groupByKey(opts).combineValues(new ExCombiner(sp,config.outputs)).parallelDo("String_Node_Str",new MergeRowsFn(outputUnionSchema),Avros.tableOf(Avros.ints(),outputUnion));
  for (int i=0; i < config.outputs.size(); i++) {
    OutputConfig output=config.outputs.get(i);
    AvroType<GenericData.Record> outType=Avros.generics(outputSchemas.get(i));
    PCollection<GenericData.Record> out=reduced.parallelDo(new FilterOutFn(i),outType);
    DatasetDescriptor dd=new DatasetDescriptor.Builder().schema(outType.getSchema()).format(output.format).build();
    Dataset<GenericRecord> outputDataset=Datasets.create(output.uri,dd);
    out.write(CrunchDatasets.asTarget(outputDataset),output.writeMode);
  }
  PipelineResult res=p.done();
  return res.succeeded() ? 0 : 1;
}