public OptionalLong fetchUpperBoundOffset(OffsetPosition startOffsetPosition, int fetchSize) throws IOException {
        Optional<OffsetPosition> position = offsetIndex().fetchUpperBoundOffset(startOffsetPosition, fetchSize);
        if (position.isPresent())
            return OptionalLong.of(position.get().offset);
        return OptionalLong.empty();
    }
Read a message set from this segment beginning with the first offset >= startOffset. The message set will include
no more than maxSize bytes and will end before maxOffset if a maxOffset is specified.

This method is thread-safe.

@param startOffset A lower bound on the first offset to include in the message set we read
@param maxSize The maximum number of bytes to include in the message set we read
@param maxPositionOpt The maximum position in the log segment that should be exposed for read
@param minOneMessage If this is true, the first message will be returned even if it exceeds `maxSize` (if one exists)

@return The fetched data and the offset metadata of the first message whose offset is >= startOffset,
        or null if the startOffset is larger than the largest offset in this log
storage/src/main/java/org/apache/kafka/storage/internals/log/LogSegment.java