Package org.apache.hadoop.hbase.io
Class ImmutableBytesWritable
java.lang.Object
org.apache.hadoop.hbase.io.ImmutableBytesWritable
- All Implemented Interfaces:
Comparable<ImmutableBytesWritable>
,org.apache.hadoop.io.Writable
,org.apache.hadoop.io.WritableComparable<ImmutableBytesWritable>
@Public
public class ImmutableBytesWritable
extends Object
implements org.apache.hadoop.io.WritableComparable<ImmutableBytesWritable>
A byte sequence that is usable as a key or value. Based on
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.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A Comparator optimized for ImmutableBytesWritable. -
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate 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 rangeSet the new ImmutableBytesWritable to the contents of the passedibw
. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(byte[] that) Compares the bytes in this object to the specified byte arrayint
Define the sort order of the BytesWritable.byte[]
Returns a copy of the bytes referred to by this writableboolean
byte[]
get()
Get the data from the BytesWritable.int
Returns the number of valid bytes in the bufferint
Return the offset into the buffer.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[][]
Convert a list of byte arrays into an array of byte arraystoString()
void
write
(DataOutput out)
-
Field Details
-
bytes
-
offset
-
length
-
-
Constructor Details
-
ImmutableBytesWritable
public ImmutableBytesWritable()Create a zero-size sequence. -
ImmutableBytesWritable
Create a ImmutableBytesWritable using the byte array as the initial value.- Parameters:
bytes
- This array becomes the backing storage for the object.
-
ImmutableBytesWritable
Set the new ImmutableBytesWritable to the contents of the passedibw
.- Parameters:
ibw
- the value to set this ImmutableBytesWritable to.
-
ImmutableBytesWritable
Set the value to a given byte range- Parameters:
bytes
- the new byte range to set tooffset
- the offset in newData to start atlength
- the number of bytes in the range
-
-
Method Details
-
get
Get the data from the BytesWritable.- Returns:
- The data is only valid between offset and offset+length.
-
set
Use passed bytes as backing array for this instance. -
set
Use passed bytes as backing array for this instance. -
getLength
Returns the number of valid bytes in the buffer -
getOffset
Return the offset into the buffer. -
readFields
- Specified by:
readFields
in interfaceorg.apache.hadoop.io.Writable
- Throws:
IOException
-
write
- Specified by:
write
in interfaceorg.apache.hadoop.io.Writable
- Throws:
IOException
-
hashCode
-
compareTo
Define the sort order of the BytesWritable.- Specified by:
compareTo
in interfaceComparable<ImmutableBytesWritable>
- Parameters:
that
- The other bytes writable- Returns:
- Positive if left is bigger than right, 0 if they are equal, and negative if left is smaller than right.
-
compareTo
Compares the bytes in this object to the specified byte array- Returns:
- Positive if left is bigger than right, 0 if they are equal, and negative if left is smaller than right.
-
equals
-
toString
-
toArray
Convert a list of byte arrays into an array of byte arrays- Parameters:
array
- List of byte [].- Returns:
- Array of byte [].
-
copyBytes
Returns a copy of the bytes referred to by this writable
-