zoukankan      html  css  js  c++  java
  • spark持久化

    package com.wll;
    import org.apache.spark.SparkConf;
    import org.apache.spark.api.java.JavaRDD;
    import org.apache.spark.api.java.JavaSparkContext;
    public class Persist {
        static SparkConf conf=new SparkConf().setMaster("local").setAppName("persist");
        static JavaSparkContext sc=new JavaSparkContext(conf);
        public static void main(String[] args){
            noCache();
            //cache();
        }
        public static void noCache(){
    
            JavaRDD<String> list=sc.textFile("C:\Users\wanglonglong\Desktop\hive-default.xml");
            long beginTime=System.currentTimeMillis();
            long count=list.count();
            System.out.println("无持久化第一次"+(System.currentTimeMillis()-beginTime));
    
            beginTime=System.currentTimeMillis();
            count=list.count();
            System.out.println("无持久化第二次"+(System.currentTimeMillis()-beginTime));
        }
        public static void cache(){
            JavaRDD<String> list=sc.textFile("C:\Users\wanglonglong\Desktop\hive-default.xml").cache();
            long beginTime=System.currentTimeMillis();
            long count=list.count();
            System.out.println("持久化第一次"+(System.currentTimeMillis()-beginTime));
    
            beginTime=System.currentTimeMillis();
            count=list.count();
            System.out.println("持久化第二次"+(System.currentTimeMillis()-beginTime));
        }
    }
  • 相关阅读:
    ASP.NET MVC中防止跨站请求攻击(CSRF)
    C#操作JSON学习
    C# 产生随机密码
    博客园上好的技术系列收藏
    OWIN学习
    bzoj1068: [SCOI2007]压缩
    bzoj1012: [JSOI2008]最大数maxnumber
    bzoj1055: [HAOI2008]玩具取名
    bzoj1011: [HNOI2008]遥远的行星
    bzoj1008: [HNOI2008]越狱
  • 原文地址:https://www.cnblogs.com/wakerwang/p/9568440.html
Copyright © 2011-2022 走看看