[学习笔记]

/*没有下面的话, 会报一个错误,java.lang.IllegalArgumentException: System memory 259522560 must be at least 4.718592E8(470M). Please use a larger heap size.这是memory不够,导致无法启动SparkContext*/        
        conf.set("spark.testing.memory", "2000000000");
        JavaSparkContext sc = new JavaSparkContext(conf);
/*下面的这种倒入的方法也行*/        
 //       JavaRDD<String> text = sc.textFile("hdfs://localhost:9000/README.txt");
/*原文件是:o1abc 45
o1abc 77
o1abc o1abc */        
        JavaRDD<String> text = sc.textFile("E://temp//input//friend.txt");
        List<String> strList = text.collect();
/*输出str:o1abc 45
str:o1abc 77
str:o1abc o1abc*/        
        for (String str : strList) {
            System.out.println("str:" + str);
        }
/*Interface FlatMapFunction<T,R>, Iterable<R> call(T t)(注意之后的版本,返回值有所变化。)*/        
        JavaRDD<String> words = text.flatMap(new FlatMapFunction<String, String>() {
/*List的super Interface 是java.lang.Iterable*/            
            public Iterable<String> call(String line) throws Exception {
                System.out.println("flatMap once, line is "+line );
                String[] wordsArray=line.split(" ");
                List<String> wordsList=Arrays.asList(wordsArray);
                return wordsList;
            }
        });
        List<String> wordsList = words.collect();
/*输出
flatMap once, line is o1abc 45
flatMap once, line is o1abc 77
flatMap once, line is o1abc o1abc
 
word:o1abc
word:45
word:o1abc
word:77
word:o1abc
word:o1abc*/        
        for (String word : wordsList) {
            System.out.println("word:" + word);
        }    
/* http://spark.apache.org/docs/latest/
 Interface PairFunction<T,K,V>
A function that returns key-value pairs (Tuple2<K, V>), and can be used to construct PairRDDs.
scala.Tuple2<K,V>     call(T t) 
*/    
/*  
flatMap once, line is o1abc 45(这句说明前面语句再次被执行)
in tuple2 word: o1abc

文章转载原文:https://blog.csdn.net/qq_44596980/article/details/93385009

System memory 259522560 must be at least 4.718592的更多相关文章

  1. java.lang.IllegalArgumentException: System memory 259522560 must be at least 471859200.

    报错信息 java.lang.IllegalArgumentException: System memory 259522560 must be at least 471859200. Please ...

  2. There is insufficient system memory to run this query 错误

    服务器环境大致情况如下: 操作系统:   Microsoft Windows Server 2003 R2 Enterprise Edition Service Pack 2 数据库  :   Mic ...

  3. System memory,AGP memory和video memory【转】

    system  memory就是电脑的内存条上的,一般都很大.显卡不能访问 . video memory就是显示卡上的显存,一般是32,64,128M这样,速度最快,显卡可直接访问 .用来描述电脑上一 ...

  4. spark System memory must be at least

    运行 ScalaSpark 程序的时候出现错误: System memory * must be at least *.Please increase heap size using the --dr ...

  5. STM32 microcontroller system memory boot mode

    The bootloader is stored in the internal boot ROM memory (system memory) of STM32 devices. It is pro ...

  6. Exception in thread "main" java.lang.IllegalArgumentException: System memory 202768384 must be at least 4.718592E8. Please use a larger heap size.

    Spark-submit 提交任务时候报错 Exception in thread "main" java.lang.IllegalArgumentException: Syste ...

  7. STM32的System memory

    Main Flash memory 是STM32内置的Flash,一般我们使用JTAG或者SWD模式下载程序时,就是下载到这个里面,重启后也直接从这启动程序. System memory 从系统存储器 ...

  8. System.Span, System.Memory,还有System.IO.Pipelines

    System.Span, System.Memory,还有System.IO.Pipelines 使用高性能Pipelines构建.NET通讯程序 .NET Standard支持一组新的API,Sys ...

  9. PatentTips - Modified buddy system memory allocation

    BACKGROUND Memory allocation systems assign blocks of memory on request. A memory allocation system ...

随机推荐

  1. 洛谷P1903 [国家集训队]数颜色 / 维护队列 ( 带 修 )

    题意:有两种操作: 1. Q L R代表询问你从第L支画笔到第R支画笔中共有几种不同颜色的画笔. 2. R P Col 把第P支画笔替换为颜色Col. 对每个1操作 输出答案: 带修莫队 模板题 (加 ...

  2. lodop第三方插件的使用

    原文链接 使用pdf.js插件与LODOP控件实现前端浏览器静默打印PDF文件 lodop官网地址:http://www.lodop.net/download.html lodop他人总结教程:htt ...

  3. P2051 [AHOI2009]中国象棋——DP(我是谁,我在哪,为什么)

    象棋,给你棋盘大小,然后放炮(炮的数量不限),不能让炮打到其他的炮,问方案数: 数据n,m<=200; 状态压缩似乎能做,但是我不会: 因为只要状态数,所以不必纠结每种状态的具体情况: 可以想出 ...

  4. scrapy框架之Selectors选择器

    Selectors(选择器) 当您抓取网页时,您需要执行的最常见任务是从HTML源中提取数据.有几个库可以实现这一点: BeautifulSoup是Python程序员中非常流行的网络抓取库,它基于HT ...

  5. Kafka详细原理

    Kafka Kafka是最初由Linkedin公司开发,是一个分布式.支持分区的(partition).多副本的(replica),基于zookeeper协调的分布式消息系统,它的最大的特性就是可以实 ...

  6. windows环境下启动mongodb服务

    方法一1.打开命令窗口,切换到mongodb安装目录下的“bin”目录中. 输入命令:cd E:\software\MongoDB\Server\3.4\bin 2.启动服务.输入命令:”mongod ...

  7. linux后台运行nodejs项目

    1.安装pm2,这里默认你已经安装了node.js和npm npm install pm2 -g 2.创建软连接 1)全局path路径 echo $PATH 2)pm2安装路径 安装pm2时,可看到p ...

  8. 在Winform中屏蔽UnityWebPlayer的右键以及自带Logo解决方案整理

    根据项目的需要,对已经完成的Unity三维模型以及游戏要使用Winform进行包装,也就是使用Winform做一层外壳.因此在展示Unity的时候使用到了UnityWebPlayer这个插件,对于此插 ...

  9. RGB-D(深度图像) & 图像深度

    RGB-D(深度图像)   深度图像 = 普通的RGB三通道彩色图像 + Depth Map   在3D计算机图形中,Depth Map(深度图)是包含与视点的场景对象的表面的距离有关的信息的图像或图 ...

  10. 二、navicat连接本地数据库以及远程数据库

    本地连接 1.打开navicat 2.连接 最后点击确定就连接成功了: 远程数据库 和上面一样.....