2015-11-02 148 views
0

是否有使用Apache-Spark的Java API將JavaRDD<ArrayList<T>>轉換爲JavaRDD<T>的直接方式?將JavaRDD <ArrayList<T>>轉換爲JavaRDD <T>

JavaPairRDD<NullWritable, ArrayList<Record>> baseRDD = sc.newAPIHadoopFile(args[2], InputFormat2.class, NullWritable.class,ArrayList.class, conf); 
JavaRDD<ArrayList<Record>> mapLines1 = baseRDD.values(); 

我要轉換的JavaRDD<ArrayList<Record>>JavaRDD<Record>

回答

2

你可以簡單地flatMap

rdd.flatMap(new FlatMapFunction<ArrayList<Record>, Record>() { 
    @Override 
    public Iterable<Record> call(ArrayList<Record> records) { 
    return records; 
    } 
}); 
相關問題