@Override
            public int findCommonPrefix(ByteBuffer left, int leftOffset, int leftLength, byte[] right,
                                        int rightOffset, int rightLength) {
                long offset1Adj;
                Object refObj1 = null;
                if (left.isDirect()) {
                    offset1Adj = leftOffset + UnsafeAccess.directBufferAddress(left);
                } else {
                    offset1Adj = leftOffset + left.arrayOffset() + UnsafeAccess.BYTE_ARRAY_BASE_OFFSET;
                    refObj1 = left.array();
                }
                return findCommonPrefixUnsafe(refObj1, offset1Adj, leftLength, right,
                        rightOffset + UnsafeAccess.BYTE_ARRAY_BASE_OFFSET, rightLength);
            }
Utility functions for working with byte buffers, such as reading/writing variable-length long
numbers.
stroom-bytebuffer/src/main/java/stroom/bytebuffer/hbase/ByteBufferUtils.java