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)
           
Value(byte[] newData, int offset, int length)
          Set the value to a copy of the given byte range
Value(ByteBuffer bytes)
           
Value(ByteBuffer bytes, boolean copy)
           
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()
          Get the data from the BytesWritable.
 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 - This array becomes the backing storage for the object.

Value

public Value(ByteBuffer bytes)

Value

public Value(ByteBuffer bytes,
             boolean copy)

Value

public Value(byte[] bytes,
             boolean copy)

Value

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

Parameters:
ibw - the value to set this Value to.

Value

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

Parameters:
newData - the new values to copy in
offset - the offset in newData to start at
length - the number of bytes to copy
Method Detail

get

public byte[] get()
Get the data from the BytesWritable.

Returns:
The data is only valid between 0 and getSize() - 1.

set

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

copy

public void copy(byte[] b)
Parameters:
b - copy bytes

getSize

public int getSize()
Returns:
the current size of the 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 © 2013 Apache Accumulo Project. All Rights Reserved.