java.lang.Comparable<BinaryComparable>, Writable, WritableComparable<BinaryComparable>@Public @Stable public class BytesWritable extends BinaryComparable implements WritableComparable<BinaryComparable>
| Modifier and Type | Class | Description |
|---|---|---|
static class |
BytesWritable.Comparator |
A Comparator optimized for BytesWritable.
|
| Constructor | Description |
|---|---|
BytesWritable() |
Create a zero-size sequence.
|
BytesWritable(byte[] bytes) |
Create a BytesWritable using the byte array as the initial value.
|
BytesWritable(byte[] bytes,
int length) |
Create a BytesWritable using the byte array as the initial value
and length as the length.
|
| Modifier and Type | Method | Description |
|---|---|---|
byte[] |
copyBytes() |
Get a copy of the bytes that is exactly the length of the data.
|
boolean |
equals(java.lang.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(java.io.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 capacity) |
Change the capacity of the backing storage.
|
void |
setSize(int size) |
Change the size of the buffer.
|
java.lang.String |
toString() |
Generate the stream of bytes as hex pairs separated by ' '.
|
void |
write(java.io.DataOutput out) |
Serialize the fields of this object to
out. |
compareTo, compareTopublic BytesWritable()
public BytesWritable(byte[] bytes)
bytes - This array becomes the backing storage for the object.public BytesWritable(byte[] bytes,
int length)
bytes - This array becomes the backing storage for the object.length - The number of bytes to use from array.public byte[] copyBytes()
getBytes() for faster access to the underlying array.public byte[] getBytes()
copyBytes()
if you need the returned array to be precisely the length of the data.getBytes in class BinaryComparable@Deprecated public byte[] get()
getBytes() instead.public int getLength()
getLength in class BinaryComparable@Deprecated public int getSize()
getLength() instead.public void setSize(int size)
size - The new number of bytespublic int getCapacity()
public void setCapacity(int capacity)
capacity - 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(java.io.DataInput in)
throws java.io.IOException
Writablein.
For efficiency, implementations should attempt to re-use storage in the existing object where possible.
readFields in interface Writablein - DataInput to deseriablize this object from.java.io.IOException - any other problem for readFields.public void write(java.io.DataOutput out)
throws java.io.IOException
Writableout.public boolean equals(java.lang.Object right_obj)
equals in class BinaryComparablepublic int hashCode()
BinaryComparablehashCode in class BinaryComparableWritableComparator.hashBytes(byte[],int)public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2008–2025 Apache Software Foundation. All rights reserved.