Github user tdas commented on a diff in the pull request: https://github.com/apache/spark/pull/2665#discussion_r20196528 --- Diff: streaming/src/test/java/org/apache/spark/streaming/JavaAPISuite.java --- @@ -1241,6 +1243,49 @@ public void testUpdateStateByKey() { @SuppressWarnings("unchecked") @Test + public void testUpdateStateByKeyWithInitial() { + List<List<Tuple2<String, Integer>>> inputData = stringIntKVStream; + + List<Tuple2<String, Integer>> initial = Arrays.asList ( + new Tuple2<String, Integer> ("california", 1), + new Tuple2<String, Integer> ("new york", 2)); + + JavaRDD<Tuple2<String, Integer>> tmpRDD = ssc.sparkContext().parallelize(initial); + JavaPairRDD<String, Integer> initialRDD = JavaPairRDD.fromJavaRDD (tmpRDD); + + List<List<Tuple2<String, Integer>>> expected = Arrays.asList( + Arrays.asList(new Tuple2<String, Integer>("california", 5), + new Tuple2<String, Integer>("new york", 7)), + Arrays.asList(new Tuple2<String, Integer>("california", 15), + new Tuple2<String, Integer>("new york", 11)), + Arrays.asList(new Tuple2<String, Integer>("california", 15), + new Tuple2<String, Integer>("new york", 11))); + + JavaDStream<Tuple2<String, Integer>> stream = JavaTestUtils.attachTestInputStream(ssc, inputData, 1); + JavaPairDStream<String, Integer> pairStream = JavaPairDStream.fromJavaDStream(stream); + + JavaPairDStream<String, Integer> updated = pairStream.updateStateByKey( + new Function2<List<Integer>, Optional<Integer>, Optional<Integer>>() { + @Override --- End diff -- Nit (do this if you have to make more changes): incorrect indentation. should be indented by more than the line with `new Function2...`
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org