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;     } }); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -