scala - Manipulating Vectors and Lists in RDDs -
i'm new spark , scala , need following rdd transformation:
input (macaddress,vector(list(ts1,ts2),list(ts2,ts3),list.....)
(c8:3a:bv:b1:3a:e0,vector(list(1472820071, 1472821088), list(1472821088, 1472821429), list(1472821429, 1472824217)))
desided output (macaddress,vector(intvalue,intvalue,...))
(c8:3a:bv:b1:3a:e0,vector(1472821088-1472820071, 1472821429-1472821088,1472824217-1472821429))
in short, have rdd grouped key (macaddress) containing paired lists of values. need transform vector of lists vector containing paired differences computed lists (secondelement-firstelement). number of paired lists in vector variable in rdd (depends macaddress considered)
i don't know transformation have use in case.
thanks
make updates based on datatype
def flattenrddelements(x:(macaddress,vector[list[int]]) ) : (macaddress,vector[string]) = { x match { case (s,y) => (s,y.map(switchlistelements)) } } def switchlistelements(x: list[int]):string = x match { case a::b::nil => b+"-"+a } rdd.map(r => flattenrddelements(r))
Comments
Post a Comment