@@ -25,7 +25,7 @@ import scala.collection.JavaConverters._
25
25
import scala .reflect .ClassTag
26
26
27
27
import org .apache .spark .Logging
28
- import org .apache .spark .annotation .Experimental
28
+ import org .apache .spark .annotation .{ Experimental , Since }
29
29
import org .apache .spark .api .java .JavaRDD
30
30
import org .apache .spark .api .java .JavaSparkContext .fakeClassTag
31
31
import org .apache .spark .rdd .RDD
@@ -51,6 +51,7 @@ import org.apache.spark.storage.StorageLevel
51
51
* (Wikipedia)]]
52
52
*/
53
53
@ Experimental
54
+ @ Since (" 1.5.0" )
54
55
class PrefixSpan private (
55
56
private var minSupport : Double ,
56
57
private var maxPatternLength : Int ,
@@ -61,17 +62,20 @@ class PrefixSpan private (
61
62
* Constructs a default instance with default parameters
62
63
* {minSupport: `0.1`, maxPatternLength: `10`, maxLocalProjDBSize: `32000000L`}.
63
64
*/
65
+ @ Since (" 1.5.0" )
64
66
def this () = this (0.1 , 10 , 32000000L )
65
67
66
68
/**
67
69
* Get the minimal support (i.e. the frequency of occurrence before a pattern is considered
68
70
* frequent).
69
71
*/
72
+ @ Since (" 1.5.0" )
70
73
def getMinSupport : Double = minSupport
71
74
72
75
/**
73
76
* Sets the minimal support level (default: `0.1`).
74
77
*/
78
+ @ Since (" 1.5.0" )
75
79
def setMinSupport (minSupport : Double ): this .type = {
76
80
require(minSupport >= 0 && minSupport <= 1 ,
77
81
s " The minimum support value must be in [0, 1], but got $minSupport. " )
@@ -82,11 +86,13 @@ class PrefixSpan private (
82
86
/**
83
87
* Gets the maximal pattern length (i.e. the length of the longest sequential pattern to consider.
84
88
*/
89
+ @ Since (" 1.5.0" )
85
90
def getMaxPatternLength : Int = maxPatternLength
86
91
87
92
/**
88
93
* Sets maximal pattern length (default: `10`).
89
94
*/
95
+ @ Since (" 1.5.0" )
90
96
def setMaxPatternLength (maxPatternLength : Int ): this .type = {
91
97
// TODO: support unbounded pattern length when maxPatternLength = 0
92
98
require(maxPatternLength >= 1 ,
@@ -98,12 +104,14 @@ class PrefixSpan private (
98
104
/**
99
105
* Gets the maximum number of items allowed in a projected database before local processing.
100
106
*/
107
+ @ Since (" 1.5.0" )
101
108
def getMaxLocalProjDBSize : Long = maxLocalProjDBSize
102
109
103
110
/**
104
111
* Sets the maximum number of items (including delimiters used in the internal storage format)
105
112
* allowed in a projected database before local processing (default: `32000000L`).
106
113
*/
114
+ @ Since (" 1.5.0" )
107
115
def setMaxLocalProjDBSize (maxLocalProjDBSize : Long ): this .type = {
108
116
require(maxLocalProjDBSize >= 0L ,
109
117
s " The maximum local projected database size must be nonnegative, but got $maxLocalProjDBSize" )
@@ -116,6 +124,7 @@ class PrefixSpan private (
116
124
* @param data sequences of itemsets.
117
125
* @return a [[PrefixSpanModel ]] that contains the frequent patterns
118
126
*/
127
+ @ Since (" 1.5.0" )
119
128
def run [Item : ClassTag ](data : RDD [Array [Array [Item ]]]): PrefixSpanModel [Item ] = {
120
129
if (data.getStorageLevel == StorageLevel .NONE ) {
121
130
logWarning(" Input data is not cached." )
@@ -202,6 +211,7 @@ class PrefixSpan private (
202
211
* @tparam Sequence sequence type, which is an Iterable of Itemsets
203
212
* @return a [[PrefixSpanModel ]] that contains the frequent sequential patterns
204
213
*/
214
+ @ Since (" 1.5.0" )
205
215
def run [Item , Itemset <: jl.Iterable [Item ], Sequence <: jl.Iterable [Itemset ]](
206
216
data : JavaRDD [Sequence ]): PrefixSpanModel [Item ] = {
207
217
implicit val tag = fakeClassTag[Item ]
@@ -211,6 +221,7 @@ class PrefixSpan private (
211
221
}
212
222
213
223
@ Experimental
224
+ @ Since (" 1.5.0" )
214
225
object PrefixSpan extends Logging {
215
226
216
227
/**
@@ -535,10 +546,14 @@ object PrefixSpan extends Logging {
535
546
* @param freq frequency
536
547
* @tparam Item item type
537
548
*/
538
- class FreqSequence [Item ](val sequence : Array [Array [Item ]], val freq : Long ) extends Serializable {
549
+ @ Since (" 1.5.0" )
550
+ class FreqSequence [Item ] @ Since (" 1.5.0" ) (
551
+ @ Since (" 1.5.0" ) val sequence : Array [Array [Item ]],
552
+ @ Since (" 1.5.0" ) val freq : Long ) extends Serializable {
539
553
/**
540
554
* Returns sequence as a Java List of lists for Java users.
541
555
*/
556
+ @ Since (" 1.5.0" )
542
557
def javaSequence : ju.List [ju.List [Item ]] = sequence.map(_.toList.asJava).toList.asJava
543
558
}
544
559
}
@@ -548,5 +563,7 @@ object PrefixSpan extends Logging {
548
563
* @param freqSequences frequent sequences
549
564
* @tparam Item item type
550
565
*/
551
- class PrefixSpanModel [Item ](val freqSequences : RDD [PrefixSpan .FreqSequence [Item ]])
566
+ @ Since (" 1.5.0" )
567
+ class PrefixSpanModel [Item ] @ Since (" 1.5.0" ) (
568
+ @ Since (" 1.5.0" ) val freqSequences : RDD [PrefixSpan .FreqSequence [Item ]])
552
569
extends Serializable
0 commit comments