@InterfaceAudience.Public public class ImmutableBytesWritable extends Object implements org.apache.hadoop.io.WritableComparable<ImmutableBytesWritable>
BytesWritable
only this class is NOT resizable and DOES NOT
distinguish between the size of the sequence and the current capacity as
BytesWritable
does. Hence its comparatively 'immutable'. When
creating a new instance of this class, the underlying byte [] is not copied, just referenced. The
backing buffer is accessed when we go to serialize.Modifier and Type | Class and Description |
---|---|
static class |
ImmutableBytesWritable.Comparator
A Comparator optimized for ImmutableBytesWritable.
|
Modifier and Type | Field and Description |
---|---|
private byte[] |
bytes |
private int |
length |
private int |
offset |
Constructor and Description |
---|
ImmutableBytesWritable()
Create a zero-size sequence.
|
ImmutableBytesWritable(byte[] bytes)
Create a ImmutableBytesWritable using the byte array as the initial value.
|
ImmutableBytesWritable(byte[] bytes,
int offset,
int length)
Set the value to a given byte range
|
ImmutableBytesWritable(ImmutableBytesWritable ibw)
Set the new ImmutableBytesWritable to the contents of the passed
ibw . |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(byte[] that)
Compares the bytes in this object to the specified byte array n * @return Positive if left is
bigger than right, 0 if they are equal, and negative if left is smaller than right.
|
int |
compareTo(ImmutableBytesWritable that)
Define the sort order of the BytesWritable.
|
byte[] |
copyBytes()
Returns a copy of the bytes referred to by this writable
|
boolean |
equals(Object right_obj) |
byte[] |
get()
Get the data from the BytesWritable.
|
int |
getLength()
Returns the number of valid bytes in the buffer
|
int |
getOffset()
Return the offset into the buffer.
|
int |
getSize()
Deprecated.
since 0.98.5. Use
getLength() instead |
int |
hashCode() |
void |
readFields(DataInput in) |
void |
set(byte[] b)
Use passed bytes as backing array for this instance.
|
void |
set(byte[] b,
int offset,
int length)
Use passed bytes as backing array for this instance.
|
static byte[][] |
toArray(List<byte[]> array)
Convert a list of byte arrays into an array of byte arrays
|
String |
toString() |
void |
write(DataOutput out) |
public ImmutableBytesWritable()
public ImmutableBytesWritable(byte[] bytes)
bytes
- This array becomes the backing storage for the object.public ImmutableBytesWritable(ImmutableBytesWritable ibw)
ibw
.ibw
- the value to set this ImmutableBytesWritable to.public ImmutableBytesWritable(byte[] bytes, int offset, int length)
bytes
- the new byte range to set tooffset
- the offset in newData to start atlength
- the number of bytes in the rangepublic byte[] get()
public void set(byte[] b)
public void set(byte[] b, int offset, int length)
@Deprecated public int getSize()
getLength()
insteadgetLength()
,
HBASE-11561public int getLength()
public int getOffset()
public void readFields(DataInput in) throws IOException
readFields
in interface org.apache.hadoop.io.Writable
IOException
public void write(DataOutput out) throws IOException
write
in interface org.apache.hadoop.io.Writable
IOException
public int compareTo(ImmutableBytesWritable that)
compareTo
in interface Comparable<ImmutableBytesWritable>
that
- The other bytes writablepublic int compareTo(byte[] that)
public static byte[][] toArray(List<byte[]> array)
array
- List of byte [].public byte[] copyBytes()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.