code: @Override
    public void writeTo(StreamOutput out) throws IOException {
      // Encode flag
      out.writeBoolean(this.isPruned());
  
      // Encode size of list
      out.writeInt(set.size());
  
      // Encode ints
      BytesRef buffer = new BytesRef(new byte[1024 * 8]);
      Iterator<IntCursor> it = set.iterator();
      while (it.hasNext()) {
        Bytes.writeVInt(buffer, it.next().value);
        if (buffer.offset > buffer.bytes.length - 5) {
          out.write(buffer.bytes, 0, buffer.offset);
          buffer.offset = 0;
        }
      }
  
      // flush the remaining bytes from the buffer
      out.write(buffer.bytes, 0, buffer.offset);
    }
docs: Serialize the list of terms to the {@link StreamOutput}.
  <br>
  Given the low performance of {@link org.elasticsearch.common.io.stream.BytesStreamOutput} when writing a large number
  of longs (5 to 10 times slower than writing directly to a byte[]), we use a small buffer of 8kb
  to optimise the throughput. 8kb seems to be the optimal buffer size, larger buffer size did not improve
  the throughput.
  
  @param out the output