public void serialize(DataOutput out) throws IOException {
    int bitLength = getNumWords();
    int pageSize = getPageSize();
    int pageCount = getPageCount();

    out.writeInt(bitLength);
    for (int p = 0; p < pageCount; p++) {
      long[] bits = getPage(p);
      for (int i = 0; i < pageSize && bitLength-- > 0; i++) {
        out.writeLong(bits[i]);
      }
    }
  }
returns true if both sets have the same bits set
ambry-utils/src/main/java/com/github/ambry/utils/OpenBitSet.java