RDD transformations and actions can only be invoked by the driver, not inside of other transformations; for example, rdd1.map(x => rdd2.values.count() * x) is invalid because the values transformation and count action cannot be performed inside of the rdd1.map transformation. For more information, see SPARK-5063.
As the error says, i'm trying to map(transformation) a JavaRDD object within the main map function, how is it possible with Apache Spark?
The main JavaPairRDD object (TextFile and Word are defined classes):
JavaPairRDD<TextFile, JavaRDD<Word>> filesWithWords = new...
and map function:
filesWithWords.map(textFileJavaRDDTuple2 -> textFileJavaRDDTuple2._2().map(word -> new Word(word.getText(), (long) textFileJavaRDDTuple2._1().getText().split(word.getText()).length)));
also i tried foreach instead map function, but not working. (And of course searched SPARK-5063)