public class BytesWritable extends BinaryComparable implements WritableComparable<BinaryComparable>
Writable 和 WritableComparable 的实现.| Modifier and Type | Class and Description |
|---|---|
static class |
BytesWritable.Comparator
BytesWritable 对象的
WritableComparator 自然顺序实现(升序). |
| Constructor and Description |
|---|
BytesWritable()
默认构造 空 byte[] 的 BytesWritable.
|
BytesWritable(byte[] bytes)
构造值为给定 byte 数组的 BytesWritable.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object right_obj)
判断两个 BytesWritable 内容是否相同.
|
byte[] |
getBytes()
返回此 byte 数组的内容
|
int |
getCapacity()
获取字节数组容量.
|
int |
getLength()
返回内容长度.
|
int |
hashCode()
计算二进制内容的哈希值.
|
void |
readFields(DataInput in)
从指定的
DataInput in 反序列化. |
void |
set(byte[] newData,
int offset,
int length)
更新数据内容为给定字节数组中的数据.
|
void |
set(BytesWritable newData)
更新数据内容为给定 BytesWritable 的数据.
|
void |
setCapacity(int new_cap)
更该字节数组容量
|
void |
setSize(int size)
更改数组内容长度.
|
String |
toString()
输出数据的十六进制内容.
|
void |
write(DataOutput out)
序列化到指定的
DataOutput out. |
compareTo, compareTocompareTopublic BytesWritable()
public BytesWritable(byte[] bytes)
bytes - public byte[] getBytes()
getBytes in class BinaryComparablepublic int getLength()
getLength in class BinaryComparablepublic void setSize(int size)
注意:更改后,有效数据内容只由bytes[0, 更改前 getLength() -1], 新增加的数组内容是未定义的,数组的容量按需增加。
size - 新内容长度public int getCapacity()
public void setCapacity(int new_cap)
new_cap - 新容量大小public void set(BytesWritable newData)
等价于:set(newData.getBytes(), 0, newData.getLength())
newData - 新数据public void set(byte[] newData,
int offset,
int length)
newData - 源数组offset - 数据内容在 newData 中的偏移量length - 数据内容长度public void readFields(DataInput in) throws IOException
WritableDataInput in 反序列化.readFields in interface WritableIOExceptionpublic void write(DataOutput out) throws IOException
WritableDataOutput out.write in interface WritableIOExceptionpublic int hashCode()
BinaryComparable直接使用 {@link WritableComparator#hashBytes(byte[], int)进行计算
hashCode in class BinaryComparablepublic boolean equals(Object right_obj)
equals in class BinaryComparableright_obj - Copyright © 2023 Alibaba Cloud Computing. All rights reserved.