写本文原因是之前已经将官网文档阅读过几遍,但是后来工作接触spark机会较少所以没有跟进新特性,利用周末一点闲暇时间粗略阅读一篇,将自己之前遇见过的问题解决过的问题印象不深刻的问题做一下记录。

1关于RDD缓存:

Don’t spill to disk unless the functions that computed your datasets are expensive, or they filter a large amount of the data. Otherwise, recomputing a partition may be as fast as reading it from disk.  除非生成RDD的计算逻辑非常复杂,否则不要溢写到磁盘,性能低。当数据丢失重新计算都比读取磁盘快。

2 spark 加速器新特性:

While this code used the built-in support for accumulators of type Long, programmers can also create their own types by subclassing AccumulatorV2. The AccumulatorV2 abstract class has several methods which one has to override: reset for resetting the accumulator to zero, add for adding another value into the accumulator, merge for merging another same-type accumulator into this one. Other methods that must be overridden are contained in the API documentation. For example, supposing we had a MyVector class representing mathematical vectors, we could write:

支持新的方法,reset,merg等方法;reset将加速器置0,merge方法用于合并另一个类型相同的加速器。

注意:

For accumulator updates performed inside actions only, Spark guarantees that each task’s update to the accumulator will only be applied once, i.e. restarted tasks will not update the value. In transformations, users should be aware of that each task’s update may be applied more than once if tasks or job stages are re-executed.

Accumulators do not change the lazy evaluation model of Spark. If they are being updated within an operation on an RDD, their value is only updated once that RDD is computed as part of an action. Consequently, accumulator updates are not guaranteed to be executed when made within a lazy transformation like map().

核心要点是:

加速器只有在action算子执行时候才会真正运算,加速器不会改变Spark的延迟计算模型。例如错误代码:

val accum = sc.longAccumulator
data.map { x => accum.add(x); x }
// Here, accum is still 0 because no actions have caused the map operation to be computed.

  

3:Spark使用Spark提供的API进行提交作业

Launching Spark jobs from Java / Scala

The org.apache.spark.launcher package provides classes for launching Spark jobs as child processes using a simple Java API.

4:关于Structured Streaming文档新特性

Structured Streaming在Spark2.3之前是一款基于Sparl SQL引擎的流处理计算引擎,将流数据抽象为意向无界限的表,每当有流数据到来时候进行追加或者更新结果;但是当Spark2.3的到到来,Spark提供了一种新的连续更低延迟的连续流处理引擎,直白说就是不是基于微批次的而是真正的流处理引擎。

官方文档原文:

Internally, by default, Structured Streaming queries are processed using a micro-batch processing engine, which processes data streams as a series of small batch jobs thereby achieving end-to-end latencies as low as 100 milliseconds and exactly-once fault-tolerance guarantees. However, since Spark 2.3, we have introduced a new low-latency processing mode called Continuous Processing, which can achieve end-to-end latencies as low as 1 millisecond with at-least-once guarantees. Without changing the Dataset/DataFrame operations in your queries, you will be able to choose the mode based on your application requirements.

5:Structured Streaming处理流数据的过程

Spark并不保存输入的数据,处理完毕新到来的流数据之后便开始进行回收新数据,只保存新到来的流数据的状态信息(对于wordcount而言就是新来的数据的wordcount结果,然后这部分结果更新到ResultTable中)。原文:

Note that Structured Streaming does not materialize the entire table. It reads the latest available data from the streaming data source, processes it incrementally to update the result, and then discards the source data.it only keeps around the minimal intermediate state data as required to update the result 。 

延迟数据的处理:对于迟到的数据处理spark也是用watermarking机制,watermarking就是允许延迟的时间阈值,spark根据这个阈值进行清除中间状态数据。

6:关于WaterMarking原文:

a: watermarking是什么?

Since Spark 2.1, we have support for watermarking which allows the user to specify the threshold of late data, and allows the engine to accordingly clean up old state.

译文:指定的延迟阈值的数值并不是watermark,延迟时间阈值是一个单独的参数用于指定可以接受的延迟。watermark最重要的用途让计算引擎根据watermark进行清理不必要的中间状态,watermark=计算引擎看见的最大eventtime-延迟时间阈值。当迟到的数据在watermark之前的话则就放弃,否则进行处理。估计你们看着有点难懂:举个例子,例如此时watermark=12:05,突然来一个记录的时间是12:03,此时该记录将会被丢失,因为12:05之前的中间数据已经被清除,但是如果迟到的记录时间是12:06的话则就可以被正常处理。

例如图:

图中迟到的记录 (12:04 donkey)看到的watermark=12:11,12:04记录属于12:00-12:10窗口中,但是由于12:11之前的数据都被清除了,所以12:00-12:10数据被清除,所以12:04的数据是无法被处理的,因此丢丢弃。

b: watermarking如何工作?

In other words, late data within the threshold will be aggregated, but data later than the threshold will start getting dropped .

7:Continuous Processing

Continuous Processing是一个新的计算引擎,是一个真正的连续流处理引擎,高容错,低延迟等特性,但是一次性语义保证是:最少一次,即: at-least-once。

