spark action 操作(1)
2016-05-26 22:19
471 查看
下面介绍spark的几个action操作:
1、first(),返回RDD中的第一个元素(不排序)。
def first(): T // Return the first element in this RDD.
2、count(),返回RDD中的元素数量。
def count(): Long //Return the number of elements in the RDD.
3、collect(),返回一个包含RDD中所有元素的数组。
def collect(): Array[T] //Return an array that contains all of the elements in this RDD.
4、take(n),用于获取RDD中从0到n-1下标的元素,不排序。
def take(num: Int): Array[T] //Take the first num elements of the RDD. It works by first scanning one partition, and use the results from that partition to estimate the number of additional partitions needed to satisfy
the limit.
5、top(n),用于从RDD中,按照默认(降序)或者指定的排序规则,返回前n个元素。
def top(num: Int)(implicit ord: Ordering[T]): Array[T]
//Returns the top k (largest) elements from this RDD as defined by the specified implicit Ordering[T] and maintains the ordering.
6、takeOrdered(n),takeOrdered和top类似,只不过和top相反的顺序返回元素。
def takeOrdered(num: Int)(implicit ord: Ordering[T]): Array[T]
//Returns the first k (smallest) elements from this RDD as defined by the specified implicit Ordering[T] and maintains the ordering.
Reference:
https://spark.apache.org/docs/1.6.0/api/scala/index.html#org.apache.spark.rdd.RDD
http://lxw1234.com/archives/2015/07/363.htm
1、first(),返回RDD中的第一个元素(不排序)。
def first(): T // Return the first element in this RDD.
2、count(),返回RDD中的元素数量。
def count(): Long //Return the number of elements in the RDD.
3、collect(),返回一个包含RDD中所有元素的数组。
def collect(): Array[T] //Return an array that contains all of the elements in this RDD.
4、take(n),用于获取RDD中从0到n-1下标的元素,不排序。
def take(num: Int): Array[T] //Take the first num elements of the RDD. It works by first scanning one partition, and use the results from that partition to estimate the number of additional partitions needed to satisfy
the limit.
5、top(n),用于从RDD中,按照默认(降序)或者指定的排序规则,返回前n个元素。
def top(num: Int)(implicit ord: Ordering[T]): Array[T]
//Returns the top k (largest) elements from this RDD as defined by the specified implicit Ordering[T] and maintains the ordering.
6、takeOrdered(n),takeOrdered和top类似,只不过和top相反的顺序返回元素。
def takeOrdered(num: Int)(implicit ord: Ordering[T]): Array[T]
//Returns the first k (smallest) elements from this RDD as defined by the specified implicit Ordering[T] and maintains the ordering.
Reference:
https://spark.apache.org/docs/1.6.0/api/scala/index.html#org.apache.spark.rdd.RDD
http://lxw1234.com/archives/2015/07/363.htm
相关文章推荐
- CentOS环境下vim配置(有图)
- css3 -- 文本
- 205. Isomorphic Strings
- 类、函数和正则表达式
- 删除目录软链接注意事项
- 京东2016校招编程题
- JavaEE的十大安全控制
- c中的\n和单双引号
- GetProcAddress函数实现和分析
- MY_GEEK_画板
- linux下的gedit命令使用方法与技巧
- EnTaroTassadar【4】
- EnTaroTassadar【4】
- Sublime Text使用技巧
- python模块介绍- SocketServer 网络服务框架
- Android6.0短信获取
- Cannot proceed with delivery: an existing transporter instance is currently uploading this package
- Azure 国际篇_新旧版本迁移(二)_迁移VHD文件
- STM32F0_新建软件工程详细过程
- sdutoj 3273 山东理工大学第七届acm校赛--经济节约