Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7765#discussion_r35832408
  
    --- Diff: 
core/src/test/scala/org/apache/spark/util/collection/unsafe/sort/PrefixComparatorsSuite.scala
 ---
    @@ -17,22 +17,29 @@
     
     package org.apache.spark.util.collection.unsafe.sort
     
    +import com.google.common.primitives.UnsignedBytes
     import org.scalatest.prop.PropertyChecks
    -
     import org.apache.spark.SparkFunSuite
    +import org.apache.spark.unsafe.types.UTF8String
     
     class PrefixComparatorsSuite extends SparkFunSuite with PropertyChecks {
     
       test("String prefix comparator") {
     
         def testPrefixComparison(s1: String, s2: String): Unit = {
    -      val s1Prefix = PrefixComparators.STRING.computePrefix(s1)
    -      val s2Prefix = PrefixComparators.STRING.computePrefix(s2)
    +      val utf8string1 = UTF8String.fromString(s1)
    +      val utf8string2 = UTF8String.fromString(s2)
    +      val s1Prefix = PrefixComparators.STRING.computePrefix(utf8string1)
    +      val s2Prefix = PrefixComparators.STRING.computePrefix(utf8string2)
           val prefixComparisonResult = 
PrefixComparators.STRING.compare(s1Prefix, s2Prefix)
    +
    +      val cmp = UnsignedBytes.lexicographicalComparator().compare(
    +        utf8string1.getBytes.take(8), utf8string2.getBytes.take(8))
    +
           assert(
    -        (prefixComparisonResult == 0) ||
    -        (prefixComparisonResult < 0 && s1 < s2) ||
    -        (prefixComparisonResult > 0 && s1 > s2))
    +        (prefixComparisonResult == 0 && cmp == 0) ||
    --- End diff --
    
    cc @JoshRosen 
    
    I made the randomized tester to be stricter. Previously it would still pass 
if prefix always return 0.



---
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