[学习笔记]

/*没有下面的话, 会报一个错误,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. Spoj Query on a tree SPOJ - QTREE(树链剖分+线段树)

    You are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, ...

  2. JS 的 new 到底是干什么的?

    大部分讲 new 的文章会从面向对象的思路讲起,但是我始终认为,在解释一个事物的时候,不应该引入另一个更复杂的事物. 今天我从「省代码」的角度来讲 new. --------------------- ...

  3. 求ascii 然后做运算

    介绍 ABC 返回每个字符的ascii A->65 B->66 C->77 组成656667 把所有的7替换成1 然后变成 656667 和 656661 每个数值做加法 然后做减法 ...

  4. Mysql中行转列和列转行

    一.行转列 即将原本同一列下多行的不同内容作为多个字段,输出对应内容. 建表语句 DROP TABLE IF EXISTS tb_score; CREATE TABLE tb_score(    id ...

  5. go区分操作系统

    package main import ( "fmt" "runtime" ) func main() { fmt.Println("Go runs ...

  6. Change Assembly Version in a compiled .NET assembly

    Change Assembly Version in a compiled .NET assembly You can use ILMerge: ILMerge.exe Foo.dll /ver:1. ...

  7. 性能分析 | 线上CPU100%排查

    不知道在大家面试中,有没有遇到这个问题: 生产服务器上部署了几个java程序,突然出现了CPU100%的异常告警,你如何定位出问题呢? 这个问题分为两版回答! 高调版 对不起,我是做研发的,这个问题在 ...

  8. [转][echarts]地图轮播

    代码片断: 来自:https://blog.csdn.net/qq_36947128/article/details/90899564 function Play(){ chart.dispatchA ...

  9. Python - pytesseract 机器视觉

    机器视觉  - tesseract ( 验证码 ) 安装 Ubuntu sudo apt-get install tesseract-ocr Windows 下载安装包 添加环境变量(Path) :搜 ...

  10. oracle 中SQL 语句开发语法 SELECT INTO含义

    oracle 中SQL 语句开发语法 SELECT INTO含义 在ORACLE中SELECT INTO是如何使用的,什么意思?和SQL SERVER的不一样?   和sqlserver的不一样sql ...