Spark2.3文档翻阅的一点简略笔记(WaterMarking)的更多相关文章

  1. css文档之盒模型阅读笔记

    前段时间抽空仔细阅读了w3c的css文档关于盒模型方面的一些基础知识.边读边记录了一些要点,在此做些整理,与大家分享,如有理解有误之处,请不吝指教. 1.综述 文档中的每个元素被描绘为矩形盒子.渲染引 ...

  2. 基于swagger进行接口文档的编写

    0. 前言 近期忙于和各个银行的代收接口联调,根据遇到的问题,对之前编写的接口进行了修改,需求收集和设计接口时想到了方方面面,生产环境下还是会遇到意想不到的问题,好在基本的执行逻辑已确定,因此只是对接 ...

  3. java简单实现用语音读txt文档

    最近比较无聊,随便翻着博客,无意中看到了有的人用VBS读文本内容,也就是读几句中文,emmm,挺有趣的,实现也很简单,都不需要安装什么环境,直接新建txt文件,输入一些简单的vbs读文本的代码,然后将 ...

  4. Elasticsearch-如何控制存储和索引文档(_source、_all、返回源文档的某些字段)

    Elasticsearch-如何控制存储和索引文档(_source._all) _source:可以在索引中存储文档._all:可以在单个字段上索引所有内容. 1. 存储原有内容的_source _s ...

  5. 下载网页中的 pdf 各种姿势,教你如何 carry 各种网页上的 pdf 文档。

    关联词: PDF 下载 FLASH 网页 HTML 报告 内嵌 浏览器 文档 FlexPaperViewer swfobject. 这个需求是最近帮一个妹子处理一下各大高校网站里的 PDF 文档下载, ...

  6. 自定义WIZ文档模板

    WIZ文档模板 1.在wiz笔记里面新建一个笔记,并将其做成一个模板 例子: 2.该作为模板的笔记制作完成后,右键-高级-另存为  导出为html格式 3.将导出的文件和文件夹(有时候只有一个htm文 ...

  7. 每天一点Linux-01文档系统

    Windows: 以多根的方式组织文档 C: D: E:Linux: 以单根的方式组织文档 / /目录结构: FSH (Filesystem Hierarchy Standard) [root@yan ...

  8. DL4NLP —— seq2seq+attention机制的应用:文档自动摘要(Automatic Text Summarization)

    两周以前读了些文档自动摘要的论文,并针对其中两篇( [2] 和 [3] )做了presentation.下面把相关内容简单整理一下. 文本自动摘要(Automatic Text Summarizati ...

  9. [转]OpenContrail 体系架构文档

    OpenContrail 体系架构文档 英文原文:http://opencontrail.org/opencontrail-architecture-documentation/ 翻译者:@KkBLu ...

随机推荐

  1. PetaPoco源代码学习--2.TableInfo、ColumnInfo类和Cache类

    当把常用的特性填写到POCO实体类时,执行数据库操作时,需要根据实体类上的特性信息进行相应的操作,PetaPoco中的TableInfo和ColumnInfo类就是用来保存实体类上的特性信息. Tab ...

  2. VB.NET文件读写(C#可以改写)

    VB.NET也可以用using 先FileStream,再StreamReader(写用StreamWriter) Using fs As New FileStream(p1, FileMode.Op ...

  3. C# 四舍五入 保留两位小数(转载)

    一.C#默认四舍五入 1 Math.Round(45.367,2) //Returns 45.372 Math.Round(45.365,2) //Returns 45.36二.C#中的Round() ...

  4. 安装Mysql报错**此用户已存在!**

    我是安装了两个installer下载器,将其中一个删除运行另一个就会报这个错. 解决办法:将删除的那个installer从回收站还原.

  5. Java面试题—初级(9)

    139. Java中的泛型是什么 ? 使用泛型的好处是什么? 泛型是Java SE 1.5的新特性,泛型的本质是参数化类型,也就是说所操作的数据类型被指定为一个参数. 好处: 1.类型安全,提供编译期 ...

  6. HDU2389(KB10-F 二分图最大匹配Hopcroft_Karp)

    Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Java/Ot ...

  7. CSS计数器(序列数字字符自动递增)详解———张鑫旭

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=4303 一.挖坟不可耻 ...

  8. drop,truncate,delete 区别

    一.SQL中的语法 1.drop table 表名称                         eg: drop table  dbo.Sys_Test   2.truncate table 表 ...

  9. WEB服务器、应用程序服务器、HTTP服务器的区别

    WEB服务器.应用程序服务器.HTTP服务器的区别 Web服务器: 基本功能就是提供Web信息浏览服务.它只需支持HTTP协议.HTML文档格式及URL.与客户端的网络浏览器配合.因为Web服务器主要 ...

  10. js-ES6学习笔记-Class(5)

    1.原生构造函数会忽略apply方法传入的this,也就是说,原生构造函数的this无法绑定,导致拿不到内部属性.比如,Array构造函数有一个内部属性[[DefineOwnProperty]],用来 ...