欢迎关注大数据技术架构与案例微信公众号:过往记忆大数据
过往记忆博客公众号iteblog_hadoop
欢迎关注微信公众号:
过往记忆大数据

 分类:Spark函数

Apache Spark 2.4 中解决复杂数据类型的内置函数和高阶函数介绍

Apache Spark 2.4 中解决复杂数据类型的内置函数和高阶函数介绍
Apache Spark 2.4 是在11月08日正式发布的,其带来了很多新的特性具体可以参见这里,本文主要介绍这次为复杂数据类型新引入的内置函数和高阶函数。本次 Spark 发布共引入了29个新的内置函数来处理复杂类型(例如,数组类型),包括高阶函数。如果想及时了解Spark、Hadoop或者Hbase相关的文章,欢迎关注微信公共帐号:iteblog_hadoop

w397090770   5年前 (2018-11-21) 2445℃ 0评论2喜欢

Spark中函数addFile和addJar函数介绍

Spark中函数addFile和addJar函数介绍
  我们在使用Spark的时候有时候需要将一些数据分发到计算节点中。一种方法是将这些文件上传到HDFS上,然后计算节点从HDFS上获取这些数据。当然我们也可以使用addFile函数来分发这些文件。addFile  addFile方法可以接收本地文件(或者HDFS上的文件),甚至是文件夹(如果是文件夹,必须是HDFS路径),然后Spark的Driver和Exector

w397090770   8年前 (2016-07-11) 12422℃ 0评论13喜欢

Spark函数讲解:combineByKey

Spark函数讲解:combineByKey
  使用用户设置好的聚合函数对每个Key中的Value进行组合(combine)。可以将输入类型为RDD[(K, V)]转成成RDD[(K, C)]。函数原型[code lang="scala"]def combineByKey[C](createCombiner: V => C, mergeValue: (C, V) => C, mergeCombiners: (C, C) => C) : RDD[(K, C)]def combineByKey[C](createCombiner: V => C, mergeValue: (C, V) => C, mergeCombiners: (C, C) => C, numPartitio

w397090770   9年前 (2015-03-19) 22531℃ 0评论23喜欢

Spark函数讲解:collectAsMap

Spark函数讲解:collectAsMap
  功能和collect函数类似。该函数用于Pair RDD,最终返回Map类型的结果。官方文档说明:Return the key-value pairs in this RDD to the master as a Map.Warning: this doesn't return a multimap (so if you have multiple values to the same key, only one value per key is preserved in the map returned)函数原型[code lang="scala"]def collectAsMap(): Map[K, V][/code]实例[code lang="scala

w397090770   9年前 (2015-03-16) 16440℃ 0评论18喜欢

Spark函数讲解:collect

Spark函数讲解:collect
  将RDD转成Scala数组,并返回。函数原型[code lang="scala"]def collect(): Array[T]def collect[U: ClassTag](f: PartialFunction[T, U]): RDD[U][/code]  collect函数的定义有两种,我们最常用的是第一个。第二个函数需要我们提供一个标准的偏函数,然后保存符合的元素到MappedRDD中。实例[code lang="scala"]/** * User: 过往记忆 * Date: 15-03-11 * Ti

w397090770   9年前 (2015-03-11) 29744℃ 0评论22喜欢

Spark函数讲解:cogroup

Spark函数讲解:cogroup
  将多个RDD中同一个Key对应的Value组合到一起。函数原型[code lang="scala"]def cogroup[W1, W2, W3](other1: RDD[(K, W1)], other2: RDD[(K, W2)], other3: RDD[(K, W3)], partitioner: Partitioner) : RDD[(K, (Iterable[V], Iterable[W1], Iterable[W2], Iterable[W3]))] def cogroup[W1, W2, W3](other1: RDD[(K, W1)], other2: RDD[(K, W2)], other3: RDD[(K, W3)], numPartitions: Int) : RDD[(K

w397090770   9年前 (2015-03-10) 17409℃ 0评论17喜欢

Spark函数讲解:coalesce

Spark函数讲解:coalesce
  对RDD中的分区重新进行合并。函数原型[code lang="scala"]def coalesce(numPartitions: Int, shuffle: Boolean = false)    (implicit ord: Ordering[T] = null): RDD[T][/code]  返回一个新的RDD,且该RDD的分区个数等于numPartitions个数。如果shuffle设置为true,则会进行shuffle。实例[code lang="scala"]/** * User: 过往记忆 * Date: 15-03-09 * Time: 上午0

w397090770   9年前 (2015-03-09) 14120℃ 1评论5喜欢

Spark函数讲解序列文章

Spark函数讲解序列文章
  本博客近日将对Spark 1.2.1 RDD中所有的函数进行讲解,主要包括函数的解释,实例以及注意事项,每日一篇请关注。以下是将要介绍的函数,按照字母的先后顺序进行介绍,可以点的说明已经发布了。  aggregate、aggregateByKey、cache、cartesian、checkpoint、coalesce、cogroup groupWith collect, toArraycollectAsMap combineByKey computecontext, spar

w397090770   9年前 (2015-03-08) 7233℃ 0评论6喜欢

Spark函数讲解:checkpoint

Spark函数讲解:checkpoint
  为当前RDD设置检查点。该函数将会创建一个二进制的文件,并存储到checkpoint目录中,该目录是用SparkContext.setCheckpointDir()设置的。在checkpoint的过程中,该RDD的所有依赖于父RDD中的信息将全部被移出。对RDD进行checkpoint操作并不会马上被执行,必须执行Action操作才能触发。函数原型[code lang="scala"]def checkpoint()[/code]实例

w397090770   9年前 (2015-03-08) 60511℃ 0评论7喜欢

Spark函数讲解:cartesian

Spark函数讲解:cartesian
  从名字就可以看出这是笛卡儿的意思,就是对给的两个RDD进行笛卡儿计算。官方文档说明:Return the Cartesian product of this RDD and another one, that is, the RDD of all pairs of elements (a, b) where a is in `this` and b is in `other`.函数原型[code lang="scala"]def cartesian[U: ClassTag](other: RDD[U]): RDD[(T, U)][/code]  该函数返回的是Pair类型的RDD,计算结果

w397090770   9年前 (2015-03-07) 11176℃ 0评论5喜欢