public static byte[] getOrCopy(ByteBuffer buffer, int length) {
        if (buffer == null || length <= 0) {
            return new byte[0];
        }

        // let it fail later when buffer.remaining() < length

        byte[] bytes;
        if (buffer.hasArray() && length == buffer.capacity()) {
            bytes = buffer.array();
        } else {
            int position = buffer.position();
            bytes = new byte[length];
            buffer.get(bytes);
            ((Buffer) buffer).position(position);
        }
        return bytes;
    }
Reads a 32-bit integer in little-endian byte order from the given byte array
starting at the specified offset.

@param bytes  the byte array containing the integer value
@param offset the starting position of the integer value within the byte
              array
@return the 32-bit integer value read from the byte array
clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseByteUtils.java