@Override
    public Segment findSegment(final long offset) {
        final Segment[] curViews = segmentList.get();
        if (curViews.length == 0) {
            return null;
        }
        int minStart = 0;
        for (minStart = 0; minStart < curViews.length; minStart++) {
            if (curViews[minStart] == null
                    || curViews[minStart].isExpired()) {
                continue;
            }
            break;
        }
        if (minStart >= curViews.length) {
            minStart = curViews.length - 1;
        }
        final Segment startSeg = curViews[minStart];
        if (offset < startSeg.getStart()) {
            throw new ArrayIndexOutOfBoundsException(new StringBuilder(512)
                    .append("Request offsets is ").append(offset)
                    .append(", the start is ").append(startSeg.getStart()).toString());
        }
        final Segment last = curViews[curViews.length - 1];
        if (offset >= last.getStart() + last.getCachedSize()) {
            return null;
        }
        int high = curViews.length - 1;
        while (minStart <= high) {
            final int mid = high + minStart >>> 1;
            final Segment found = curViews[mid];
            if (found.contains(offset)) {
                return found;
            } else if (offset < found.getStart()) {
                high = mid - 1;
            } else {
                minStart = mid + 1;
            }
        }
        return null;
    }
Binary search the segment that contains the offset

@param offset    offset to search
@return          the segment includes the searched offset
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/broker/msgstore/disk/FileSegmentList.java