code: @Override
    public byte[] toBytes(HdfsStatsKey hdfsStatsKey) {
      if (hdfsStatsKey == null || hdfsStatsKey.getQualifiedPathKey() == null) {
        return HdfsConstants.EMPTY_BYTES;
      } else {
        if (StringUtils.isBlank(hdfsStatsKey.getQualifiedPathKey().getNamespace())) {
          // hadoop1 or non federated namespace
          return ByteUtil.join(HdfsConstants.SEP_BYTES,
            Bytes.toBytes(Long.toString(hdfsStatsKey.getEncodedRunId())),
            Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getCluster()),
            Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getPath()));
        } else {
          // include federated namespace
          return ByteUtil.join(HdfsConstants.SEP_BYTES,
            Bytes.toBytes(Long.toString(hdfsStatsKey.getEncodedRunId())),
            Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getCluster()),
            Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getPath()),
            Bytes.toBytes(hdfsStatsKey.getQualifiedPathKey().getNamespace()));
        }
      }
    }
docs: Returns the byte encoded representation of a HdfsStatsKey
  
  @param hdfsStats the HdfsStatsKey to serialize
  @return the byte encoded representation of the HdfsStatsKey