I am trying to implement K-nearest neighbor algorithm in Spark. I was wondering if it is possible to work with nested RDD's. This will make my life a lot easier. Consider the following code snippet.
public static void main (String[] args){
//blah blah code
JavaRDD<Double> temp1 = testData.map(
new Function<Vector,Double>(){
public Double call(final Vector z) throws Exception{
JavaRDD<Double> temp2 = trainData.map(
new Function<Vector, Double>() {
public Double call(Vector vector) throws Exception {
return (double) vector.length();
}
}
);
return (double)z.length();
}
}
);
}
Currently I am getting error with this nested settings (I can post here the full log). Is it allowed in the fist place? Thanks