Spark: Best practice for retrieving big data from RDD to local machine
|
've got big RDD(1gb) in yarn cluster. On local machine, which use this cluster I have only 512 mb. I'd like to iterate over values in RDD on my local machine. I can't use collect(), because it would create too big array locally which more then my heap. I need some iterative way. There is method iterator(), but it requires some additional information, I can't provide. UDP: commited toLocalIterator method |
|||||||||
|
|
Update: TL;DR And the original answer might give a rough idea how it works: First of all, get the array of partition indexes:
Then create smaller rdds filtering out everything but a single partition. Collect the data from smaller rdds and iterate over values of a single partition:
I didn't try this code, but it should work. Please write a comment if it won't compile. Of cause, it will work only if the partitions are small enough. If they aren't, you can always increase the number of partitions with |
|||||||||||||
|
Did you find this question interesting? Try our newsletter
Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).
|
Wildfire answer seems semantically correct, but I'm sure you should be able to be vastly more efficient by using the API of Spark. If you want to process each partition in turn, I don't see why you can't using
Or this
|
|||||||||||||
|
|
Here is the same approach as suggested by @Wildlife but written in pyspark. The nice thing about this approach - it lets user access records in RDD in order. I'm using this code to feed data from RDD into STDIN of the machine learning tool's process.
Produces output:
|
||||
|
Map/filter/reduce using Spark and download the results later? I think usual Hadoop approach will work. Api says that there are map - filter - saveAsFile commands:https://spark.incubator.apache.org/docs/0.8.1/scala-programming-guide.html#transformations |
|||||||||||||
|
|
For Spark 1.3.1 , the format is as follows
|
Spark: Best practice for retrieving big data from RDD to local machine的更多相关文章
- Why Apache Spark is a Crossover Hit for Data Scientists [FWD]
Spark is a compelling multi-purpose platform for use cases that span investigative, as well as opera ...
- [Spark] 02 - Practice Spark
开发环境 教学视频:Spark的环境搭建,需安装配置环境:Java, Hadoop 环境配置:玩转大数据分析!Spark2.X+Python 精华实战课程(免费)[其实只是环境搭建] 进入pyspar ...
- spark SQL (四)数据源 Data Source----Parquet 文件的读取与加载
spark SQL Parquet 文件的读取与加载 是由许多其他数据处理系统支持的柱状格式.Spark SQL支持阅读和编写自动保留原始数据模式的Parquet文件.在编写Parquet文件时,出于 ...
- Spark菜鸟学习营Day1 从Java到RDD编程
Spark菜鸟学习营Day1 从Java到RDD编程 菜鸟训练营主要的目标是帮助大家从零开始,初步掌握Spark程序的开发. Spark的编程模型是一步一步发展过来的,今天主要带大家走一下这段路,让我 ...
- The ‘Microsoft.ACE.OLEDB.12.0′ provider is not registered on the local machine. (System.Data)
When you try to import Excel 2007 or later “.xlsx” files into an SQL Server 2008 database you may ge ...
- Microsoft SQL Server 17导出xlsx文件时报错:The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. (System.Data)
导出数据时报错: 如果你是导出office 2007格式 TITLE: SQL Server Import and Export Wizard ---------------------------- ...
- Spark学习之键值对(pair RDD)操作(3)
Spark学习之键值对(pair RDD)操作(3) 1. 我们通常从一个RDD中提取某些字段(如代表事件时间.用户ID或者其他标识符的字段),并使用这些字段为pair RDD操作中的键. 2. 创建 ...
- <Spark><Programming><Loading and Saving Your Data>
Motivation Spark是基于Hadoop可用的生态系统构建的,因此Spark可以通过Hadoop MapReduce的InputFormat和OutputFormat接口存取数据. Spar ...
- spark SQL (五)数据源 Data Source----json hive jdbc等数据的的读取与加载
1,JSON数据集 Spark SQL可以自动推断JSON数据集的模式,并将其作为一个Dataset[Row].这个转换可以SparkSession.read.json()在一个Dataset[Str ...
随机推荐
- 算法笔记_178:历届试题 邮局(Java)
目录 1 问题描述 2 解决方案 1 问题描述 问题描述 C村住着n户村民,由于交通闭塞,C村的村民只能通过信件与外界交流.为了方便村民们发信,C村打算在C村建设k个邮局,这样每户村民可以去离自己 ...
- Statusbar
Main window The QtGui.QMainWindow class provides a main application window. This enables to create a ...
- 1z0-052 q209_9
9: You are working on an instance started using the SPFILE. You want to move the Flash Recovery Area ...
- python2.7中minetypes.py的UnicodeDecodeError
问题: python错误提示: UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not ...
- apacheBench对网站进行压力测试
apacheBench对网站进行压力测试 分类: 学习 2014-02-19 10:35 4154人阅读 评论(1) 收藏 举报 apacheBench压力测试 Apache Benchmark下载 ...
- Job for vsftpd.service failed because the control process exited with error code
# systemctl start vsftpd.serviceJob for vsftpd.service failed because the control process exited wit ...
- AbatorForEclipse插件使用总结
AbatorForEclipse是IbatorForEclipse之前的一个老版插件.插件装好后,我们来使用看看:1,新建一个工程AbatorTest,点击右键,新建一个abatorConfig.xm ...
- HDUOJ----2512一卡通大冒险
一卡通大冒险 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- Java I/O 应用程序设计
课程 Java面向对象程序设计 一.实验目的 掌握数据流的使用 二.实验环境 1.微型计算机一台 2.WINDOWS操作系统,Java SDK,Eclipse开发环境 三.实验内容 1.使用Scan ...
- 【LeetCode】39. Combination Sum (2 solutions)
Combination Sum Given a set of candidate numbers (C) and a target number (T), find all unique combin ...
