@@ -65,7 +65,7 @@ public static void main(String[] args) {
65
65
JavaStreamingContext ssc = new JavaStreamingContext (sparkConf , Durations .seconds (1 ));
66
66
ssc .checkpoint ("." );
67
67
68
- // Initial RDD input to trackStateByKey
68
+ // Initial state RDD input to mapWithState
69
69
@ SuppressWarnings ("unchecked" )
70
70
List <Tuple2 <String , Integer >> tuples = Arrays .asList (new Tuple2 <String , Integer >("hello" , 1 ),
71
71
new Tuple2 <String , Integer >("world" , 1 ));
@@ -90,7 +90,7 @@ public Tuple2<String, Integer> call(String s) {
90
90
});
91
91
92
92
// Update the cumulative count function
93
- final Function4 <Time , String , Optional <Integer >, State <Integer >, Optional <Tuple2 <String , Integer >>> trackStateFunc =
93
+ final Function4 <Time , String , Optional <Integer >, State <Integer >, Optional <Tuple2 <String , Integer >>> mappingFunc =
94
94
new Function4 <Time , String , Optional <Integer >, State <Integer >, Optional <Tuple2 <String , Integer >>>() {
95
95
96
96
@ Override
@@ -104,7 +104,7 @@ public Optional<Tuple2<String, Integer>> call(Time time, String word, Optional<I
104
104
105
105
// This will give a Dstream made of state (which is the cumulative count of the words)
106
106
JavaMapWithStateDStream <String , Integer , Integer , Tuple2 <String , Integer >> stateDstream =
107
- wordsDstream .mapWithState (StateSpec .function (trackStateFunc ).initialState (initialRDD ));
107
+ wordsDstream .mapWithState (StateSpec .function (mappingFunc ).initialState (initialRDD ));
108
108
109
109
stateDstream .print ();
110
110
ssc .start ();
0 commit comments