Package org.apache.cassandra.db.marshal
Class ByteArrayAccessor
java.lang.Object
org.apache.cassandra.db.marshal.ByteArrayAccessor
- All Implemented Interfaces:
ValueAccessor<byte[]>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.db.marshal.ValueAccessor
ValueAccessor.ObjectFactory<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ValueAccessor.ObjectFactory<byte[]>static final ValueAccessor<byte[]> -
Method Summary
Modifier and TypeMethodDescriptionbyte[]allocate(int size) Allocate and return a instance of bytes on the heap.<V2> intcompare(byte[] left, V2 right, ValueAccessor<V2> accessorR) lexicographically compare tointcompareByteArrayTo(byte[] left, byte[] right) compare a byte array on the left with a on the right}intcompareByteBufferTo(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 ofintcopyByteArrayTo(byte[] src, int srcOffset, byte[] dst, int dstOffset, int size) copies a byte array into this accessors value.intcopyByteBufferTo(ByteBuffer src, int srcOffset, byte[] dst, int dstOffset, int size) copies a byte buffer into this accessors value.<V2> intcopyTo(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 accessorbyte[][]createArray(int length) allocate an instance of the accessors backing typevoidupdates with bytes from the contents of starting at offsetbyte[]empty()return a value with a length of 0ValueAccessor.ObjectFactory<byte[]>factory()returns theValueAccessor.ObjectFactoryfor the backing typebytegetByte(byte[] value, int offset) returns a byte from offsetdoublegetDouble(byte[] value, int offset) floatgetFloat(byte[] value, int offset) intgetInt(byte[] value, int offset) returns an int from offsetlonggetLong(byte[] value, int offset) returns a long from offsetshortgetShort(byte[] value, int offset) returns a short from offsetintgetUnsignedShort(byte[] value, int offset) returns an unsigned short from offsetintputByte(byte[] dst, int offset, byte value) writes the byte value to at offsetintputFloat(byte[] dst, int offset, float value) writes the float value to at offsetintputInt(byte[] dst, int offset, int value) writes the int value to at offsetintputLong(byte[] dst, int offset, long value) writes the long value to at offsetintputShort(byte[] dst, int offset, short value) writes the short value to at offsetbyte[]read(DataInputPlus in, int length) Reads a value of bytes fromintsize(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 0toBuffer(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 bytebufferbytetoByte(byte[] value) returns a byte from offset 0doubletoDouble(byte[] value) returns a double from offset 0floattoFloat(byte[] value) returns a float from offset 0float[]toFloatArray(byte[] value, int dimension) returns a float[] from offset 0toHex(byte[] value) inttoInt(byte[] value) returns an int from offset 0longtoLong(byte[] value) returns a long from offset 0shorttoShort(byte[] value) returns a short from offset 0toTimeUUID(byte[] value) returns a TimeUUID from offset 0toUUID(byte[] value) returns a UUID from offset 0byte[]valueOf(boolean v) return a value with the bytes frombyte[]valueOf(byte v) return a value with the bytes frombyte[]valueOf(byte[] bytes) return a value containing the Caller should assume that modifying the returned value will also modify the contents ofbyte[]valueOf(double v) return a value with the bytes frombyte[]valueOf(float v) return a value with the bytes frombyte[]valueOf(int v) return a value with the bytes frombyte[]valueOf(long v) return a value with the bytes frombyte[]valueOf(short v) return a value with the bytes frombyte[]return a value containing the bytes for the given string and charsetbyte[]valueOf(ByteBuffer bytes) 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 ofbyte[]return a value with the bytes fromvoidwrite(byte[] value, ByteBuffer out) Write the contents of the given value into the ByteBuffervoidwrite(byte[] value, DataOutputPlus out) Write the contents of the given value into the a DataOutputPlusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cassandra.db.marshal.ValueAccessor
digest, getBoolean, getUnsignedVInt, getUnsignedVInt32, getVInt, getVInt32, hashCode, isEmpty, isEmptyFromOffset, putBytes, putBytes, putUnsignedVInt, putUnsignedVInt32, putVInt, putVInt32, remaining, sizeFromOffset, sizeWithShortLength, sizeWithVIntLength, sliceWithShortLength, toString, writeWithVIntLength
-
Field Details
-
instance
-
factory
-
-
Method Details
-
size
public int size(byte[] value) - Specified by:
sizein interfaceValueAccessor<byte[]>- Returns:
- the size of the given value
-
createArray
public byte[][] createArray(int length) Description copied from interface:ValueAccessorallocate an instance of the accessors backing type- Specified by:
createArrayin interfaceValueAccessor<byte[]>- Parameters:
length- size of backing typ to allocate
-
write
Description copied from interface:ValueAccessorWrite the contents of the given value into the a DataOutputPlus- Specified by:
writein interfaceValueAccessor<byte[]>- Throws:
IOException
-
write
Description copied from interface:ValueAccessorWrite the contents of the given value into the ByteBuffer- Specified by:
writein interfaceValueAccessor<byte[]>
-
copyTo
public <V2> int copyTo(byte[] src, int srcOffset, V2 dst, ValueAccessor<V2> dstAccessor, int dstOffset, int size) Description copied from interface:ValueAccessorcopy the bytes from the value, starting at the offset into the value, starting at the offset , using the accessor- Specified by:
copyToin interfaceValueAccessor<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:ValueAccessorcopies a byte array into this accessors value.- Specified by:
copyByteArrayToin interfaceValueAccessor<byte[]>
-
copyByteBufferTo
Description copied from interface:ValueAccessorcopies a byte buffer into this accessors value.- Specified by:
copyByteBufferToin interfaceValueAccessor<byte[]>
-
digest
Description copied from interface:ValueAccessorupdates with bytes from the contents of starting at offset- Specified by:
digestin interfaceValueAccessor<byte[]>
-
read
Description copied from interface:ValueAccessorReads a value of bytes from- Specified by:
readin interfaceValueAccessor<byte[]>- Throws:
IOException
-
slice
public byte[] slice(byte[] input, int offset, int length) Description copied from interface:ValueAccessorReturns 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:
slicein interfaceValueAccessor<byte[]>
-
compare
Description copied from interface:ValueAccessorlexicographically compare to- Specified by:
comparein interfaceValueAccessor<byte[]>- Type Parameters:
V2- backing type of
-
compareByteArrayTo
public int compareByteArrayTo(byte[] left, byte[] right) Description copied from interface:ValueAccessorcompare a byte array on the left with a on the right}- Specified by:
compareByteArrayToin interfaceValueAccessor<byte[]>
-
compareByteBufferTo
Description copied from interface:ValueAccessorcompare a byte buffer on the left with a on the right}- Specified by:
compareByteBufferToin interfaceValueAccessor<byte[]>
-
toBuffer
Description copied from interface:ValueAccessorreturns 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:
toBufferin interfaceValueAccessor<byte[]>
-
toArray
public byte[] toArray(byte[] value) Description copied from interface:ValueAccessorreturns 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:
toArrayin interfaceValueAccessor<byte[]>
-
toArray
public byte[] toArray(byte[] value, int offset, int length) Description copied from interface:ValueAccessorreturns 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:
toArrayin interfaceValueAccessor<byte[]>
-
toString
- Specified by:
toStringin interfaceValueAccessor<byte[]>- Throws:
CharacterCodingException
-
toHex
- Specified by:
toHexin interfaceValueAccessor<byte[]>
-
toByte
public byte toByte(byte[] value) Description copied from interface:ValueAccessorreturns a byte from offset 0- Specified by:
toBytein interfaceValueAccessor<byte[]>
-
getByte
public byte getByte(byte[] value, int offset) Description copied from interface:ValueAccessorreturns a byte from offset- Specified by:
getBytein interfaceValueAccessor<byte[]>
-
toShort
public short toShort(byte[] value) Description copied from interface:ValueAccessorreturns a short from offset 0- Specified by:
toShortin interfaceValueAccessor<byte[]>
-
getShort
public short getShort(byte[] value, int offset) Description copied from interface:ValueAccessorreturns a short from offset- Specified by:
getShortin interfaceValueAccessor<byte[]>
-
getUnsignedShort
public int getUnsignedShort(byte[] value, int offset) Description copied from interface:ValueAccessorreturns an unsigned short from offset- Specified by:
getUnsignedShortin interfaceValueAccessor<byte[]>
-
toInt
public int toInt(byte[] value) Description copied from interface:ValueAccessorreturns an int from offset 0- Specified by:
toIntin interfaceValueAccessor<byte[]>
-
getInt
public int getInt(byte[] value, int offset) Description copied from interface:ValueAccessorreturns an int from offset- Specified by:
getIntin interfaceValueAccessor<byte[]>
-
getFloat
public float getFloat(byte[] value, int offset) - Specified by:
getFloatin interfaceValueAccessor<byte[]>
-
getDouble
public double getDouble(byte[] value, int offset) - Specified by:
getDoublein interfaceValueAccessor<byte[]>
-
toLong
public long toLong(byte[] value) Description copied from interface:ValueAccessorreturns a long from offset 0- Specified by:
toLongin interfaceValueAccessor<byte[]>
-
getLong
public long getLong(byte[] value, int offset) Description copied from interface:ValueAccessorreturns a long from offset- Specified by:
getLongin interfaceValueAccessor<byte[]>
-
toFloat
public float toFloat(byte[] value) Description copied from interface:ValueAccessorreturns a float from offset 0- Specified by:
toFloatin interfaceValueAccessor<byte[]>
-
toFloatArray
public float[] toFloatArray(byte[] value, int dimension) Description copied from interface:ValueAccessorreturns a float[] from offset 0- Specified by:
toFloatArrayin interfaceValueAccessor<byte[]>
-
toDouble
public double toDouble(byte[] value) Description copied from interface:ValueAccessorreturns a double from offset 0- Specified by:
toDoublein interfaceValueAccessor<byte[]>
-
toUUID
Description copied from interface:ValueAccessorreturns a UUID from offset 0- Specified by:
toUUIDin interfaceValueAccessor<byte[]>
-
toTimeUUID
Description copied from interface:ValueAccessorreturns a TimeUUID from offset 0- Specified by:
toTimeUUIDin interfaceValueAccessor<byte[]>
-
toBallot
Description copied from interface:ValueAccessorreturns a TimeUUID from offset 0- Specified by:
toBallotin interfaceValueAccessor<byte[]>
-
putByte
public int putByte(byte[] dst, int offset, byte value) Description copied from interface:ValueAccessorwrites the byte value to at offset- Specified by:
putBytein interfaceValueAccessor<byte[]>- Returns:
- the number of bytes written to
-
putShort
public int putShort(byte[] dst, int offset, short value) Description copied from interface:ValueAccessorwrites the short value to at offset- Specified by:
putShortin interfaceValueAccessor<byte[]>- Returns:
- the number of bytes written to
-
putInt
public int putInt(byte[] dst, int offset, int value) Description copied from interface:ValueAccessorwrites the int value to at offset- Specified by:
putIntin interfaceValueAccessor<byte[]>- Returns:
- the number of bytes written to
-
putLong
public int putLong(byte[] dst, int offset, long value) Description copied from interface:ValueAccessorwrites the long value to at offset- Specified by:
putLongin interfaceValueAccessor<byte[]>- Returns:
- the number of bytes written to
-
putFloat
public int putFloat(byte[] dst, int offset, float value) Description copied from interface:ValueAccessorwrites the float value to at offset- Specified by:
putFloatin interfaceValueAccessor<byte[]>- Returns:
- the number of bytes written to
-
empty
public byte[] empty()Description copied from interface:ValueAccessorreturn a value with a length of 0- Specified by:
emptyin interfaceValueAccessor<byte[]>
-
valueOf
public byte[] valueOf(byte[] bytes) Description copied from interface:ValueAccessorreturn a value containing the Caller should assume that modifying the returned value will also modify the contents of- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
Description copied from interface:ValueAccessorreturn 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:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
Description copied from interface:ValueAccessorreturn a value containing the bytes for the given string and charset- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
public byte[] valueOf(boolean v) Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
public byte[] valueOf(byte v) Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
public byte[] valueOf(short v) Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
public byte[] valueOf(int v) Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
public byte[] valueOf(long v) Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
public byte[] valueOf(float v) Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
valueOf
public byte[] valueOf(double v) Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<byte[]>
-
convert
Description copied from interface:ValueAccessorConvert 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:
convertin interfaceValueAccessor<byte[]>
-
allocate
public byte[] allocate(int size) Description copied from interface:ValueAccessorAllocate and return a instance of bytes on the heap.- Specified by:
allocatein interfaceValueAccessor<byte[]>
-
factory
Description copied from interface:ValueAccessorreturns theValueAccessor.ObjectFactoryfor the backing type- Specified by:
factoryin interfaceValueAccessor<byte[]>
-