Github user andrewor14 commented on the pull request:

    https://github.com/apache/spark/pull/8635#issuecomment-138995034
  
    @chenghao-intel thanks for taking the time to write the test. However I 
think it is more complicated than necessary. I was able to add a much smaller 
test to the existing `UnsafeRowSerializerSuite`. Can you use this one instead?
    ```
    test("SPARK-10466: external sorter spilling with unsafe row serializer") {
      val conf = new SparkConf()
        .set("spark.shuffle.spill.initialMemoryThreshold", "1024")
        .set("spark.shuffle.sort.bypassMergeThreshold", "0")
        .set("spark.shuffle.memoryFraction", "0.0001")
      var sc: SparkContext = null
      var outputFile: File = null
      try {
        sc = new SparkContext("local", "test", conf)
        outputFile = File.createTempFile("test-unsafe-row-serializer-spill", "")
        val data = (1 to 1000).iterator.map { i =>
          val internalRow = 
CatalystTypeConverters.convertToCatalyst(Row(i)).asInstanceOf[InternalRow]
          val unsafeRow = UnsafeProjection.create(Array(IntegerType: 
DataType)).apply(internalRow)
          (i, unsafeRow)
        }
        val ser = new UnsafeRowSerializer(numFields = 2)
        val part = new HashPartitioner(10)
        val sorter = new ExternalSorter[Int, UnsafeRow, UnsafeRow](
          partitioner = Some(part), serializer = Some(ser))
    
        // Ensure we spilled something and have to merge them later
        assert(sorter.numSpills === 0)
        sorter.insertAll(data)
        assert(sorter.numSpills > 0)
    
        // Merging spilled files should not throw assertion error
        val taskContext = new TaskContextImpl(0, 0, 0, 0, null, null, 
InternalAccumulator.create(sc))
        taskContext.taskMetrics.shuffleWriteMetrics = Some(new 
ShuffleWriteMetrics)
        sorter.writePartitionedFile(ShuffleBlockId(0, 0, 0), taskContext, 
outputFile)
    
      } finally {
        // Clean up
        if (sc != null) {
          sc.stop()
        }
        if (outputFile != null) {
          outputFile.delete()
        }
      }
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to