@@ -9,18 +9,19 @@ import java.time.Duration
9
9
object QuickStart {
10
10
11
11
// some function with random logic that we want to use in our map
12
- val function = PureFunction .OnKeyValue <Int , Int , Return .Map <Int >> { key, value, _ ->
13
- when {
14
- key < 25 -> // remove if key is less than 25
15
- Return .remove()
16
- key < 50 -> // expire after 2 seconds if key is less than 50
17
- Return .expire(Duration .ofSeconds(2 ))
18
- key < 75 -> // update if key is < 75.
19
- Return .update(value!! + 10000000 )
20
- else -> // else do nothing
21
- Return .nothing()
12
+ private val function =
13
+ PureFunction .OnKeyValue <Int , Int , Return .Map <Int >> { key, value, _ ->
14
+ when {
15
+ key < 25 -> // remove if key is less than 25
16
+ Return .remove()
17
+ key < 50 -> // expire after 2 seconds if key is less than 50
18
+ Return .expire(Duration .ofSeconds(2 ))
19
+ key < 75 -> // update if key is < 75.
20
+ Return .update(value!! + 10000000 )
21
+ else -> // else do nothing
22
+ Return .nothing()
23
+ }
22
24
}
23
- }
24
25
25
26
@JvmStatic
26
27
fun main (args : Array <String >) {
@@ -37,15 +38,15 @@ object QuickStart {
37
38
map.remove(1 ) // basic remove
38
39
39
40
// atomic write a Stream of key-value
40
- map.put(Stream .range(1 , 100 ).map { item -> KeyVal .create(item ) })
41
+ map.put(Stream .range(1 , 100 ).map { KeyVal .create(it ) })
41
42
42
43
// create a read stream from 10th key-value to 90th, increment values by 1000000 and insert.
43
44
val updatedKeyValuesStream =
44
45
map
45
46
.from(10 )
46
47
.stream()
47
- .takeWhile { keyVal -> keyVal .key() <= 90 }
48
- .map { keyVal -> KeyVal .create(keyVal .key(), keyVal .value() + 5000000 ) }
48
+ .takeWhile { it .key() <= 90 }
49
+ .map { KeyVal .create(it .key(), it .value() + 5000000 ) }
49
50
50
51
map.put(updatedKeyValuesStream)
51
52
@@ -54,6 +55,6 @@ object QuickStart {
54
55
// print all key-values to view the update.
55
56
map
56
57
.stream()
57
- .forEach { println (it) }
58
+ .forEach(::println)
58
59
}
59
60
}
0 commit comments