Search in sources :

Example 16 with BinaryHeapInputStream

use of org.apache.ignite.internal.binary.streams.BinaryHeapInputStream in project ignite by apache.

the class BinaryMarshallerSelfTest method testReadDetachObjectProperly.

/**
 * Perform action on binary object after unmarshalling from offheap data, when offheap memory chunk cleared.
 *
 * @param obj Object to marshal-unmarshal.
 * @param action Action to perform on object.
 * @throws Exception If failed.
 */
private void testReadDetachObjectProperly(Object obj, IgniteThrowableConsumer<Object> action, boolean deserialize) throws Exception {
    BinaryMarshaller marsh = binaryMarshaller();
    BinaryHeapOutputStream os = new BinaryHeapOutputStream(1024);
    BinaryWriterExImpl writer = marsh.binaryMarshaller().writer(os);
    writer.writeObject(obj);
    BinaryHeapInputStream is = new BinaryHeapInputStream(os.array());
    BinaryReaderExImpl reader = marsh.binaryMarshaller().reader(is);
    Object bObj = reader.readObjectDetached(deserialize);
    Arrays.fill(os.array(), (byte) 0);
    action.accept(bObj);
}
Also used : BinaryHeapOutputStream(org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream) BinaryHeapInputStream(org.apache.ignite.internal.binary.streams.BinaryHeapInputStream) BinaryObject(org.apache.ignite.binary.BinaryObject)

Aggregations

BinaryHeapInputStream (org.apache.ignite.internal.binary.streams.BinaryHeapInputStream)16 BinaryReaderExImpl (org.apache.ignite.internal.binary.BinaryReaderExImpl)13 BinaryHeapOutputStream (org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream)9 BinaryWriterExImpl (org.apache.ignite.internal.binary.BinaryWriterExImpl)8 BinaryInputStream (org.apache.ignite.internal.binary.streams.BinaryInputStream)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 JdbcResponse (org.apache.ignite.internal.processors.odbc.jdbc.JdbcResponse)3 SQLException (java.sql.SQLException)2 IgniteException (org.apache.ignite.IgniteException)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 MarshallerContextImpl (org.apache.ignite.internal.MarshallerContextImpl)2 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)2 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)2 ClientListenerProtocolVersion (org.apache.ignite.internal.processors.odbc.ClientListenerProtocolVersion)2 ClientListenerRequest (org.apache.ignite.internal.processors.odbc.ClientListenerRequest)2 IgniteProductVersion (org.apache.ignite.lang.IgniteProductVersion)2 Time (java.sql.Time)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1