@Override
    public Segment findSegmentByTimeStamp(long timestamp) {
        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;
        }
        // Check boundaries
        if (minStart >= curViews.length) {
            minStart = curViews.length - 1;
        }
        int hight = curViews.length - 1;
        final Segment startSeg = curViews[minStart];
        if ((minStart == hight)
                || (timestamp <= startSeg.getLeftAppendTime())) {
            return startSeg;
        }
        Segment last = curViews[hight];
        Segment before = curViews[hight - 1];
        if (last.getCachedSize() > 0) {
            if (timestamp > last.getLeftAppendTime()) {
                return last;
            }
        }
        if (timestamp > before.getRightAppendTime()) {
            return last;
        } else if (timestamp > before.getLeftAppendTime()) {
            return before;
        }
        int mid = 0;
        Segment found = null;
        // Use dichotomy to find the first segment that contains the specified timestamp
        while (minStart <= hight) {
            mid = hight + minStart >>> 1;
            found = curViews[mid];
            if (found.containTime(timestamp)) {
                before = curViews[mid - 1];
                if (timestamp > before.getRightAppendTime()) {
                    return found;
                } else if (timestamp > before.getLeftAppendTime()) {
                    return before;
                }
                hight = mid - 1;
            } else if (timestamp < found.getLeftAppendTime()) {
                hight = 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