Class ByteArrayAccessor

java.lang.Object
org.apache.cassandra.db.marshal.ByteArrayAccessor
All Implemented Interfaces:
ValueAccessor<byte[]>

public class ByteArrayAccessor extends Object implements ValueAccessor<byte[]>
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.cassandra.db.marshal.ValueAccessor

    ValueAccessor.ObjectFactory<V>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final ValueAccessor.ObjectFactory<byte[]>
     
    static final ValueAccessor<byte[]>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    allocate(int size)
    Allocate and return a instance of bytes on the heap.
    <V2> int
    compare(byte[] left, V2 right, ValueAccessor<V2> accessorR)
    lexicographically compare to
    int
    compareByteArrayTo(byte[] left, byte[] right)
    compare a byte array on the left with a on the right}
    int
    compareByteBufferTo(ByteBuffer left, byte[] right)
    compare a byte buffer on the left with a on the right}
    <V2> byte[]
    convert(V2 src, ValueAccessor<V2> accessor)
    Convert the data in to and the returned value may share a common byte array instance, so caller should assume that modifying the returned value will also modify the contents of
    int
    copyByteArrayTo(byte[] src, int srcOffset, byte[] dst, int dstOffset, int size)
    copies a byte array into this accessors value.
    int
    copyByteBufferTo(ByteBuffer src, int srcOffset, byte[] dst, int dstOffset, int size)
    copies a byte buffer into this accessors value.
    <V2> int
    copyTo(byte[] src, int srcOffset, V2 dst, ValueAccessor<V2> dstAccessor, int dstOffset, int size)
    copy the bytes from the value, starting at the offset into the value, starting at the offset , using the accessor
    byte[][]
    createArray(int length)
    allocate an instance of the accessors backing type
    void
    digest(byte[] value, int offset, int size, Digest digest)
    updates with bytes from the contents of starting at offset
    byte[]
    return a value with a length of 0
    returns the ValueAccessor.ObjectFactory for the backing type
    byte
    getByte(byte[] value, int offset)
    returns a byte from offset
    double
    getDouble(byte[] value, int offset)
     
    float
    getFloat(byte[] value, int offset)
     
    int
    getInt(byte[] value, int offset)
    returns an int from offset
    long
    getLong(byte[] value, int offset)
    returns a long from offset
    short
    getShort(byte[] value, int offset)
    returns a short from offset
    int
    getUnsignedShort(byte[] value, int offset)
    returns an unsigned short from offset
    int
    putByte(byte[] dst, int offset, byte value)
    writes the byte value to at offset
    int
    putFloat(byte[] dst, int offset, float value)
    writes the float value to at offset
    int
    putInt(byte[] dst, int offset, int value)
    writes the int value to at offset
    int
    putLong(byte[] dst, int offset, long value)
    writes the long value to at offset
    int
    putShort(byte[] dst, int offset, short value)
    writes the short value to at offset
    byte[]
    read(DataInputPlus in, int length)
    Reads a value of bytes from
    int
    size(byte[] value)
     
    byte[]
    slice(byte[] input, int offset, int length)
    Returns a value with the contents of from to .
    byte[]
    toArray(byte[] value)
    returns a byte[] with the contents of Depending on the accessor implementation, this method may: * allocate a new byte[] object and copy data into it * return the value, if the backing type is byte[]
    byte[]
    toArray(byte[] value, int offset, int length)
    returns a byte[] with bytes copied from the contents of starting at offset .
    toBallot(byte[] value)
    returns a TimeUUID from offset 0
    toBuffer(byte[] value)
    returns a ByteBuffer with the contents of Depending on the accessor implementation, this method may: * allocate a new ByteBuffer and copy data into it * return the value, if the backing type is a bytebuffer
    byte
    toByte(byte[] value)
    returns a byte from offset 0
    double
    toDouble(byte[] value)
    returns a double from offset 0
    float
    toFloat(byte[] value)
    returns a float from offset 0
    float[]
    toFloatArray(byte[] value, int dimension)
    returns a float[] from offset 0
    toHex(byte[] value)
     
    int
    toInt(byte[] value)
    returns an int from offset 0
    long
    toLong(byte[] value)
    returns a long from offset 0
    short
    toShort(byte[] value)
    returns a short from offset 0
    toString(byte[] value, Charset charset)
     
    toTimeUUID(byte[] value)
    returns a TimeUUID from offset 0
    toUUID(byte[] value)
    returns a UUID from offset 0
    byte[]
    valueOf(boolean v)
    return a value with the bytes from
    byte[]
    valueOf(byte v)
    return a value with the bytes from
    byte[]
    valueOf(byte[] bytes)
    return a value containing the Caller should assume that modifying the returned value will also modify the contents of
    byte[]
    valueOf(double v)
    return a value with the bytes from
    byte[]
    valueOf(float v)
    return a value with the bytes from
    byte[]
    valueOf(int v)
    return a value with the bytes from
    byte[]
    valueOf(long v)
    return a value with the bytes from
    byte[]
    valueOf(short v)
    return a value with the bytes from
    byte[]
    valueOf(String s, Charset charset)
    return a value containing the bytes for the given string and charset
    byte[]
    return a value containing the and the returned value may share a common byte array instance, so caller should assume that modifying the returned value will also modify the contents of
    byte[]
    return a value with the bytes from
    void
    write(byte[] value, ByteBuffer out)
    Write the contents of the given value into the ByteBuffer
    void
    write(byte[] value, DataOutputPlus out)
    Write the contents of the given value into the a DataOutputPlus

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • size

      public int size(byte[] value)
      Specified by:
      size in interface ValueAccessor<byte[]>
      Returns:
      the size of the given value
    • createArray

      public byte[][] createArray(int length)
      Description copied from interface: ValueAccessor
      allocate an instance of the accessors backing type
      Specified by:
      createArray in interface ValueAccessor<byte[]>
      Parameters:
      length - size of backing typ to allocate
    • write

      public void write(byte[] value, DataOutputPlus out) throws IOException
      Description copied from interface: ValueAccessor
      Write the contents of the given value into the a DataOutputPlus
      Specified by:
      write in interface ValueAccessor<byte[]>
      Throws:
      IOException
    • write

      public void write(byte[] value, ByteBuffer out)
      Description copied from interface: ValueAccessor
      Write the contents of the given value into the ByteBuffer
      Specified by:
      write in interface ValueAccessor<byte[]>
    • copyTo

      public <V2> int copyTo(byte[] src, int srcOffset, V2 dst, ValueAccessor<V2> dstAccessor, int dstOffset, int size)
      Description copied from interface: ValueAccessor
      copy the bytes from the value, starting at the offset into the value, starting at the offset , using the accessor
      Specified by:
      copyTo in interface ValueAccessor<byte[]>
      Type Parameters:
      V2 - the destination value type
      Returns:
      the number of bytes copied ()
    • copyByteArrayTo

      public int copyByteArrayTo(byte[] src, int srcOffset, byte[] dst, int dstOffset, int size)
      Description copied from interface: ValueAccessor
      copies a byte array into this accessors value.
      Specified by:
      copyByteArrayTo in interface ValueAccessor<byte[]>
    • copyByteBufferTo

      public int copyByteBufferTo(ByteBuffer src, int srcOffset, byte[] dst, int dstOffset, int size)
      Description copied from interface: ValueAccessor
      copies a byte buffer into this accessors value.
      Specified by:
      copyByteBufferTo in interface ValueAccessor<byte[]>
    • digest

      public void digest(byte[] value, int offset, int size, Digest digest)
      Description copied from interface: ValueAccessor
      updates with bytes from the contents of starting at offset
      Specified by:
      digest in interface ValueAccessor<byte[]>
    • read

      public byte[] read(DataInputPlus in, int length) throws IOException
      Description copied from interface: ValueAccessor
      Reads a value of bytes from
      Specified by:
      read in interface ValueAccessor<byte[]>
      Throws:
      IOException
    • slice

      public byte[] slice(byte[] input, int offset, int length)
      Description copied from interface: ValueAccessor
      Returns a value with the contents of from to . Depending on the accessor implementation, this method may: * allocate a new object of , and copy data into it * return a view of where changes to one will be reflected in the other
      Specified by:
      slice in interface ValueAccessor<byte[]>
    • compare

      public <V2> int compare(byte[] left, V2 right, ValueAccessor<V2> accessorR)
      Description copied from interface: ValueAccessor
      lexicographically compare to
      Specified by:
      compare in interface ValueAccessor<byte[]>
      Type Parameters:
      V2 - backing type of
    • compareByteArrayTo

      public int compareByteArrayTo(byte[] left, byte[] right)
      Description copied from interface: ValueAccessor
      compare a byte array on the left with a on the right}
      Specified by:
      compareByteArrayTo in interface ValueAccessor<byte[]>
    • compareByteBufferTo

      public int compareByteBufferTo(ByteBuffer left, byte[] right)
      Description copied from interface: ValueAccessor
      compare a byte buffer on the left with a on the right}
      Specified by:
      compareByteBufferTo in interface ValueAccessor<byte[]>
    • toBuffer

      public ByteBuffer toBuffer(byte[] value)
      Description copied from interface: ValueAccessor
      returns a ByteBuffer with the contents of Depending on the accessor implementation, this method may: * allocate a new ByteBuffer and copy data into it * return the value, if the backing type is a bytebuffer
      Specified by:
      toBuffer in interface ValueAccessor<byte[]>
    • toArray

      public byte[] toArray(byte[] value)
      Description copied from interface: ValueAccessor
      returns a byte[] with the contents of Depending on the accessor implementation, this method may: * allocate a new byte[] object and copy data into it * return the value, if the backing type is byte[]
      Specified by:
      toArray in interface ValueAccessor<byte[]>
    • toArray

      public byte[] toArray(byte[] value, int offset, int length)
      Description copied from interface: ValueAccessor
      returns a byte[] with bytes copied from the contents of starting at offset . Depending on the accessor implementation, this method may: * allocate a new byte[] object and copy data into it * return the value, if the backing type is byte[], offset is 0 and == size(value)
      Specified by:
      toArray in interface ValueAccessor<byte[]>
    • toString

      public String toString(byte[] value, Charset charset) throws CharacterCodingException
      Specified by:
      toString in interface ValueAccessor<byte[]>
      Throws:
      CharacterCodingException
    • toHex

      public String toHex(byte[] value)
      Specified by:
      toHex in interface ValueAccessor<byte[]>
    • toByte

      public byte toByte(byte[] value)
      Description copied from interface: ValueAccessor
      returns a byte from offset 0
      Specified by:
      toByte in interface ValueAccessor<byte[]>
    • getByte

      public byte getByte(byte[] value, int offset)
      Description copied from interface: ValueAccessor
      returns a byte from offset
      Specified by:
      getByte in interface ValueAccessor<byte[]>
    • toShort

      public short toShort(byte[] value)
      Description copied from interface: ValueAccessor
      returns a short from offset 0
      Specified by:
      toShort in interface ValueAccessor<byte[]>
    • getShort

      public short getShort(byte[] value, int offset)
      Description copied from interface: ValueAccessor
      returns a short from offset
      Specified by:
      getShort in interface ValueAccessor<byte[]>
    • getUnsignedShort

      public int getUnsignedShort(byte[] value, int offset)
      Description copied from interface: ValueAccessor
      returns an unsigned short from offset
      Specified by:
      getUnsignedShort in interface ValueAccessor<byte[]>
    • toInt

      public int toInt(byte[] value)
      Description copied from interface: ValueAccessor
      returns an int from offset 0
      Specified by:
      toInt in interface ValueAccessor<byte[]>
    • getInt

      public int getInt(byte[] value, int offset)
      Description copied from interface: ValueAccessor
      returns an int from offset
      Specified by:
      getInt in interface ValueAccessor<byte[]>
    • getFloat

      public float getFloat(byte[] value, int offset)
      Specified by:
      getFloat in interface ValueAccessor<byte[]>
    • getDouble

      public double getDouble(byte[] value, int offset)
      Specified by:
      getDouble in interface ValueAccessor<byte[]>
    • toLong

      public long toLong(byte[] value)
      Description copied from interface: ValueAccessor
      returns a long from offset 0
      Specified by:
      toLong in interface ValueAccessor<byte[]>
    • getLong

      public long getLong(byte[] value, int offset)
      Description copied from interface: ValueAccessor
      returns a long from offset
      Specified by:
      getLong in interface ValueAccessor<byte[]>
    • toFloat

      public float toFloat(byte[] value)
      Description copied from interface: ValueAccessor
      returns a float from offset 0
      Specified by:
      toFloat in interface ValueAccessor<byte[]>
    • toFloatArray

      public float[] toFloatArray(byte[] value, int dimension)
      Description copied from interface: ValueAccessor
      returns a float[] from offset 0
      Specified by:
      toFloatArray in interface ValueAccessor<byte[]>
    • toDouble

      public double toDouble(byte[] value)
      Description copied from interface: ValueAccessor
      returns a double from offset 0
      Specified by:
      toDouble in interface ValueAccessor<byte[]>
    • toUUID

      public UUID toUUID(byte[] value)
      Description copied from interface: ValueAccessor
      returns a UUID from offset 0
      Specified by:
      toUUID in interface ValueAccessor<byte[]>
    • toTimeUUID

      public TimeUUID toTimeUUID(byte[] value)
      Description copied from interface: ValueAccessor
      returns a TimeUUID from offset 0
      Specified by:
      toTimeUUID in interface ValueAccessor<byte[]>
    • toBallot

      public Ballot toBallot(byte[] value)
      Description copied from interface: ValueAccessor
      returns a TimeUUID from offset 0
      Specified by:
      toBallot in interface ValueAccessor<byte[]>
    • putByte

      public int putByte(byte[] dst, int offset, byte value)
      Description copied from interface: ValueAccessor
      writes the byte value to at offset
      Specified by:
      putByte in interface ValueAccessor<byte[]>
      Returns:
      the number of bytes written to
    • putShort

      public int putShort(byte[] dst, int offset, short value)
      Description copied from interface: ValueAccessor
      writes the short value to at offset
      Specified by:
      putShort in interface ValueAccessor<byte[]>
      Returns:
      the number of bytes written to
    • putInt

      public int putInt(byte[] dst, int offset, int value)
      Description copied from interface: ValueAccessor
      writes the int value to at offset
      Specified by:
      putInt in interface ValueAccessor<byte[]>
      Returns:
      the number of bytes written to
    • putLong

      public int putLong(byte[] dst, int offset, long value)
      Description copied from interface: ValueAccessor
      writes the long value to at offset
      Specified by:
      putLong in interface ValueAccessor<byte[]>
      Returns:
      the number of bytes written to
    • putFloat

      public int putFloat(byte[] dst, int offset, float value)
      Description copied from interface: ValueAccessor
      writes the float value to at offset
      Specified by:
      putFloat in interface ValueAccessor<byte[]>
      Returns:
      the number of bytes written to
    • empty

      public byte[] empty()
      Description copied from interface: ValueAccessor
      return a value with a length of 0
      Specified by:
      empty in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(byte[] bytes)
      Description copied from interface: ValueAccessor
      return a value containing the Caller should assume that modifying the returned value will also modify the contents of
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(ByteBuffer bytes)
      Description copied from interface: ValueAccessor
      return a value containing the and the returned value may share a common byte array instance, so caller should assume that modifying the returned value will also modify the contents of
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(String s, Charset charset)
      Description copied from interface: ValueAccessor
      return a value containing the bytes for the given string and charset
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(UUID v)
      Description copied from interface: ValueAccessor
      return a value with the bytes from
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(boolean v)
      Description copied from interface: ValueAccessor
      return a value with the bytes from
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(byte v)
      Description copied from interface: ValueAccessor
      return a value with the bytes from
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(short v)
      Description copied from interface: ValueAccessor
      return a value with the bytes from
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(int v)
      Description copied from interface: ValueAccessor
      return a value with the bytes from
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(long v)
      Description copied from interface: ValueAccessor
      return a value with the bytes from
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(float v)
      Description copied from interface: ValueAccessor
      return a value with the bytes from
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • valueOf

      public byte[] valueOf(double v)
      Description copied from interface: ValueAccessor
      return a value with the bytes from
      Specified by:
      valueOf in interface ValueAccessor<byte[]>
    • convert

      public <V2> byte[] convert(V2 src, ValueAccessor<V2> accessor)
      Description copied from interface: ValueAccessor
      Convert the data in to and the returned value may share a common byte array instance, so caller should assume that modifying the returned value will also modify the contents of
      Specified by:
      convert in interface ValueAccessor<byte[]>
    • allocate

      public byte[] allocate(int size)
      Description copied from interface: ValueAccessor
      Allocate and return a instance of bytes on the heap.
      Specified by:
      allocate in interface ValueAccessor<byte[]>
    • factory

      public ValueAccessor.ObjectFactory<byte[]> factory()
      Description copied from interface: ValueAccessor
      returns the ValueAccessor.ObjectFactory for the backing type
      Specified by:
      factory in interface ValueAccessor<byte[]>