public static byte[] cloneValue(Tag tag) {
    int tagLength = tag.getValueLength();
    byte[] tagArr = new byte[tagLength];
    if (tag.hasArray()) {
      Bytes.putBytes(tagArr, 0, tag.getValueArray(), tag.getValueOffset(), tagLength);
    } else {
      ByteBufferUtils.copyFromBufferToArray(tagArr, tag.getValueByteBuffer(), tag.getValueOffset(),
        0, tagLength);
    }
    return tagArr;
  }
Returns tag value in a new byte array. Primarily for use client-side. If server-side, use
{@link Tag#getValueArray()} with appropriate {@link Tag#getValueOffset()} and
{@link Tag#getValueLength()} instead to save on allocations.
@param tag The Tag whose value to be returned
@return tag value in a new byte array.
hbase-common/src/main/java/org/apache/hadoop/hbase/Tag.java