java - Spark Converting JavaDStream<String> method to JavaPairDStream<String, String> method -
i have function in spark streaming code splits tweets individual words
javadstream<string> words = statuses .flatmap(new flatmapfunction<string, string>() { public iterable<string> call(string in) { return arrays.aslist(in.split(" ")); } });
i need modify returns words , original tweet against each word. have tried below, getting java.lang.classcastexception: scala.tuple2 cannot cast java.lang.iterable
error during run time.
javapairdstream<string, string> wordtweets = statuses.flatmaptopair( new pairflatmapfunction<string, string, string>() { public iterable<tuple2<string, string>> call(string in){ tuple2<string, string> tuple2 = new tuple2(arrays.aslist(in.split(" ")), in); return (iterable<tuple2<string, string>>) tuple2; } });
use following functionality
javapairdstream<string, string> locationspairrdd=outstreamrdd.maptopair(new pairfunction<string, string, string>() { public tuple2<string, string> call(string arg0) throws exception { return null; } });