@@ -83,9 +83,9 @@ public Optional<Integer> call(List<Integer> values, Optional<Integer> state) {
83
83
ssc .checkpoint ("." );
84
84
85
85
// Initial RDD input to updateStateByKey
86
- JavaPairRDD < String , Integer > initialRDD = ssc . sc ()
87
- . parallelizePairs ( Arrays . asList ( new Tuple2 <String , Integer >("hello " , 1 ), new Tuple2 < String , Integer >
88
- ( "world" , 1 )) );
86
+ List < Tuple2 < String , Integer >> tuples = Arrays . asList ( new Tuple2 < String , Integer >( "hello" , 1 ),
87
+ new Tuple2 <String , Integer >("world " , 1 ));
88
+ JavaPairRDD < String , Integer > initialRDD = ssc . sc (). parallelizePairs ( tuples );
89
89
90
90
JavaReceiverInputDStream <String > lines = ssc .socketTextStream (
91
91
args [0 ], Integer .parseInt (args [1 ]), StorageLevels .MEMORY_AND_DISK_SER_2 );
@@ -105,8 +105,8 @@ public Tuple2<String, Integer> call(String s) {
105
105
});
106
106
107
107
// This will give a Dstream made of state (which is the cumulative count of the words)
108
- JavaPairDStream <String , Integer > stateDstream = wordsDstream .updateStateByKey (updateFunction , new
109
- HashPartitioner (ssc .sc ().defaultParallelism ()), initialRDD );
108
+ JavaPairDStream <String , Integer > stateDstream = wordsDstream .updateStateByKey (updateFunction ,
109
+ new HashPartitioner (ssc .sc ().defaultParallelism ()), initialRDD );
110
110
111
111
stateDstream .print ();
112
112
ssc .start ();
0 commit comments