public static int compareAsLong(final byte[] leftBytes, final ByteBuffer right, final int rightPos) {

        int cmp = 0;

        for (int i = 0; i < Long.BYTES && cmp == 0; i++) {
            int iRight = i + rightPos;
            cmp = (i == 0 || (leftBytes[i] >= 0 == right.get(iRight) >= 0))
                    ? leftBytes[i] - right.get(iRight)
                    : right.get(iRight) - leftBytes[i];
        }
//        final int cmp2 = cmp;
//        LAMBDA_LOGGER.info(() -> LogUtil.message("Comparing {}, {}, {}, {} - {}",
//                byteBufferInfo(left), leftPos,
//                byteBufferInfo(right), rightPos,
//                cmp2));
        return cmp;
    }
Compare two {@link ByteBuffer} objects as if they are longs

@param left     A {@link ByteBuffer} representing a long
@param leftPos  The absolute position of the long in the the left {@link ByteBuffer}
@param right    A {@link ByteBuffer} representing a long
@param rightPos The absolute position of the long in the the right {@link ByteBuffer}
@return The result of the comparison, 0 if identical, <0 if left < right,
>0 if left < right
stroom-bytebuffer/src/main/java/stroom/bytebuffer/ByteBufferUtils.java