zoukankan      html  css  js  c++  java
  • CacheTest

    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.storage.StorageLevel;
    public class CacheTest{
    public static void main(String[] args) {
    SparkConf conf = new SparkConf();
    conf/*.setMaster("local")*/.setAppName("CacheTest");
    JavaSparkContext jsc = new JavaSparkContext(conf);
    JavaRDD<String> lines = jsc.textFile("hdfs://node1:9000/test/NASA_access_log_Aug95");
    // lines = lines.cache();
    // lines = lines.persist(StorageLevel.MEMORY_ONLY_2());
    lines = lines.persist(new StorageLevel(false, true, false, true, 3));
    long startTime = System.currentTimeMillis();
    long count = lines.count();
    long endTime = System.currentTimeMillis();
    System.out.println("共"+count+ "条数据,"+"初始化时间+cache时间+计算时间="+ (endTime-startTime));
    /*
    long countStartTime = System.currentTimeMillis();
    long countrResult = lines.count();
    long countEndTime = System.currentTimeMillis();
    System.out.println("共"+countrResult+ "条数据,"+"计算时间="+ (countEndTime-countStartTime));
    lines.unpersist();
    long countStartTime2 = System.currentTimeMillis();
    long countrResult2 = lines.count();
    long countEndTime2 = System.currentTimeMillis();
    System.out.println("共"+countrResult2+ "条数据,"+"计算时间="+ (countEndTime2-countStartTime2));*/


    // lines.unpersist();
    while(true){

    }

    // jsc.stop();
    }
    }

  • 相关阅读:
    Android(安卓)全套开发资料视频+源码
    腾讯qlv视频转为MP4格式工具
    优酷爱奇艺视频转换为MP4格式工具
    JAVA全套资料含视频源码(持续更新~)
    PPT、Word、Excel模板免费下载
    图片下载
    aspx使用KindEditor副文本框插件出现检测到有潜在危险
    跨域请求
    WEUI滚动加载
    jq复制
  • 原文地址:https://www.cnblogs.com/huiandong/p/9194604.html
Copyright © 2011-2022 走看看