public class Tuple extends Object implements WritableComparable<Object>
Writable 对象的有序集.
Tuple 将 Writable 对象保存在一个 List 中,每个 Writable 对象都是一个
Tuple域 (Field)。
Tuple 的方法与 Record 有些类似,不同之处:
Record 由 MapReduce 框架创建。
TupleReaderWriter| Modifier and Type | Field and Description |
|---|---|
static char |
DELIM
toDelimitedString() 使用的默认列分隔符:CTRL + A |
static String |
NULLINDICATOR
toDelimitedString() 使用的默认NULL指示符: \N |
| Constructor and Description |
|---|
Tuple()
默认构造函数
|
Tuple(int size)
构造一个指定大小的 Tuple.
|
Tuple(List<Writable> vals,
boolean reference)
给定
List 构造 Tuple. |
Tuple(Tuple tuple,
boolean reference)
复制另一个 Tuple 的数据
|
Tuple(Writable[] fields)
给定
Writable 数组构造 Tuple. |
| Modifier and Type | Method and Description |
|---|---|
void |
append(Collection<Writable> vals)
将集合中的field添加到Tuple
|
void |
append(Writable val)
Append a field to a tuple.
|
void |
append(Writable[] vals)
将数组中的field添加到Tuple
|
void |
clear()
清空Tuple中的所有field
|
Tuple |
clone()
生成当前Tuple的拷贝
|
int |
compareTo(Object other)
比较两个Tuple对象,依次比较Tuple中的各个field
|
boolean |
equals(Object other)
比较两个Tuple对象是否相等
|
Writable |
get(int fieldNum)
Get the value in a given field.
|
List<Writable> |
getAll()
Get all of the fields in the tuple as a list.
|
int |
hashCode()
获取Tuple对象的hash直
|
void |
readFields(DataInput in)
从指定的输入流中反序列化出Tuple对象
|
void |
set(int fieldNum,
Writable val)
Set the value in a given field.
|
void |
set(List<Writable> vals)
设置Tuple中存放的
Writable对象,复用vals |
void |
set(Writable[] vals)
设置Tuple中存放的
Writable对象 |
int |
size()
Find the size of the tuple.
|
Writable[] |
toArray()
得到Tuple的数组形式
|
String |
toDelimitedString()
将Tuple中的所有field使用
DELIM连接起来,field为null时使用NULLINDICATOR代替. |
String |
toDelimitedString(char delim)
将Tuple中的所有field使用指定的delim连接起来,field为null时使用
NULLINDICATOR代替. |
String |
toDelimitedString(char delim,
String nullIndicator)
将Tuple中的所有field使用指定的delim连接起来,field为null时使用指定的nullIndicator代替.
|
String |
toString()
获取Tuple的字符串表示形式
|
void |
write(DataOutput out)
将Tuple对象序列化至指定的输出流中
|
public static final char DELIM
toDelimitedString() 使用的默认列分隔符:CTRL + Apublic static final String NULLINDICATOR
toDelimitedString() 使用的默认NULL指示符: \Npublic Tuple()
public Tuple(int size)
size - Writable 对象个数public Tuple(List<Writable> vals, boolean reference)
List 构造 Tuple.vals - reference - 如果为true,新创建的 Tuple 直接使用 vals 保存 Fields,否则,会创建一个新的 List.public int size()
public Writable get(int fieldNum)
fieldNum - Number of the field to get the value for.IOException - if the field number is greater than or equal to the number of
fields in the tuple.public List<Writable> getAll()
public void set(int fieldNum,
Writable val)
throws IOException
fieldNum - Number of the field to set the value for.val - Writable to put in the indicated field.IOException - if the field number is greater than or equal to the number of
fields in the tuple.public void set(List<Writable> vals)
Writable对象,复用valsvals - 待设置的Writable对象public void append(Writable val)
val - Object to append to the tuple.public void append(Writable[] vals)
vals - 待添加的fieldpublic void append(Collection<Writable> vals)
vals - 待添加的fieldpublic void clear()
public String toDelimitedString()
DELIM连接起来,field为null时使用NULLINDICATOR代替.public String toDelimitedString(char delim)
NULLINDICATOR代替.delim - 指定的分割符public String toDelimitedString(char delim, String nullIndicator)
delim - 指定的分割符nullIndicator - 指定的null替代字符串public int compareTo(Object other)
compareTo in interface Comparable<Object>public void write(DataOutput out) throws IOException
write in interface WritableIOExceptionpublic void readFields(DataInput in) throws IOException
readFields in interface WritableIOExceptionCopyright © 2023 Alibaba Cloud Computing. All rights reserved.