org.apache.hadoop中遇到的API记录

来源:互联网 发布:软件 评职称 编辑:程序博客网 时间:2024/05/22 12:57

一、org.apache.hadoop.ioClass Text

使用UTF8存储文本,提供串行化,并行化和在字节级别的比较文本的方法。长度类型为interger(整型),

除此之外,它还提供了不需要将字符数组转换为一个字符串就实现了字符串遍历。

同时,包括了实用性很强的串行/并行一个字符串,译码/解码一个字符串,检验一个字节数组中是否存在一个有效的UTF8码。计算编码字符串的长度


构造器:

Text()

Textbyte[]utf8

Text(Stringstring)

Text(Textutf8)


方法:都很简单。

参考:http://hadoop.apache.org/docs/r1.2.1/api/index.html?org/apache/hadoop/package-summary.html

功能:我的理解是文本(字符串)的类型。wordcount那个入门案例就使用这个类型来表示输入的文本。


二、org.apache.hadoop.mapreduce.MapContext中子类Mapper.Context

public class Mapper.Context extends MapContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT> method:继承:org.apache.hadoop.mapreduce.Class MapContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
public VALUEIN getCurrentValue()  throws IOException,InterruptedException 
public boolean nextKeyValue()    throws IOException,InterruptedException
public boolean nextKeyValue()    throws IOException,InterruptedException
public InputSplit getInputSplit()

继承:org.apache.hadoop.mapreduce.TaskInputOutputContext
public abstract boolean nextKeyValue()    throws IOException,InterruptedException
public abstract KEYIN getCurrentKey()     throws IOException,InterruptedException
public abstract VALUEIN getCurrentValue()     throws IOException,InterruptedException
public void write(KEYOUT key, VALUEOUT value)    throws IOException, InterruptedException Generate an output key/value pair.





0 0
原创粉丝点击