Today, using Java+spark to implement Flatmaptopair's lambda function, the code is as follows:
javapairrdd<string, string> Extractsessionsrdd = Time2sessionsrdd.flatmaptopair (tuple->{ List New arraylist<>(); // ... return extractsessionids;});
Result Error:
No instance (s) of type variable (s) k2,v2 so, list<tuple2<string,string>> conforms to ITERATOR<TUPLE2&L T String,string>>
The reason for surfing the internet is because the Spark 2.0 above requires returning an instance of iterator.
So the code below (red) is changed, and the error disappears.
javapairrdd<string, string> Extractsessionsrdd = Time2sessionsrdd.flatmaptopair (tuple->{ List< tuple2<string, string>> extractsessionids = new arraylist<>(); // ... return extractsessionids. iterator ();});
Record, Memo.
Reference: http://blog.csdn.net/t1dmzks/article/details/70234272
Java+spark problems encountered in implementing Flatmaptopair lambda functions and their solutions