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>

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 it is comparatively 'immutable'.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A Comparator optimized for Value.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected byte[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
    Creates a value using the UTF-8 encoding of the CharSequence
    Creates a Value using the bytes in a buffer as the initial value.
    Value(ByteBuffer bytes, boolean copy)
    Deprecated.
    A copy of the bytes in the buffer is always made.
    Value(Value ibw)
    Creates a new Value based on another.
    Value(org.apache.hadoop.io.Text text)
    Creates a Value using the bytes of the Text.
  • Method Summary

    Modifier and Type
    Method
    Description
    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)
    Sets the byte data of this value.
    boolean
    equals(Object right_obj)
     
    byte[]
    get()
    Gets the byte data of this value.
    int
    Gets the size of this value.
    int
     
    void
     
    void
    set(byte[] b)
    Sets the byte data of this value.
    static byte[][]
    toArray(List<byte[]> array)
    Deprecated.
    since 1.7.0; this utility method is not appropriate for the Value object
     
    void
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • value

      protected byte[] value
  • Constructor Details

    • Value

      public Value()
      Creates a zero-size sequence.
    • Value

      public Value(CharSequence cs)
      Creates a value using the UTF-8 encoding of the CharSequence
      Parameters:
      cs - may not be null
      Since:
      1.8.0
    • Value

      public 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
    • Value

      public 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
    • Value

      public Value(ByteBuffer bytes)
      Creates a Value using the bytes in a buffer as the initial value. Makes a defensive copy.
      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 - bytes of value (may not be null)
      copy - false to use the backing array of the buffer directly as the backing array, true to force a copy
    • Value

      public 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
    • Value

      public Value(Value ibw)
      Creates a new Value based on another.
      Parameters:
      ibw - may not be null.
    • Value

      public 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 valye bytes
      length - the number of bytes in the value
      Throws:
      IndexOutOfBoundsException - if offset or length are invalid
  • Method Details

    • get

      public byte[] get()
      Gets the byte data of this value.
      Returns:
      the underlying byte array directly.
    • set

      public 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
    • copy

      public void copy(byte[] b)
      Sets the byte data of this value. The given byte array is copied.
      Parameters:
      b - may not be null
    • getSize

      public int getSize()
      Gets the size of this value.
      Returns:
      size in bytes
    • 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

      @Deprecated public static byte[][] toArray(List<byte[]> array)
      Deprecated.
      since 1.7.0; this utility method is not appropriate for the Value object
      Converts a list of byte arrays to a two-dimensional array.
      Parameters:
      array - list of byte arrays
      Returns:
      two-dimensional byte array containing one given byte array per row