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

    https://github.com/apache/spark/pull/7937#discussion_r36270132
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/mllib/fpm/PrefixSpanSuite.scala ---
    @@ -35,83 +35,81 @@ class PrefixSpanSuite extends SparkFunSuite with 
MLlibTestSparkContext {
         */
     
         val sequences = Array(
    -      Array(1, -1, 3, -1, 4, -1, 5),
    -      Array(2, -1, 3, -1, 1),
    -      Array(2, -1, 4, -1, 1),
    -      Array(3, -1, 1, -1, 3, -1, 4, -1, 5),
    -      Array(3, -1, 4, -1, 4, -1, 3),
    -      Array(6, -1, 5, -1, 3))
    +      Array(0, 1, 0, 3, 0, 4, 0, 5, 0),
    +      Array(0, 2, 0, 3, 0, 1, 0),
    +      Array(0, 2, 0, 4, 0, 1, 0),
    +      Array(0, 3, 0, 1, 0, 3, 0, 4, 0, 5, 0),
    +      Array(0, 3, 0, 4, 0, 4, 0, 3, 0),
    +      Array(0, 6, 0, 5, 0, 3, 0))
     
         val rdd = sc.parallelize(sequences, 2).cache()
     
    -    val prefixspan = new PrefixSpan()
    -      .setMinSupport(0.33)
    -      .setMaxPatternLength(50)
    -    val result1 = prefixspan.run(rdd)
    +    val result1 = PrefixSpan.genFreqPatterns(
    +      rdd, minCount = 2L, maxPatternLength = 50, maxLocalProjDBSize = 16L)
         val expectedValue1 = Array(
    -      (Array(1), 4L),
    -      (Array(1, -1, 3), 2L),
    -      (Array(1, -1, 3, -1, 4), 2L),
    -      (Array(1, -1, 3, -1, 4, -1, 5), 2L),
    -      (Array(1, -1, 3, -1, 5), 2L),
    -      (Array(1, -1, 4), 2L),
    -      (Array(1, -1, 4, -1, 5), 2L),
    -      (Array(1, -1, 5), 2L),
    -      (Array(2), 2L),
    -      (Array(2, -1, 1), 2L),
    -      (Array(3), 5L),
    -      (Array(3, -1, 1), 2L),
    -      (Array(3, -1, 3), 2L),
    -      (Array(3, -1, 4), 3L),
    -      (Array(3, -1, 4, -1, 5), 2L),
    -      (Array(3, -1, 5), 2L),
    -      (Array(4), 4L),
    -      (Array(4, -1, 5), 2L),
    -      (Array(5), 3L)
    +      (Array(0, 1, 0), 4L),
    +      (Array(0, 1, 0, 3, 0), 2L),
    +      (Array(0, 1, 0, 3, 0, 4, 0), 2L),
    +      (Array(0, 1, 0, 3, 0, 4, 0, 5, 0), 2L),
    +      (Array(0, 1, 0, 3, 0, 5, 0), 2L),
    +      (Array(0, 1, 0, 4, 0), 2L),
    +      (Array(0, 1, 0, 4, 0, 5, 0), 2L),
    +      (Array(0, 1, 0, 5, 0), 2L),
    +      (Array(0, 2, 0), 2L),
    +      (Array(0, 2, 0, 1, 0), 2L),
    +      (Array(0, 3, 0), 5L),
    +      (Array(0, 3, 0, 1, 0), 2L),
    +      (Array(0, 3, 0, 3, 0), 2L),
    +      (Array(0, 3, 0, 4, 0), 3L),
    +      (Array(0, 3, 0, 4, 0, 5, 0), 2L),
    +      (Array(0, 3, 0, 5, 0), 2L),
    +      (Array(0, 4, 0), 4L),
    +      (Array(0, 4, 0, 5, 0), 2L),
    +      (Array(0, 5, 0), 3L)
         )
         compareInternalResults(expectedValue1, result1.collect())
     
    -    prefixspan.setMinSupport(0.5).setMaxPatternLength(50)
    -    val result2 = prefixspan.run(rdd)
    +    val result2 = PrefixSpan.genFreqPatterns(
    +      rdd, minCount = 3, maxPatternLength = 50, maxLocalProjDBSize = 32L)
         val expectedValue2 = Array(
    -      (Array(1), 4L),
    -      (Array(3), 5L),
    -      (Array(3, -1, 4), 3L),
    -      (Array(4), 4L),
    -      (Array(5), 3L)
    +      (Array(0, 1, 0), 4L),
    +      (Array(0, 3, 0), 5L),
    +      (Array(0, 3, 0, 4, 0), 3L),
    +      (Array(0, 4, 0), 4L),
    +      (Array(0, 5, 0), 3L)
         )
         compareInternalResults(expectedValue2, result2.collect())
     
    -    prefixspan.setMinSupport(0.33).setMaxPatternLength(2)
    -    val result3 = prefixspan.run(rdd)
    +    val result3 = PrefixSpan.genFreqPatterns(
    +      rdd, minCount = 2, maxPatternLength = 2, maxLocalProjDBSize = 32L)
         val expectedValue3 = Array(
    -      (Array(1), 4L),
    -      (Array(1, -1, 3), 2L),
    -      (Array(1, -1, 4), 2L),
    -      (Array(1, -1, 5), 2L),
    -      (Array(2, -1, 1), 2L),
    -      (Array(2), 2L),
    -      (Array(3), 5L),
    -      (Array(3, -1, 1), 2L),
    -      (Array(3, -1, 3), 2L),
    -      (Array(3, -1, 4), 3L),
    -      (Array(3, -1, 5), 2L),
    -      (Array(4), 4L),
    -      (Array(4, -1, 5), 2L),
    -      (Array(5), 3L)
    +      (Array(0, 1, 0), 4L),
    +      (Array(0, 1, 0, 3, 0), 2L),
    +      (Array(0, 1, 0, 4, 0), 2L),
    +      (Array(0, 1, 0, 5, 0), 2L),
    +      (Array(0, 2, 0, 1, 0), 2L),
    +      (Array(0, 2, 0), 2L),
    +      (Array(0, 3, 0), 5L),
    +      (Array(0, 3, 0, 1, 0), 2L),
    +      (Array(0, 3, 0, 3, 0), 2L),
    +      (Array(0, 3, 0, 4, 0), 3L),
    +      (Array(0, 3, 0, 5, 0), 2L),
    +      (Array(0, 4, 0), 4L),
    +      (Array(0, 4, 0, 5, 0), 2L),
    +      (Array(0, 5, 0), 3L)
         )
         compareInternalResults(expectedValue3, result3.collect())
       }
     
       test("PrefixSpan internal (integer seq, -1 delim) run, variable-size 
itemsets") {
         val sequences = Array(
    -      Array(1, -1, 1, 2, 3, -1, 1, 3, -1, 4, -1, 3, 6),
    -      Array(1, 4, -1, 3, -1, 2, 3, -1, 1, 5),
    -      Array(5, 6, -1, 1, 2, -1, 4, 6, -1, 3, -1, 2),
    -      Array(5, -1, 7, -1, 1, 6, -1, 3, -1, 2, -1, 3))
    +      Array(0, 1, 0, 1, 2, 3, 0, 1, 3, 0, 4, 0, 3, 6, 0),
    --- End diff --
    
    I don't think this will be a problem. This is testing a private API, which 
assumes the input is sorted. The public API ensures that the inputs will be 
sorted 
(https://github.com/apache/spark/pull/7937/files#diff-860c766286608b13836350f907446622R159)


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