public void compressTags(OutputStream out, ByteBuffer in, int offset, int length)
    throws IOException {
    if (in.hasArray()) {
      // Offset we are given is relative to ByteBuffer#arrayOffset
      compressTags(out, in.array(), in.arrayOffset() + offset, length);
    } else {
      int pos = offset;
      int endOffset = pos + length;
      assert pos < endOffset;
      while (pos < endOffset) {
        int tagLen = ByteBufferUtils.readAsInt(in, pos, Tag.TAG_LENGTH_SIZE);
        pos += Tag.TAG_LENGTH_SIZE;
        Dictionary.write(out, in, pos, tagLen, tagDict);
        pos += tagLen;
      }
    }
  }
Compress tags one by one and writes to the OutputStream.
@param out    Stream to which the compressed tags to be written
@param in     Source buffer where tags are available
@param offset Offset for the tags byte buffer
@param length Length of all tag bytes
hbase-common/src/main/java/org/apache/hadoop/hbase/io/TagCompressionContext.java