BytesWritable不能作为mapreduce中的key或者value,与ByteWritable不同。
1,BytesWritable.tobyte()//将ByteWritable类型的数据转换为十六进制对,并以空格分开;
2,BytesWritable.set(byte[] newData,int offset,int length);//将值设置为给定的字节范围的副本
3,BytesWritable.copyBytes()//获得对象的byte[]类型全部数据:Get a copy of the bytes that is exactly the length of the data. See getBytes() for faster access to the underlying array.
4,BytesWritable.getBytes()//**Get the data backing the BytesWritable. Please use copyBytes() if you need the returned array to be precisely the length of the data.**
Modifier and Type
Method and Description
byte[]
copyBytes():Get a copy of the bytes that is exactly the length of the data.
boolean
equals(Object right_obj):Are the two byte sequences equal?
byte[]
get():Deprecated. Use getBytes() instead.
byte[]
getBytes():Get the data backing the BytesWritable.
int
getCapacity():Get the capacity, which is the maximum size that could handled without resizing the backing storage.
int
getLength():Get the current size of the buffer.
int
getSize():Deprecated.Use getLength() instead.
int
hashCode():Return a hash of the bytes returned from {#getBytes()}.
void
readFields(DataInput in):Deserialize the fields of this object from in.
void
set(byte[] newData, int offset, int length):Set the value to a copy of the given byte range
void
set(BytesWritable newData):Set the BytesWritable to the contents of the given newData.
void
setCapacity(int new_cap):Change the capacity of the backing storage.
void
setSize(int size):Change the size of the buffer.
String
toString():Generate the stream of bytes as hex pairs separated by ’ '.
void
write(DataOutput out):Serialize the fields of this object to out.