code: public static StringBuffer pack(SerializedRecord sr) {
      StringBuffer sb = new StringBuffer();
  
      ArrayList<String> keys = new ArrayList<String>(sr.fields.keySet());
  
      if (sr.isValid())
        SerializedRecord.arrangeKeys(keys);
  
      for (int i = 0; i < keys.size(); i++) {
        String value = sr.fields.get(keys.get(i));
        sb.append(keys.get(i) + ":" + value);
        sb.append(FIELD_SEPARATOR);
      }
      return sb;
    }
docs: Pack a SerializedRecord into an array of bytes
  
  @param sr the SerializedRecord to be packed