您当前的位置: 首页 >  hadoop

宝哥大数据

暂无认证

  • 0浏览

    0关注

    1029博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

hadoop2.5.2学习10--MR之统计每月最高三个温度01

宝哥大数据 发布时间:2017-02-08 23:18:38 ,浏览量:0

1、hadoop 之InputFormat

在上篇文章中有一个job.setInputFormatClass(KeyValueTextInputFormat.class);,用于设置输入的格式,这个类型中可以设置分隔符。

2、splits and records

数据传到hdfs上,以block形式存在,mapreduce中, 源数据被split 分成一个个分片, 每个分片有一个mapTask处理,每个分片按照制定格式切割成若干个键值对(records),作为map的的输入。map循环处理这些records。 Split 和rRecord 都是逻辑性的概念。

首先看一下InputSplit

这里写图片描述

InputSplit是一个抽象类, 称为分片,表示每个mapper的输入数据。 InputSplit 包含一个以字节为单位的长度和一组存储位置。分片并不包含数据本身,而是指向数据的引用。存储位置供MapReduce系统使用以便将map任务尽量放在分片数据附近,而分片大小用来排序分片,便于优先处理最大的分片,从而最小化作业时间。 InputSplit的方法:

返回值方法名解释abstract longgetLength()Get the size of the split, so that the input splits can be sorted by size.SplitLocationInfo[]getLocationInfo()Gets info about which nodes the input split is stored on and how it is stored at each locationabstract String[]getLocations()Get the list of nodes by name where the data for the split would be local. InputFormat

这里写图片描述

InputFormat负责创建inputSplit, 并将它们拆分成键值对(records),

关注
打赏
1587549273
查看更多评论
立即登录/注册

微信扫码登录

0.0381s