@Override
            public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
                    int length2) {
                // Short circuit equal case
                if (buffer1 == buffer2 && offset1 == offset2 && length1 == length2) {
                    return 0;
                }
                int minLength = Math.min(length1, length2);
                int minWords = minLength / SIZEOF_LONG;
                int offset1Adj = offset1 + BYTE_ARRAY_BASE_OFFSET;
                int offset2Adj = offset2 + BYTE_ARRAY_BASE_OFFSET;

                /*
                 * Compare 8 bytes at a time. Benchmarking shows comparing 8 bytes at a time is no slower than comparing
                 * 4 bytes at a time even on 32-bit. On the other hand, it is substantially faster on 64-bit.
                 */
                for (int i = 0; i < minWords * SIZEOF_LONG; i += SIZEOF_LONG) {
                    long lw = theUnsafe.getLong(buffer1, offset1Adj + (long) i);
                    long rw = theUnsafe.getLong(buffer2, offset2Adj + (long) i);
                    long diff = lw ^ rw;

                    if (diff != 0) {
                        if (!littleEndian) {
                            return lessThanUnsigned(lw, rw) ? -1 : 1;
                        }

                        // Use binary search
                        int n = 0;
                        int y;
                        int x = (int) diff;
                        if (x == 0) {
                            x = (int) (diff >>> 32);
                            n = 32;
                        }

                        y = x << 16;
                        if (y == 0) {
                            n += 16;
                        } else {
                            x = y;
                        }

                        y = x << 8;
                        if (y == 0) {
                            n += 8;
                        }
                        return (int) (((lw >>> n) & 0xFFL) - ((rw >>> n) & 0xFFL));
                    }
                }

                // The epilogue to cover the last (minLength % 8) elements.
                for (int i = minWords * SIZEOF_LONG; i < minLength; i++) {
                    int a = (buffer1[offset1 + i] & 0xff);
                    int b = (buffer2[offset2 + i] & 0xff);
                    if (a != b) {
                        return a - b;
                    }
                }
                return length1 - length2;
            }
Lexicographically compare two arrays.

@param buffer1 left operand
@param buffer2 right operand
@param offset1 Where to start comparing in the left buffer
@param offset2 Where to start comparing in the right buffer
@param length1 How much to compare from the left buffer
@param length2 How much to compare from the right buffer
@return 0 if equal, < 0 if left is less than right, etc.
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/common/utils/Bytes.java