kowshik commented on a change in pull request #10684:
URL: https://github.com/apache/kafka/pull/10684#discussion_r638519831



##########
File path: core/src/main/scala/kafka/log/LogSegments.scala
##########
@@ -210,11 +209,23 @@ class LogSegments(topicPartition: TopicPartition) {
    * @return the entry associated with the greatest offset, if it exists.
    */
   @threadsafe
-  def lastEntry: Option[Map.Entry[JLong, LogSegment]] = 
Option(segments.lastEntry)
+  def lastEntry: Option[Map.Entry[Long, LogSegment]] = 
Option(segments.lastEntry)
 
   /**
    * @return the log segment with the greatest offset, if it exists.
    */
   @threadsafe
   def lastSegment: Option[LogSegment] = lastEntry.map(_.getValue)
+
+  /**
+   * @return an iterable with log segments ordered from lowest base offset to 
highest,
+   *         each segment returned  has a base offset strictly greater than 
the provided baseOffset.
+   */
+  def higherSegments(baseOffset: Long): Iterable[LogSegment] = {
+    val view =
+      Option(segments.higherKey(baseOffset)).map {
+        higherOffset => segments.tailMap(higherOffset, true)
+      }.getOrElse(new ConcurrentSkipListMap[Long, LogSegment]())

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to