docs: @Override
    public void serialize(DataOutput out) throws IOException {
      int startOffset = 0;
      boolean hasrun = hasRunCompression();
      if (hasrun) {
        out.writeInt(Integer.reverseBytes(SERIAL_COOKIE | ((this.size - 1) << 16)));
        byte[] bitmapOfRunContainers = new byte[(size + 7) / 8];
        for (int i = 0; i < size; ++i) {
          if (this.values[i] instanceof MappeableRunContainer) {
            bitmapOfRunContainers[i / 8] |= (1 << (i % 8));
          }
        }
        out.write(bitmapOfRunContainers);
        if (this.size < NO_OFFSET_THRESHOLD) {
          startOffset = 4 + 4 * this.size + bitmapOfRunContainers.length;
        } else {
          startOffset = 4 + 8 * this.size + bitmapOfRunContainers.length;
        }
      } else { // backwards compatibilility
        out.writeInt(Integer.reverseBytes(SERIAL_COOKIE_NO_RUNCONTAINER));
        out.writeInt(Integer.reverseBytes(size));
        startOffset = 4 + 4 + this.size * 4 + this.size * 4;
      }
      for (int k = 0; k < size; ++k) {
        out.writeShort(Short.reverseBytes(this.keys[k]));
        out.writeShort(Short.reverseBytes((short) (this.values[k].getCardinality() - 1)));
      }
      if ((!hasrun) || (this.size >= NO_OFFSET_THRESHOLD)) {
        for (int k = 0; k < this.size; k++) {
          out.writeInt(Integer.reverseBytes(startOffset));
          startOffset = startOffset + values[k].getArraySizeInBytes();
        }
      }
      for (int k = 0; k < size; ++k) {
        values[k].writeArray(out);
      }
  
    }