urbandan commented on a change in pull request #9430: URL: https://github.com/apache/kafka/pull/9430#discussion_r569497510
########## File path: core/src/main/scala/kafka/tools/GetOffsetShell.scala ########## @@ -132,23 +150,104 @@ object GetOffsetShell { } } - partitionOffsets.toArray.sortBy { case (tp, _) => tp.partition }.foreach { case (tp, offset) => - println(s"$topic:${tp.partition}:${Option(offset).getOrElse("")}") + partitionOffsets.toSeq.sortWith((tp1, tp2) => { + val topicComp = tp1._1.topic.compareTo(tp2._1.topic) + if (topicComp == 0) + tp1._1.partition < tp2._1.partition + else + topicComp < 0 + }).foreach { case (tp, offset) => + println(s"${tp.topic}:${tp.partition}:${Option(offset).getOrElse("")}") } + } + /** + * Creates a topic-partition filter based on a list of patterns. + * Expected format: + * List: TopicPartitionPattern(, TopicPartitionPattern)* + * TopicPartitionPattern: TopicPattern(:PartitionPattern)? | :PartitionPattern + * TopicPattern: REGEX + * PartitionPattern: NUMBER | NUMBER-(NUMBER)? | -NUMBER + */ + def createTopicPartitionFilterWithPatternList(topicPartitions: String, excludeInternalTopics: Boolean): PartitionInfo => Boolean = { + val ruleSpecs = topicPartitions.split(",") + val rules = ruleSpecs.map { ruleSpec => Review comment: I personally prefer not using regex, but I see your point - switched to regex usage. ---------------------------------------------------------------- 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