question: VcfRecord [ ] mergeRecords ( VcfRecord [ ] records , VcfHeader [ ] headers , VcfHeader destHeader , Set < String > unmergeableFormatFields , boolean preserveFormats ) { assert records . length == headers . length ; final MultiMap < Integer , VcfRecord > recordSets = new MultiMap < > ( true ) ; final MultiMap < Integer , VcfHeader > headerSets = new MultiMap < > ( true ) ; for ( int i = 0 ; i < records . length ; i ++ ) { recordSets . put ( records [ i ] . getLength ( ) , records [ i ] ) ; headerSets . put ( records [ i ] . getLength ( ) , headers [ i ] ) ; } final ArrayList < VcfRecord > ret = new ArrayList < > ( ) ; for ( Integer key : recordSets . keySet ( ) ) { final Collection < VcfRecord > recs = recordSets . get ( key ) ; final Collection < VcfHeader > heads = headerSets . get ( key ) ; final VcfRecord [ ] recsArray = recs . toArray ( new VcfRecord [ recs . size ( ) ] ) ; final VcfHeader [ ] headsArray = heads . toArray ( new VcfHeader [ heads . size ( ) ] ) ; final VcfRecord merged = mergeRecordsWithSameRef ( recsArray , headsArray , destHeader , unmergeableFormatFields , ! preserveFormats ) ; if ( merged != null ) { ret . add ( merged ) ; } else { final VcfRecord [ ] recHolder = new VcfRecord [ 1 ] ; final VcfHeader [ ] headHolder = new VcfHeader [ 1 ] ; for ( int i = 0 ; i < recsArray . length ; i ++ ) { recHolder [ 0 ] = recsArray [ i ] ; headHolder [ 0 ] = headsArray [ i ] ; ret . add ( mergeRecordsWithSameRef ( recHolder , headHolder , destHeader , unmergeableFormatFields , ! preserveFormats ) ) ; } } } return ret . toArray ( new VcfRecord [ ret . size ( ) ] ) ; }
target:  Perform merge operation on a set of records with the same start position, batching up into separate merge operations for each reference span.