org.apache.ignite.internal.binary

## Class BinaryObjectOffheapImpl

- java.lang.Object
- - org.apache.ignite.internal.binary.BinaryObjectExImpl
  - - org.apache.ignite.internal.binary.BinaryObjectOffheapImpl

All Implemented Interfaces:
  Externalizable, Serializable, Cloneable, BinaryObject, BinaryObjectEx, CacheObject, Message

    public class BinaryObjectOffheapImpl
    extends BinaryObjectExImpl
    implements Externalizable, CacheObject

Binary object implementation over offheap memory

See Also:
  Serialized Form

### Field Summary

### Fields inherited from interface org.apache.ignite.internal.processors.cache.CacheObject

`TOMBSTONE, 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 and Description
`BinaryObjectOffheapImpl()` For `Externalizable` (not supported).
`BinaryObjectOffheapImpl(BinaryContext ctx, long ptr, int start, int size)`

### Method Summary

All Methods Instance Methods Concrete Methods
`byte[]` `array()`
`byte` `cacheObjectType()`
`BinaryObject` `clone()` Copies this binary object.
`BinaryContext` `context()` Get binary context.
`BinarySerializedFieldComparator` `createFieldComparator()` Create field comparator.
`BinarySchema` `createSchema()` Create schema for object.
`int` `dataStartOffset()` Get offset of data begin.
`<T> T` `deserialize()` Gets fully deserialized instance of binary object.
`<T> T` `deserialize(@Nullable ClassLoader ldr)` Gets fully deserialized instance of binary object.
`short` `directType()` Gets message type.
`protected <F> F` `field(BinaryReaderHandles rCtx, String fieldName)`
`<F> F` `field(int fieldId)` Gets field value.
`<F> F` `field(String fieldName)` Gets field value.
`<F> F` `fieldByOrder(int order)` Get field by offset.
`byte` `fieldsCount()` Gets fields count.
`void` `finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr)`
`int` `footerStartOffset()` Get offset of the footer begin.
`boolean` `hasArray()`
`boolean` `hasField(String fieldName)` Checks whether field exists in the object.
`int` `hashCode()`
`boolean` `hasSchema()`
`BinaryObject` `heapCopy()`
`boolean` `isFlagSet(short flag)` Check if flag set.
`boolean` `isPlatformType()` Gets flag indicating whether object value is a platform type.
`int` `length()`
`long` `offheapAddress()`
`void` `onAckReceived()` Method called when ack message received.
`CacheObject` `prepareForCache(CacheObjectContext ctx)` Prepares cache object for cache (e.g. copies user-provided object if needed).
`void` `prepareMarshal(CacheObjectValueContext ctx)`
`boolean` `putValue(ByteBuffer buf)`
`boolean` `putValue(ByteBuffer buf, int off, int len)`
`int` `putValue(long addr)`
`@Nullable BinaryType` `rawType()` Get raw type.
`void` `readExternal(ObjectInput in)`
`boolean` `readFrom(ByteBuffer buf, MessageReader reader)` Reads this message from provided byte buffer.
`int` `schemaId()` Get schema ID.
`int` `size()` Get the size of the object
`int` `start()`
`BinaryObjectBuilder` `toBuilder()` Creates a new `BinaryObjectBuilder` based on this binary object.
`@Nullable BinaryType` `type()` Gets type information for this binary object.
`int` `typeId()`
`<T> T` `value(CacheObjectValueContext ctx, boolean cpy)`
`<T> T` `value(CacheObjectValueContext ctx, boolean cpy, ClassLoader ldr)` Deserializes a value from an internal representation.
`byte[]` `valueBytes(CacheObjectValueContext ctx)`
`int` `valueBytesLength(CacheObjectContext ctx)`
`void` `writeExternal(ObjectOutput out)`
`protected boolean` `writeFieldByOrder(int fieldOffset, ByteBuffer buf)` Writes field value defined by the given field offset to the given byte buffer.
`boolean` `writeTo(ByteBuffer buf, MessageWriter writer)` Writes this message to provided byte buffer.

### Methods inherited from class org.apache.ignite.internal.binary.BinaryObjectExImpl

`enumName, enumOrdinal, equals, hasCircularReferences, toString`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### BinaryObjectOffheapImpl

    public BinaryObjectOffheapImpl()

For `Externalizable` (not supported).

#### BinaryObjectOffheapImpl

    public BinaryObjectOffheapImpl(BinaryContext ctx,
                                   long ptr,
                                   int start,
                                   int size)

Parameters:
  `ctx` - Context.
  `ptr` - Memory address.
  `start` - Object start.
  `size` - Memory size.

### Method Detail

#### heapCopy

    public BinaryObject heapCopy()

Returns:
  Heap-based copy.

#### typeId

    public int typeId()

Specified by:
  `typeId` in interface `BinaryObjectEx`
Returns:
  Type ID.

#### length

    public int length()

Specified by:
  `length` in class `BinaryObjectExImpl`
Returns:
  Length.

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### hasSchema

    public boolean hasSchema()

Specified by:
  `hasSchema` in class `BinaryObjectExImpl`
Returns:
  `True` if object has schema.

#### schemaId

    public int schemaId()

Get schema ID.

Specified by:
  `schemaId` in class `BinaryObjectExImpl`
Returns:
  Schema ID.

#### createSchema

    public BinarySchema createSchema()

Create schema for object.

Specified by:
  `createSchema` in class `BinaryObjectExImpl`
Returns:
  Schema.

#### context

    public BinaryContext context()

Get binary context.

Specified by:
  `context` in class `BinaryObjectExImpl`
Returns:
  Binary context.

#### start

    public int start()

Specified by:
  `start` in class `BinaryObjectExImpl`
Returns:
  Object start.

#### array

    public byte[] array()

Specified by:
  `array` in class `BinaryObjectExImpl`
Returns:
  Object array if object is array based, otherwise `null`.

#### putValue

    public boolean putValue(ByteBuffer buf)
                     throws IgniteCheckedException

Specified by:
  `putValue` in interface `CacheObject`
Parameters:
  `buf` - Buffer to write value to.
Returns:
  `True` if value was successfully written, `false` if there was not enough space in the buffer.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

    public int putValue(long addr)
                 throws IgniteCheckedException

Specified by:
  `putValue` in interface `CacheObject`
Parameters:
  `addr` - Address tp write value to.
Returns:
  Number of bytes written.
Throws:
  `IgniteCheckedException` - If failed.

#### putValue

    public boolean putValue(ByteBuffer buf,
                            int off,
                            int len)
                     throws IgniteCheckedException

Specified by:
  `putValue` in interface `CacheObject`
Parameters:
  `buf` - Buffer to write value to.
  `off` - Offset in source binary data.
  `len` - Length of the data to write.
Returns:
  `True` if value was successfully written, `false` if there was not enough space in the buffer.
Throws:
  `IgniteCheckedException` - If failed.

#### valueBytesLength

    public int valueBytesLength(CacheObjectContext ctx)
                         throws IgniteCheckedException

Specified by:
  `valueBytesLength` in interface `CacheObject`
Parameters:
  `ctx` - Cache object context.
Returns:
  Size required to store this value object.
Throws:
  `IgniteCheckedException` - If failed.

#### offheapAddress

    public long offheapAddress()

Specified by:
  `offheapAddress` in class `BinaryObjectExImpl`
Returns:
  Object offheap address is object is offheap based, otherwise 0.

#### hasArray

    public boolean hasArray()

Specified by:
  `hasArray` in class `BinaryObjectExImpl`
Returns:
  `True` if object is array based.

#### isFlagSet

    public boolean isFlagSet(short flag)

Check if flag set.

Specified by:
  `isFlagSet` in interface `BinaryObjectEx`
Parameters:
  `flag` - flag to check.
Returns:
  `true` if flag is set, `false` otherwise.

#### type

    @Nullable
    public @Nullable BinaryType type()
                                        throws BinaryObjectException

Gets type information for this binary object.

Specified by:
  `type` in interface `BinaryObject`
Returns:
  Binary object type information.
Throws:
  `BinaryObjectException` - In case of error.

#### rawType

    @Nullable
    public @Nullable BinaryType rawType()
                                           throws BinaryObjectException

Get raw type.

Specified by:
  `rawType` in interface `BinaryObjectEx`
Returns:
  Raw type
Throws:
  `BinaryObjectException` - If failed.

#### field

    @Nullable
    public <F> F field(String fieldName)
                          throws BinaryObjectException

Gets field value.

Specified by:
  `field` in interface `BinaryObject`
Type Parameters:
  `F` - Type of the field value.
Parameters:
  `fieldName` - Field name.
Returns:
  Field value.
Throws:
  `BinaryObjectException` - In case of any other error.

#### field

    @Nullable
    public <F> F field(int fieldId)
                          throws BinaryObjectException

Gets field value.

Specified by:
  `field` in class `BinaryObjectExImpl`
Parameters:
  `fieldId` - Field ID.
Returns:
  Field value.
Throws:
  `BinaryObjectException` - In case of any other error.

#### createFieldComparator

    public BinarySerializedFieldComparator createFieldComparator()

Create field comparator.

Specified by:
  `createFieldComparator` in class `BinaryObjectExImpl`
Returns:
  Comparator.

#### dataStartOffset

    public int dataStartOffset()

Get offset of data begin.

Specified by:
  `dataStartOffset` in class `BinaryObjectExImpl`
Returns:
  Field value.

#### footerStartOffset

    public int footerStartOffset()

Get offset of the footer begin.

Specified by:
  `footerStartOffset` in class `BinaryObjectExImpl`
Returns:
  Field value.

#### fieldByOrder

    @Nullable
    public <F> F fieldByOrder(int order)

Get field by offset.

Specified by:
  `fieldByOrder` in class `BinaryObjectExImpl`
Parameters:
  `order` - Field offset.
Returns:
  Field value.

#### writeFieldByOrder

    protected boolean writeFieldByOrder(int fieldOffset,
                                        ByteBuffer buf)

Writes field value defined by the given field offset to the given byte buffer.

Specified by:
  `writeFieldByOrder` in class `BinaryObjectExImpl`
Parameters:
  `fieldOffset` - Field offset.
Returns:
  Boolean flag indicating whether the field was successfully written to the buffer, `false` if there is no enough space for the field in the buffer.

#### field

    @Nullable
    protected <F> F field(BinaryReaderHandles rCtx,
                                    String fieldName)

Specified by:
  `field` in class `BinaryObjectExImpl`
Parameters:
  `rCtx` - Reader context.
  `fieldName` - Field name.
Returns:
  Field value.

#### hasField

    public boolean hasField(String fieldName)

Checks whether field exists in the object.

Specified by:
  `hasField` in interface `BinaryObject`
Parameters:
  `fieldName` - Field name.
Returns:
  `True` if field exists.

#### deserialize

    @Nullable
    public <T> T deserialize(@Nullable
                                       @Nullable ClassLoader ldr)
                                throws BinaryObjectException

Gets fully deserialized instance of binary object. If `ldr` was not specified, configured class loader will be used `IgniteConfiguration.getClassLoader()`.

Specified by:
  `deserialize` in interface `BinaryObject`
Type Parameters:
  `T` - Type of the deserialized object.
Parameters:
  `ldr` - Class loader.
Returns:
  Fully deserialized instance of binary object.
Throws:
  `BinaryInvalidTypeException` - If class doesn't exist.
  `BinaryObjectException` - In case of any other error.

#### deserialize

    @Nullable
    public <T> T deserialize()
                                throws BinaryObjectException

Gets fully deserialized instance of binary object.

Specified by:
  `deserialize` in interface `BinaryObject`
Type Parameters:
  `T` - Type of the deserialized object.
Returns:
  Fully deserialized instance of binary object.
Throws:
  `BinaryInvalidTypeException` - If class doesn't exist.
  `BinaryObjectException` - In case of any other error.

#### clone

    public BinaryObject clone()
                       throws CloneNotSupportedException

Copies this binary object.

Specified by:
  `clone` in interface `BinaryObject`
Overrides:
  `clone` in class `BinaryObjectExImpl`
Returns:
  Copy of this binary object.
Throws:
  `CloneNotSupportedException`

#### toBuilder

    public BinaryObjectBuilder toBuilder()
                                  throws BinaryObjectException

Creates a new `BinaryObjectBuilder` based on this binary object. The following code

     BinaryObjectBuilder builder = binaryObject.toBuilder();

is equivalent to

     BinaryObjectBuilder builder = ignite.binary().builder(binaryObject);

Specified by:
  `toBuilder` in interface `BinaryObject`
Overrides:
  `toBuilder` in class `BinaryObjectExImpl`
Returns:
  Binary object builder.
Throws:
  `BinaryObjectException` - If builder cannot be created.

#### cacheObjectType

    public byte cacheObjectType()

Specified by:
  `cacheObjectType` in interface `CacheObject`
Returns:
  Object type.

#### isPlatformType

    public boolean isPlatformType()

Gets flag indicating whether object value is a platform type. Platform types will be automatically deserialized on public API cache operations regardless whether `IgniteCache.withKeepBinary()` is used or not.

Specified by:
  `isPlatformType` in interface `CacheObject`
Returns:
  Platform type flag.

#### value

    @Nullable
    public <T> T value(CacheObjectValueContext ctx,
                                 boolean cpy)

Specified by:
  `value` in interface `CacheObject`
Parameters:
  `ctx` - Context.
  `cpy` - If `true` need to copy value.
Returns:
  Value.

#### value

    @Nullable
    public <T> T value(CacheObjectValueContext ctx,
                                 boolean cpy,
                                 ClassLoader ldr)

Deserializes a value from an internal representation.

Specified by:
  `value` in interface `CacheObject`
Parameters:
  `ctx` - Context.
  `cpy` - If `true` need to copy value.
  `ldr` - Class loader, if it is `null`, default class loader will be used.
Returns:
  Value.

#### valueBytes

    public byte[] valueBytes(CacheObjectValueContext ctx)
                      throws IgniteCheckedException

Specified by:
  `valueBytes` in interface `CacheObject`
Parameters:
  `ctx` - Context.
Returns:
  Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### prepareForCache

    public CacheObject prepareForCache(CacheObjectContext ctx)

Prepares cache object for cache (e.g. copies user-provided object if needed).

Specified by:
  `prepareForCache` in interface `CacheObject`
Parameters:
  `ctx` - Cache context.
Returns:
  Instance to store in cache.

#### finishUnmarshal

    public void finishUnmarshal(CacheObjectValueContext ctx,
                                ClassLoader ldr)
                         throws IgniteCheckedException

Specified by:
  `finishUnmarshal` in interface `CacheObject`
Parameters:
  `ctx` - Context.
  `ldr` - Class loader.
Throws:
  `IgniteCheckedException` - If failed.

#### prepareMarshal

    public void prepareMarshal(CacheObjectValueContext ctx)
                        throws IgniteCheckedException

Specified by:
  `prepareMarshal` in interface `CacheObject`
Parameters:
  `ctx` - Context.
Throws:
  `IgniteCheckedException` - If failed.

#### writeTo

    public boolean writeTo(ByteBuffer buf,
                           MessageWriter writer)

Writes this message to provided byte buffer.

Specified by:
  `writeTo` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `writer` - Writer.
Returns:
  Whether message was fully written.

#### readFrom

    public boolean readFrom(ByteBuffer buf,
                            MessageReader reader)

Reads this message from provided byte buffer.

Specified by:
  `readFrom` in interface `Message`
Parameters:
  `buf` - Byte buffer.
  `reader` - Reader.
Returns:
  Whether message was fully read.

#### directType

    public short directType()

Gets message type.

Specified by:
  `directType` in interface `Message`
Returns:
  Message type.

#### fieldsCount

    public byte fieldsCount()

Gets fields count.

Specified by:
  `fieldsCount` in interface `Message`
Returns:
  Fields count.

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### onAckReceived

    public void onAckReceived()

Method called when ack message received.

Specified by:
  `onAckReceived` in interface `Message`

#### size

    public int size()

Get the size of the object

Specified by:
  `size` in interface `BinaryObject`
Returns:
  Size of the object

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022