public void write(DataOutput out) throws IOException {
    try{
      // minhash is not maxed out, M is redundant so don't write it
      if (s < k) {
        // Use -p to signify no M
        out.writeByte(-p);
        out.writeInt(k);
        out.writeInt(s);
        for(int i=0; i < s; i++){
          out.writeLong(minhash[i]);
        }
      } else {
        out.writeByte(p);
        out.writeInt(k);
        out.writeInt(s);
        for(byte b : M){
          out.writeByte(b);
        }
        for(int i=0; i < s; i++){
          out.writeLong(minhash[i]);
        }
      }
    } catch(Exception e){
      LOG.warn("Failed writing", e);
    }
  }