Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-35263

Refactor ShuffleBlockFetcherIteratorSuite to reduce duplicated code

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.1.1
    • 3.2.0
    • Shuffle, Tests
    • None

    Description

      ShuffleFetcherBlockIteratorSuite has tons of duplicate code, like:

          val iterator = new ShuffleBlockFetcherIterator(
            taskContext,
            transfer,
            blockManager,
            blocksByAddress,
            (_, in) => in,
            48 * 1024 * 1024,
            Int.MaxValue,
            Int.MaxValue,
            Int.MaxValue,
            true,
            false,
            metrics,
            false)
      

      It's challenging to tell what the interesting parts are vs. what is just being set to some default/unused value.

      Similarly but not as bad, there are 10 calls like:

      verify(transfer, times(1)).fetchBlocks(any(), any(), any(), any(), any(), any())
      

      and 7 like

      when(transfer.fetchBlocks(any(), any(), any(), any(), any(), any())).thenAnswer ...
      

      This can result in about 10% reduction in both lines and characters in the file:

      # Before
      > wc core/src/test/scala/org/apache/spark/storage/ShuffleBlockFetcherIteratorSuite.scala
          1063    3950   43201 core/src/test/scala/org/apache/spark/storage/ShuffleBlockFetcherIteratorSuite.scala
      
      # After
      > wc core/src/test/scala/org/apache/spark/storage/ShuffleBlockFetcherIteratorSuite.scala
           928    3609   39053 core/src/test/scala/org/apache/spark/storage/ShuffleBlockFetcherIteratorSuite.scala
      

      It also helps readability:

          val iterator = createShuffleBlockIteratorWithDefaults(
            transfer,
            blocksByAddress,
            maxBytesInFlight = 1000L
          )
      

      Now I can clearly tell that maxBytesInFlight is the main parameter we're interested in here.

      Attachments

        Activity

          People

            xkrogen Erik Krogen
            xkrogen Erik Krogen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: