public class BytesWritable extends Object implements WritableComparable
| Modifier and Type | Class and Description |
|---|---|
static class |
BytesWritable.Comparator
A Comparator optimized for BytesWritable.
|
| Constructor and Description |
|---|
BytesWritable()
Create a zero-size sequence.
|
BytesWritable(byte[] bytes)
Create a BytesWritable using the byte array as the initial value.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Object right_obj)
Define the sort order of the BytesWritable.
|
boolean |
equals(Object right_obj)
Are the two byte sequences equal?
|
byte[] |
get()
Get the data from the BytesWritable.
|
int |
getCapacity()
Get the capacity, which is the maximum size that could handled without
resizing the backing storage.
|
int |
getSize()
Get the current size of the buffer.
|
int |
hashCode() |
void |
readFields(DataInput in)
Reads 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)
Writes the fields of this object to
out. |
public BytesWritable()
public BytesWritable(byte[] bytes)
bytes - This array becomes the backing storage for the object.public byte[] get()
public int getSize()
public void setSize(int size)
size - The new number of bytespublic int getCapacity()
public void setCapacity(int new_cap)
new_cap - The new capacity in bytes.public void set(BytesWritable newData)
newData - the value to set this BytesWritable to.public void set(byte[] newData,
int offset,
int length)
newData - the new values to copy inoffset - the offset in newData to start atlength - the number of bytes to copypublic void readFields(DataInput in) throws IOException
Writablein. For efficiency,
implementations should attempt to re-use storage in the existing object
where possible.readFields in interface WritableIOExceptionpublic void write(DataOutput out) throws IOException
Writableout.write in interface WritableIOExceptionpublic int compareTo(Object right_obj)
compareTo in interface Comparableright_obj - The other bytes writablepublic boolean equals(Object right_obj)
Copyright © 2007, 2014, Oracle and/or its affiliates. All rights reserved.