作者:sferra石_455 | 来源:互联网 | 2023-10-15 12:29
packagecom.bjsxt.spark.others;importorg.apache.spark.SparkConf;importorg.apache.spark.api.
package com.bjsxt.spark.others;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.VoidFunction;
public class ReadDataFromCheckpoint {
public static void main(String[] args) {
SparkConf cOnf= new SparkConf();
conf.setMaster("local").setAppName("wc");
JavaSparkContext sc = new JavaSparkContext(conf);
// JavaRDD lines = sc.textFile("./words.txt");
// sc.setCheckpointDir("./checkpoint");
// lines.checkpoint();
// lines.count();
JavaRDD checkpointFile = sc.checkpointFile("./checkpoint/b54385c5-0017-498f-b881-44fea23c55b8/rdd-1");
checkpointFile.foreach(new VoidFunction() {
/**
*
*/
private static final long serialVersiOnUID= 1L;
@Override
public void call(String s) throws Exception {
System.out.println(s);
}
});
}
}
ReadDataFromCheckpoint