public Collection<LogSegment> values(long from, long to) {
        if (from == to) {
            // Handle non-segment-aligned empty sets
            return Collections.emptyList();
        } else if (to < from) {
            throw new IllegalArgumentException("Invalid log segment range: requested segments in " + topicPartition +
                    " from offset " + from + " which is greater than limit offset " + to);
        } else {
            Long floor = segments.floorKey(from);
            if (floor != null)
                return segments.subMap(floor, to).values();
            return segments.headMap(to).values();
        }
    }
@return An iterator to all segments beginning with the segment that includes "from" and ending
        with the segment that includes up to "to-1" or the end of the log (if to > end of log).
storage/src/main/java/org/apache/kafka/storage/internals/log/LogSegments.java