public Optional<OffsetPosition> fetchUpperBoundOffset(OffsetPosition fetchOffset, int fetchSize) {
        return maybeLock(lock, () -> {
            ByteBuffer idx = mmap().duplicate();
            int slot = smallestUpperBoundSlotFor(idx, fetchOffset.position + fetchSize, IndexSearchType.VALUE);
            if (slot == -1)
                return Optional.empty();
            else
                return Optional.of(parseEntry(idx, slot));
        });
    }
Find an upper bound offset for the given fetch starting position and size. This is an offset which
is guaranteed to be outside the fetched range, but note that it will not generally be the smallest
such offset.
storage/src/main/java/org/apache/kafka/storage/internals/log/OffsetIndex.java