Package org.apache.cassandra.db.marshal
Class ByteBufferAccessor
java.lang.Object
org.apache.cassandra.db.marshal.ByteBufferAccessor
- All Implemented Interfaces:
ValueAccessor<ByteBuffer>
Accessor for ByteBuffer values. ByteBufferAccessor treates
Buffer.position() as index 0,
and Buffer.remaining() as the length.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.db.marshal.ValueAccessor
ValueAccessor.ObjectFactory<V> -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionallocate(int size) Allocate and return a instance of bytes on the heap.<V2> intcompare(ByteBuffer left, V2 right, ValueAccessor<V2> accessorR) lexicographically compare tointcompareByteArrayTo(byte[] left, ByteBuffer right) compare a byte array on the left with a on the right}intcompareByteBufferTo(ByteBuffer left, ByteBuffer right) compare a byte buffer on the left with a on the right}<V2> ByteBufferconvert(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, ByteBuffer dst, int dstOffset, int size) copies a byte array into this accessors value.intcopyByteBufferTo(ByteBuffer src, int srcOffset, ByteBuffer dst, int dstOffset, int size) copies a byte buffer into this accessors value.<V2> intcopyTo(ByteBuffer 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 accessorcreateArray(int length) allocate an instance of the accessors backing typevoiddigest(ByteBuffer value, int offset, int size, Digest digest) updates with bytes from the contents of starting at offsetempty()return a value with a length of 0factory()returns theValueAccessor.ObjectFactoryfor the backing typebytegetByte(ByteBuffer value, int offset) returns a byte from offsetdoublegetDouble(ByteBuffer value, int offset) floatgetFloat(ByteBuffer value, int offset) intgetInt(ByteBuffer value, int offset) returns an int from offsetlonggetLong(ByteBuffer value, int offset) returns a long from offsetshortgetShort(ByteBuffer value, int offset) returns a short from offsetintgetUnsignedShort(ByteBuffer value, int offset) returns an unsigned short from offsetintputByte(ByteBuffer dst, int offset, byte value) writes the byte value to at offsetintputFloat(ByteBuffer dst, int offset, float value) writes the float value to at offsetintputInt(ByteBuffer dst, int offset, int value) writes the int value to at offsetintputLong(ByteBuffer dst, int offset, long value) writes the long value to at offsetintputShort(ByteBuffer dst, int offset, short value) writes the short value to at offsetread(DataInputPlus in, int length) Reads a value of bytes fromintsize(ByteBuffer value) slice(ByteBuffer input, int offset, int length) Returns a value with the contents of from to .byte[]toArray(ByteBuffer 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(ByteBuffer value, int offset, int length) returns a byte[] with bytes copied from the contents of starting at offset .toBallot(ByteBuffer value) returns a TimeUUID from offset 0toBuffer(ByteBuffer 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(ByteBuffer value) returns a byte from offset 0doubletoDouble(ByteBuffer value) returns a double from offset 0floattoFloat(ByteBuffer value) returns a float from offset 0float[]toFloatArray(ByteBuffer value, int dimension) returns a float[] from offset 0toHex(ByteBuffer value) inttoInt(ByteBuffer value) returns an int from offset 0longtoLong(ByteBuffer value) returns a long from offset 0shorttoShort(ByteBuffer value) returns a short from offset 0toString(ByteBuffer value, Charset charset) toTimeUUID(ByteBuffer value) returns a TimeUUID from offset 0toUUID(ByteBuffer value) returns a UUID from offset 0valueOf(boolean v) return a value with the bytes fromvalueOf(byte v) return a value with the bytes fromvalueOf(byte[] bytes) return a value containing the Caller should assume that modifying the returned value will also modify the contents ofvalueOf(double v) return a value with the bytes fromvalueOf(float v) return a value with the bytes fromvalueOf(int v) return a value with the bytes fromvalueOf(long v) return a value with the bytes fromvalueOf(short v) return a value with the bytes fromreturn a value containing the bytes for the given string and charsetvalueOf(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 ofreturn a value with the bytes fromvoidwrite(ByteBuffer value, ByteBuffer out) Write the contents of the given value into the ByteBuffervoidwrite(ByteBuffer 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
-
-
Method Details
-
size
- Specified by:
sizein interfaceValueAccessor<ByteBuffer>- Returns:
- the size of the given value
-
createArray
Description copied from interface:ValueAccessorallocate an instance of the accessors backing type- Specified by:
createArrayin interfaceValueAccessor<ByteBuffer>- 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<ByteBuffer>- Throws:
IOException
-
write
Description copied from interface:ValueAccessorWrite the contents of the given value into the ByteBuffer- Specified by:
writein interfaceValueAccessor<ByteBuffer>
-
copyTo
public <V2> int copyTo(ByteBuffer 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<ByteBuffer>- Type Parameters:
V2- the destination value type- Returns:
- the number of bytes copied ()
-
copyByteArrayTo
Description copied from interface:ValueAccessorcopies a byte array into this accessors value.- Specified by:
copyByteArrayToin interfaceValueAccessor<ByteBuffer>
-
copyByteBufferTo
Description copied from interface:ValueAccessorcopies a byte buffer into this accessors value.- Specified by:
copyByteBufferToin interfaceValueAccessor<ByteBuffer>
-
digest
Description copied from interface:ValueAccessorupdates with bytes from the contents of starting at offset- Specified by:
digestin interfaceValueAccessor<ByteBuffer>
-
read
Description copied from interface:ValueAccessorReads a value of bytes from- Specified by:
readin interfaceValueAccessor<ByteBuffer>- Throws:
IOException
-
slice
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<ByteBuffer>
-
compare
Description copied from interface:ValueAccessorlexicographically compare to- Specified by:
comparein interfaceValueAccessor<ByteBuffer>- Type Parameters:
V2- backing type of
-
compareByteArrayTo
Description copied from interface:ValueAccessorcompare a byte array on the left with a on the right}- Specified by:
compareByteArrayToin interfaceValueAccessor<ByteBuffer>
-
compareByteBufferTo
Description copied from interface:ValueAccessorcompare a byte buffer on the left with a on the right}- Specified by:
compareByteBufferToin interfaceValueAccessor<ByteBuffer>
-
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<ByteBuffer>
-
toArray
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<ByteBuffer>
-
toArray
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<ByteBuffer>
-
toString
- Specified by:
toStringin interfaceValueAccessor<ByteBuffer>- Throws:
CharacterCodingException
-
valueOf
Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<ByteBuffer>
-
toHex
- Specified by:
toHexin interfaceValueAccessor<ByteBuffer>
-
toByte
Description copied from interface:ValueAccessorreturns a byte from offset 0- Specified by:
toBytein interfaceValueAccessor<ByteBuffer>
-
getByte
Description copied from interface:ValueAccessorreturns a byte from offset- Specified by:
getBytein interfaceValueAccessor<ByteBuffer>
-
toShort
Description copied from interface:ValueAccessorreturns a short from offset 0- Specified by:
toShortin interfaceValueAccessor<ByteBuffer>
-
getShort
Description copied from interface:ValueAccessorreturns a short from offset- Specified by:
getShortin interfaceValueAccessor<ByteBuffer>
-
getUnsignedShort
Description copied from interface:ValueAccessorreturns an unsigned short from offset- Specified by:
getUnsignedShortin interfaceValueAccessor<ByteBuffer>
-
toInt
Description copied from interface:ValueAccessorreturns an int from offset 0- Specified by:
toIntin interfaceValueAccessor<ByteBuffer>
-
getInt
Description copied from interface:ValueAccessorreturns an int from offset- Specified by:
getIntin interfaceValueAccessor<ByteBuffer>
-
getFloat
- Specified by:
getFloatin interfaceValueAccessor<ByteBuffer>
-
getDouble
- Specified by:
getDoublein interfaceValueAccessor<ByteBuffer>
-
toLong
Description copied from interface:ValueAccessorreturns a long from offset 0- Specified by:
toLongin interfaceValueAccessor<ByteBuffer>
-
getLong
Description copied from interface:ValueAccessorreturns a long from offset- Specified by:
getLongin interfaceValueAccessor<ByteBuffer>
-
toFloat
Description copied from interface:ValueAccessorreturns a float from offset 0- Specified by:
toFloatin interfaceValueAccessor<ByteBuffer>
-
toFloatArray
Description copied from interface:ValueAccessorreturns a float[] from offset 0- Specified by:
toFloatArrayin interfaceValueAccessor<ByteBuffer>
-
toDouble
Description copied from interface:ValueAccessorreturns a double from offset 0- Specified by:
toDoublein interfaceValueAccessor<ByteBuffer>
-
toUUID
Description copied from interface:ValueAccessorreturns a UUID from offset 0- Specified by:
toUUIDin interfaceValueAccessor<ByteBuffer>
-
toTimeUUID
Description copied from interface:ValueAccessorreturns a TimeUUID from offset 0- Specified by:
toTimeUUIDin interfaceValueAccessor<ByteBuffer>
-
toBallot
Description copied from interface:ValueAccessorreturns a TimeUUID from offset 0- Specified by:
toBallotin interfaceValueAccessor<ByteBuffer>
-
putByte
Description copied from interface:ValueAccessorwrites the byte value to at offset- Specified by:
putBytein interfaceValueAccessor<ByteBuffer>- Returns:
- the number of bytes written to
-
putShort
Description copied from interface:ValueAccessorwrites the short value to at offset- Specified by:
putShortin interfaceValueAccessor<ByteBuffer>- Returns:
- the number of bytes written to
-
putInt
Description copied from interface:ValueAccessorwrites the int value to at offset- Specified by:
putIntin interfaceValueAccessor<ByteBuffer>- Returns:
- the number of bytes written to
-
putLong
Description copied from interface:ValueAccessorwrites the long value to at offset- Specified by:
putLongin interfaceValueAccessor<ByteBuffer>- Returns:
- the number of bytes written to
-
putFloat
Description copied from interface:ValueAccessorwrites the float value to at offset- Specified by:
putFloatin interfaceValueAccessor<ByteBuffer>- Returns:
- the number of bytes written to
-
empty
Description copied from interface:ValueAccessorreturn a value with a length of 0- Specified by:
emptyin interfaceValueAccessor<ByteBuffer>
-
valueOf
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<ByteBuffer>
-
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<ByteBuffer>
-
valueOf
Description copied from interface:ValueAccessorreturn a value containing the bytes for the given string and charset- Specified by:
valueOfin interfaceValueAccessor<ByteBuffer>
-
valueOf
Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<ByteBuffer>
-
valueOf
Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<ByteBuffer>
-
valueOf
Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<ByteBuffer>
-
valueOf
Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<ByteBuffer>
-
valueOf
Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<ByteBuffer>
-
valueOf
Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<ByteBuffer>
-
valueOf
Description copied from interface:ValueAccessorreturn a value with the bytes from- Specified by:
valueOfin interfaceValueAccessor<ByteBuffer>
-
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<ByteBuffer>
-
allocate
Description copied from interface:ValueAccessorAllocate and return a instance of bytes on the heap.- Specified by:
allocatein interfaceValueAccessor<ByteBuffer>
-
factory
Description copied from interface:ValueAccessorreturns theValueAccessor.ObjectFactoryfor the backing type- Specified by:
factoryin interfaceValueAccessor<ByteBuffer>
-