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

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 location
abstract String[]getLocations()Get the list of nodes by name where the data for the split would be local.

InputFormat

这里写图片描述

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值