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

来源:互联网 发布:akka java 简明教程 编辑:程序博客网 时间:2024/05/16 12:39

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 long getLength() 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 0
原创粉丝点击