Taking ~30sec on a small BAM file is a bit worrisome since that implies it will take >10 minutes on a whole genome.

Maybe a better solution here is to:
1. Rename RecordGroupId to RecordGroupName
2. Have the RecordGroupId be an Int instead of the String type
3. Use the BAM header to map the RecordGroupName:String -> RecordGroupId:Int
4. Write the new RecordGroupId:Int for each ADAMRecord (RLE will make this very inexpensive in terms of storage)

With these changes, there will be no need to generate the intermediate map because the RecordGroupId:Int would be available for all records.