code: private static long[] transformCountsToOffsets(
        long[] counts, long numRecords, long outputOffset, long bytesPerRecord,
        boolean desc, boolean signed) {
      assert counts.length == 256;
      int start = signed ? 128 : 0;  // output the negative records first (values 129-255).
      if (desc) {
        long pos = numRecords;
        for (int i = start; i < start + 256; i++) {
          pos -= counts[i & 0xff];
          counts[i & 0xff] = outputOffset + pos * bytesPerRecord;
        }
      } else {
        long pos = 0;
        for (int i = start; i < start + 256; i++) {
          long tmp = counts[i & 0xff];
          counts[i & 0xff] = outputOffset + pos * bytesPerRecord;
          pos += tmp;
        }
      }
      return counts;
    }
docs: Transforms counts into the proper unsafe output offsets for the sort type.
  
  @param counts counts for each byte value. This routine destructively modifies this array.
  @param numRecords number of data records in the original data array.
  @param outputOffset output offset in bytes from the base array object.
  @param bytesPerRecord size of each record (8 for plain sort, 16 for key-prefix sort).
  @param desc whether this is a descending (binary-order) sort.
  @param signed whether this is a signed (two's complement) sort.
  
  @return the input counts array.