@@ -25,7 +25,7 @@ import scala.reflect.ClassTag
25
25
import scala .util .Random
26
26
27
27
// utility classes to generate random data
28
- abstract class CStream [T : ClassTag ] {
28
+ abstract class CStream [+ T : ClassTag ] {
29
29
def next (): T
30
30
31
31
// roll a dice that gives max to min uniformly, with nulls interspersed as per null rate
@@ -105,12 +105,12 @@ object CStream {
105
105
.toArray
106
106
}
107
107
108
- class PartitionStream (count : Int , partitionSpec : PartitionSpec ) extends CStream [Any ] {
108
+ class PartitionStream (count : Int , partitionSpec : PartitionSpec ) extends CStream [String ] {
109
109
val keys : Array [String ] = genPartitions(count, partitionSpec)
110
110
override def next (): String = Option (roll(keys.length, nullRate = 0 )).map(dice => keys(dice.toInt)).get
111
111
}
112
112
113
- class StringStream (count : Int , prefix : String , nullRate : Double = 0.2 ) extends CStream [Any ] {
113
+ class StringStream (count : Int , prefix : String , nullRate : Double = 0.2 ) extends CStream [String ] {
114
114
val keyCount : Int = (count * (1 - nullRate)).ceil.toInt
115
115
val keys : Array [String ] = {
116
116
val fullKeySet = (1 until (count + 1 )).map(i => s " $prefix$i" )
@@ -121,7 +121,7 @@ object CStream {
121
121
}
122
122
123
123
class TimeStream (window : Window , roundMillis : Long = 1 , maxTs : Long = System .currentTimeMillis())
124
- extends CStream [Any ] {
124
+ extends CStream [Long ] {
125
125
private val minTs = maxTs - window.millis
126
126
127
127
def round (v : Long ): Long = (v / roundMillis) * roundMillis
@@ -131,17 +131,17 @@ object CStream {
131
131
}
132
132
}
133
133
134
- class IntStream (max : Int = 10000 , nullRate : Double = 0.1 ) extends CStream [Any ] {
134
+ class IntStream (max : Int = 10000 , nullRate : Double = 0.1 ) extends CStream [Integer ] {
135
135
override def next (): Integer =
136
136
Option (roll(max, 1 , nullRate = nullRate)).map(dice => Integer .valueOf(dice.toInt)).orNull
137
137
}
138
138
139
- class LongStream (max : Int = 10000 , nullRate : Double = 0.1 ) extends CStream [Any ] {
139
+ class LongStream (max : Int = 10000 , nullRate : Double = 0.1 ) extends CStream [JLong ] {
140
140
override def next (): JLong =
141
141
Option (roll(max, 1 , nullRate = nullRate)).map(java.lang.Long .valueOf(_)).orNull
142
142
}
143
143
144
- class DoubleStream (max : Double = 10000 , nullRate : Double = 0.1 ) extends CStream [Any ] {
144
+ class DoubleStream (max : Double = 10000 , nullRate : Double = 0.1 ) extends CStream [JDouble ] {
145
145
override def next (): JDouble =
146
146
Option (rollDouble(max, 1 , nullRate = nullRate)).map(java.lang.Double .valueOf(_)).orNull
147
147
}
0 commit comments