com.datastax.insight.ml.spark.data.rdd.RDDWriter Maven / Gradle / Ivy
package com.datastax.insight.ml.spark.data.rdd;
import com.datastax.insight.spec.RDDOperator;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.storage.StorageLevel;
public class RDDWriter implements RDDOperator {
public static void cache(JavaRDD rdd){
rdd.cache();
}
public static void persist(JavaRDD rdd,String storageLevel){
StorageLevel level=StorageLevel.fromString(storageLevel);
rdd.persist(level);
}
public static void unpersist(JavaRDD rdd,boolean blocking){
rdd.unpersist(blocking);
}
public static void saveFile(JavaRDD rdd,String format,String path){
if(format.equals("object")){
rdd.saveAsObjectFile(path);
}else if(format.equals("text")){
rdd.saveAsTextFile(path);
}
}
public static void checkpoint(JavaRDD rdd){
rdd.checkpoint();
}
}