public void sendTo(BytesAndBitsForCompactor wrapper, byte userBits) {
    ByteBuffer bb = toByteBuffer();
    if (bb.hasArray() && bb.arrayOffset() == 0) {
      wrapper.setData(bb.array(), userBits, bb.limit(), true /* is Reusable */);
    } else {
      // create a new buffer of just the right size and copy the old buffer into
      // it
      ByteBuffer tmp = ByteBuffer.allocate(bb.remaining());
      tmp.put(bb);
      tmp.flip();
      buffer = tmp;
      byte[] bytes = buffer.array();
      wrapper.setData(bytes, userBits, bytes.length, true /* is Reusable */);
    }
  }
Writes this stream to the wrapper object of BytesAndBitsForCompactor type. The byte array
retrieved from the HeapDataOutputStream is set in the wrapper object. The byte array may be
partially filled. The valid length of data in the byte array is set in the wrapper. It is
assumed that the HeapDataOutputStream is appropriately seeded with a byte array from the
wrapper. However the filled byte array may or may not be the same as that used for seeding ,
depending upon whether the data got accommodated in the original byte buffer or not.
geode-core/src/main/java/org/apache/geode/internal/HeapDataOutputStream.java