org.apache.accumulo.core.data
Class Value

java.lang.Object
  extended by org.apache.accumulo.core.data.Value
All Implemented Interfaces:
Comparable<Object>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<Object>

public class Value
extends Object
implements 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 its comparatively 'immutable'.


Nested Class Summary
static class Value.Comparator
          A Comparator optimized for Value.
 
Field Summary
protected  byte[] value
           
 
Constructor Summary
Value()
          Create a zero-size sequence.
Value(byte[] bytes)
          Create a Value using the byte array as the initial value.
Value(byte[] bytes, boolean copy)
          Create a Value based on the given bytes.
Value(byte[] newData, int offset, int length)
          Set the value to a copy of the given byte range
Value(ByteBuffer bytes)
          Create a Value using a copy of the ByteBuffer's content.
Value(ByteBuffer bytes, boolean copy)
          Deprecated. A copy of the bytes in the buffer is always made. Use Value(ByteBuffer) instead.
Value(Value ibw)
          Set the new Value to a copy of the contents of the passed ibw.
 
Method Summary
 int compareTo(byte[] that)
          Compares the bytes in this object to the specified byte array
 int compareTo(Object right_obj)
          Define the sort order of the BytesWritable.
 void copy(byte[] b)
           
 boolean equals(Object right_obj)
           
 byte[] get()
           
 int getSize()
           
 int hashCode()
           
 void readFields(DataInput in)
           
 void set(byte[] b)
           
static byte[][] toArray(List<byte[]> array)
           
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected byte[] value
Constructor Detail

Value

public Value()
Create a zero-size sequence.


Value

public Value(byte[] bytes)
Create a Value using the byte array as the initial value.

Parameters:
bytes - May not be null

Value

public Value(ByteBuffer bytes)
Create a Value using a copy of the ByteBuffer's content.

Parameters:
bytes - May not be null

Value

@Deprecated
public Value(ByteBuffer bytes,
                        boolean copy)
Deprecated. A copy of the bytes in the buffer is always made. Use Value(ByteBuffer) instead.

Parameters:
bytes - may not be null

Value

public Value(byte[] bytes,
             boolean copy)
Create a Value based on the given bytes.

Parameters:
bytes - may not be null
copy - signal if Value must make its own copy of bytes, or if it can use the array directly.

Value

public Value(Value ibw)
Set the new Value to a copy of the contents of the passed ibw.

Parameters:
ibw - may not be null.

Value

public Value(byte[] newData,
             int offset,
             int length)
Set the value to a copy of the given byte range

Parameters:
newData - source of copy, may not be null
offset - the offset in newData to start at
length - the number of bytes to copy
Method Detail

get

public byte[] get()
Returns:
the underlying byte array directly.

set

public void set(byte[] b)
Parameters:
b - Use passed bytes as backing array for this instance, may not be null.

copy

public void copy(byte[] b)
Parameters:
b - copy the given byte array, may not be null.

getSize

public int getSize()
Returns:
the current size of the underlying buffer.

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(Object right_obj)
Define the sort order of the BytesWritable.

Specified by:
compareTo in 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.

compareTo

public 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

public boolean equals(Object right_obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

toArray

public static byte[][] toArray(List<byte[]> array)


Copyright © 2015 Apache Accumulo Project. All rights reserved.