Package org.apache.accumulo.core.data
Class Value
java.lang.Object
org.apache.accumulo.core.data.Value
- All Implemented Interfaces:
- Comparable<Object>,- org.apache.hadoop.io.Writable,- org.apache.hadoop.io.WritableComparable<Object>
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 it is comparatively 'immutable'.- 
Nested Class SummaryNested Classes
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionValue()Creates a zero-size sequence.Value(byte[] bytes) Creates a Value using a byte array as the initial value.Value(byte[] bytes, boolean copy) Creates a Value using a byte array as the initial value.Value(byte[] newData, int offset, int length) Creates a Value based on a range in a byte array.Value(CharSequence cs) Creates a value using the UTF-8 encoding of the CharSequenceValue(ByteBuffer bytes) Creates a Value using the bytes in a buffer as the initial value.Creates a new Value based on another.Value(org.apache.hadoop.io.Text text) Creates a Value using the bytes of the Text.
- 
Method SummaryModifier and TypeMethodDescriptionintcompareTo(byte[] that) Compares the bytes in this object to the specified byte arrayintDefine the sort order of the BytesWritable.booleancontentEquals(byte[] right_obj) Compares the bytes in this object to the specified byte arrayvoidcopy(byte[] b) Sets the byte data of this value.booleanbyte[]get()Gets the byte data of this value.intgetSize()Gets the size of this value.inthashCode()voidreadFields(DataInput in) voidset(byte[] b) Sets the byte data of this value.toString()voidwrite(DataOutput out) 
- 
Field Details- 
valueprotected byte[] value
 
- 
- 
Constructor Details- 
Valuepublic Value()Creates a zero-size sequence.
- 
ValueCreates a value using the UTF-8 encoding of the CharSequence- Parameters:
- cs- may not be null
- Since:
- 1.8.0
 
- 
Valuepublic Value(org.apache.hadoop.io.Text text) Creates a Value using the bytes of the Text. Makes a copy, does not use the byte array from the Text.- Parameters:
- text- may not be null
- Since:
- 1.8.0
 
- 
Valuepublic Value(byte[] bytes) Creates a Value using a byte array as the initial value. The given byte array is used directly as the backing array, so later changes made to the array reflect into the new Value.- Parameters:
- bytes- May not be null
 
- 
ValueCreates a Value using the bytes in a buffer as the initial value. Makes a defensive copy.- Parameters:
- bytes- May not be null
 
- 
Valuepublic Value(byte[] bytes, boolean copy) Creates a Value using a byte array as the initial value.- Parameters:
- bytes- may not be null
- copy- false to use the given byte array directly as the backing array, true to force a copy
 
- 
ValueCreates a new Value based on another.- Parameters:
- ibw- may not be null.
 
- 
Valuepublic Value(byte[] newData, int offset, int length) Creates a Value based on a range in a byte array. A copy of the bytes is always made.- Parameters:
- newData- source of copy, may not be null
- offset- the offset in newData to start with for value bytes
- length- the number of bytes in the value
- Throws:
- IndexOutOfBoundsException- if offset or length are invalid
 
 
- 
- 
Method Details- 
getpublic byte[] get()Gets the byte data of this value.- Returns:
- the underlying byte array directly.
 
- 
setpublic void set(byte[] b) Sets the byte data of this value. The given byte array is used directly as the backing array, so later changes made to the array reflect into this Value.- Parameters:
- b- may not be null
 
- 
copypublic void copy(byte[] b) Sets the byte data of this value. The given byte array is copied.- Parameters:
- b- may not be null
 
- 
getSizepublic int getSize()Gets the size of this value.- Returns:
- size in bytes
 
- 
readFields- Specified by:
- readFieldsin interface- org.apache.hadoop.io.Writable
- Throws:
- IOException
 
- 
write- Specified by:
- writein interface- org.apache.hadoop.io.Writable
- Throws:
- IOException
 
- 
hashCodepublic int hashCode()
- 
compareToDefine the sort order of the BytesWritable.- Specified by:
- compareToin interface- Comparable<Object>
- Parameters:
- right_obj- 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.
 
- 
compareTopublic int compareTo(byte[] that) 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
- 
contentEqualspublic boolean contentEquals(byte[] right_obj) Compares the bytes in this object to the specified byte array- Returns:
- true if the contents of this Value is equivalent to the supplied byte array
- Since:
- 2.0.0
 
- 
toString
 
-