Class CacheObjectAdapter
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.CacheObjectAdapter
-
- All Implemented Interfaces:
Externalizable,Serializable,CacheObject,Message
- Direct Known Subclasses:
CacheObjectImpl,KeyCacheObjectImpl
public abstract class CacheObjectAdapter extends Object implements CacheObject, Externalizable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static intHEAD_SIZEHead size.protected Objectvalprotected byte[]valBytes-
Fields inherited from interface org.apache.ignite.internal.processors.cache.CacheObject
TYPE_BINARY, TYPE_BINARY_ENUM, TYPE_BYTE_ARR, TYPE_REGULAR
-
Fields inherited from interface org.apache.ignite.plugin.extensions.communication.Message
DIRECT_TYPE_SIZE
-
-
Constructor Summary
Constructors Constructor Description CacheObjectAdapter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description bytecacheObjectType()bytefieldsCount()Gets fields count.protected booleanneedCopy(CacheObjectValueContext ctx)static intobjectPutSize(int dataLen)static booleanputValue(byte cacheObjType, ByteBuffer buf, int off, int len, byte[] valBytes, int start)intputValue(long addr)static intputValue(long addr, byte type, byte[] valBytes)static intputValue(long addr, byte type, byte[] srcBytes, int srcOff, int len)booleanputValue(ByteBuffer buf)booleanputValue(ByteBuffer buf, int off, int len)voidreadExternal(ObjectInput in)booleanreadFrom(ByteBuffer buf, MessageReader reader)Reads this message from provided byte buffer.StringtoString()protected byte[]valueBytesFromValue(CacheObjectValueContext ctx)intvalueBytesLength(CacheObjectContext ctx)protected ObjectvalueFromValueBytes(CacheObjectValueContext ctx, ClassLoader ldr)voidwriteExternal(ObjectOutput out)booleanwriteTo(ByteBuffer buf, MessageWriter writer)Writes this message to provided byte buffer.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.internal.processors.cache.CacheObject
finishUnmarshal, isPlatformType, prepareForCache, prepareMarshal, value, value, valueBytes
-
Methods inherited from interface org.apache.ignite.plugin.extensions.communication.Message
directType, onAckReceived
-
-
-
-
Field Detail
-
HEAD_SIZE
protected static final int HEAD_SIZE
Head size.- See Also:
- Constant Field Values
-
val
@GridToStringInclude(sensitive=true) protected Object val
-
valBytes
protected byte[] valBytes
-
-
Method Detail
-
needCopy
protected boolean needCopy(CacheObjectValueContext ctx)
- Parameters:
ctx- Context.- Returns:
Trueneed to copy value returned to user.
-
valueBytesFromValue
protected byte[] valueBytesFromValue(CacheObjectValueContext ctx) throws IgniteCheckedException
- Returns:
- Value bytes from value.
- Throws:
IgniteCheckedException
-
valueFromValueBytes
protected Object valueFromValueBytes(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException
- Returns:
- Value from value bytes.
- Throws:
IgniteCheckedException
-
cacheObjectType
public byte cacheObjectType()
- Specified by:
cacheObjectTypein interfaceCacheObject- Returns:
- Object type.
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
putValue
public boolean putValue(ByteBuffer buf) throws IgniteCheckedException
- Specified by:
putValuein interfaceCacheObject- Parameters:
buf- Buffer to write value to.- Returns:
Trueif value was successfully written,falseif there was not enough space in the buffer.- Throws:
IgniteCheckedException- If failed.
-
putValue
public int putValue(long addr) throws IgniteCheckedException- Specified by:
putValuein interfaceCacheObject- Parameters:
addr- Address tp write value to.- Returns:
- Number of bytes written.
- Throws:
IgniteCheckedException- If failed.
-
putValue
public static int putValue(long addr, byte type, byte[] valBytes)- Parameters:
addr- Write address.type- Object type.valBytes- Value bytes array.- Returns:
- Offset shift compared to initial address.
-
putValue
public static int putValue(long addr, byte type, byte[] srcBytes, int srcOff, int len)- Parameters:
addr- Write address.type- Object type.srcBytes- Source value bytes array.srcOff- Start position in sourceBytes.len- Number of bytes for write.- Returns:
- Offset shift compared to initial address.
-
putValue
public boolean putValue(ByteBuffer buf, int off, int len) throws IgniteCheckedException
- Specified by:
putValuein interfaceCacheObject- Parameters:
buf- Buffer to write value to.off- Offset in source binary data.len- Length of the data to write.- Returns:
Trueif value was successfully written,falseif there was not enough space in the buffer.- Throws:
IgniteCheckedException- If failed.
-
valueBytesLength
public int valueBytesLength(CacheObjectContext ctx) throws IgniteCheckedException
- Specified by:
valueBytesLengthin interfaceCacheObject- Parameters:
ctx- Cache object context.- Returns:
- Size required to store this value object.
- Throws:
IgniteCheckedException- If failed.
-
readFrom
public boolean readFrom(ByteBuffer buf, MessageReader reader)
Reads this message from provided byte buffer.
-
writeTo
public boolean writeTo(ByteBuffer buf, MessageWriter writer)
Writes this message to provided byte buffer.
-
fieldsCount
public byte fieldsCount()
Gets fields count.- Specified by:
fieldsCountin interfaceMessage- Returns:
- Fields count.
-
objectPutSize
public static int objectPutSize(int dataLen)
- Parameters:
dataLen- Serialized value length.- Returns:
- Full size required to store cache object.
- See Also:
putValue(byte, ByteBuffer, int, int, byte[], int)
-
putValue
public static boolean putValue(byte cacheObjType, ByteBuffer buf, int off, int len, byte[] valBytes, int start) throws IgniteCheckedException- Parameters:
cacheObjType- Cache object type.buf- Buffer to write value to.off- Offset in source binary data.len- Length of the data to write.valBytes- Binary data.start- Start offset in binary data.- Returns:
Trueif data were successfully written.- Throws:
IgniteCheckedException- If failed.
-
-