Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-17667 Optimize the code based on Scala 2.13
  3. KAFKA-14615

Use sizeCompare(Iterable[_]) to compare two iterables

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • 4.0.0
    • None

    Description

      Since Scala 2.12 is being deprecated in 4.x version, we can utilize some improved methods for comparing size of scala collections which were introduced starting 2.13.

      This task is to find and replace usage of code paths where we use (IterableA.size == IterableB.size) having a complexity of O(IterableA size + IterableB size) with sizeCompare() method which has a complexity of O(min(IterableA size, IterableB size))

      Some examples where sizeCompare() could be used are:
      1. https://github.com/apache/kafka/blob/78d4458b94e585bc602a4ae307d3de54fcedf2af/core/src/main/scala/kafka/server/KafkaApis.scala#L1177
      2. https://github.com/apache/kafka/blob/78d4458b94e585bc602a4ae307d3de54fcedf2af/core/src/main/scala/kafka/tools/JmxTool.scala#L215 
      3. 

       [1] https://github.com/scala/scala/pull/6758
       [2] https://github.com/scala/scala/pull/6950 

      Attachments

        Issue Links

          Activity

            People

              kamalesh0420 Kamalesh Palanisamy
              divijvaidya Divij Vaidya
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: