org.apache.ignite.internal.processors.platform.memory

## Class PlatformOutputStreamImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.platform.memory.PlatformOutputStreamImpl

All Implemented Interfaces:
  AutoCloseable, BinaryOutputStream, BinaryStream, PlatformOutputStream

Direct Known Subclasses:
  PlatformBigEndianOutputStreamImpl

    public class PlatformOutputStreamImpl
    extends Object
    implements PlatformOutputStream

Interop output stream implementation.

### Field Summary

Fields
`protected int` `cap` Maximum capacity.
`protected long` `data` Pointer.
`protected PlatformMemory` `mem` Underlying memory chunk.
`protected int` `pos` Current position.

### Constructor Summary

Constructors
Constructor and Description
`PlatformOutputStreamImpl(PlatformMemory mem)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`byte[]` `array()`
`byte[]` `arrayCopy()`
`int` `capacity()`
`void` `close()` Close the stream releasing resources.
`protected void` `ensureCapacity(int reqCap)` Ensure capacity.
`boolean` `hasArray()`
`long` `offheapPointer()`
`int` `position()`
`void` `position(int pos)`
`long` `rawOffheapPointer()`
`protected void` `shift(int cnt)` Shift position.
`void` `synchronize()` Synchronize output stream with underlying memory
`void` `unsafeEnsure(int cap)` Ensure capacity for unsafe writes.
`void` `unsafePosition(int pos)` Set position in unsafe mode.
`void` `unsafeWriteBoolean(boolean val)` Write boolean in unsafe mode.
`void` `unsafeWriteByte(byte val)` Write byte in unsafe mode.
`void` `unsafeWriteChar(char val)` Write char in unsafe mode.
`void` `unsafeWriteDouble(double val)` Write double in unsafe mode.
`void` `unsafeWriteFloat(float val)` Write float in unsafe mode.
`void` `unsafeWriteInt(int val)` Write int in unsafe mode.
`void` `unsafeWriteInt(int pos, int val)` Write int in unsafe mode.
`void` `unsafeWriteLong(long val)` Write long in unsafe mode.
`void` `unsafeWriteShort(int pos, short val)` Write short in unsafe mode.
`void` `unsafeWriteShort(short val)` Write short in unsafe mode.
`void` `write(byte[] arr, int off, int len)` Write byte array.
`void` `write(long addr, int cnt)` Write data from unmanaged memory.
`void` `writeBoolean(boolean val)` Write boolean value.
`void` `writeBooleanArray(boolean[] val)` Write boolean array.
`void` `writeByte(byte val)` Write byte value.
`void` `writeByteArray(byte[] val)` Write byte array.
`void` `writeChar(char val)` Write char value.
`void` `writeCharArray(char[] val)` Write char array.
`void` `writeDouble(double val)` Write double value.
`void` `writeDoubleArray(double[] val)` Write double array.
`void` `writeFloat(float val)` Write float value.
`void` `writeFloatArray(float[] val)` Write float array.
`void` `writeInt(int val)` Write int value.
`void` `writeInt(int pos, int val)` Write int value to the given position.
`void` `writeIntArray(int[] val)` Write int array.
`void` `writeLong(long val)` Write long value.
`void` `writeLongArray(long[] val)` Write long array.
`void` `writeShort(int pos, short val)` Write short value at the given position.
`void` `writeShort(short val)` Write short value.
`void` `writeShortArray(short[] val)` Write short array.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### mem

    protected final PlatformMemory mem

Underlying memory chunk.

#### data

    protected long data

Pointer.

#### cap

    protected int cap

Maximum capacity.

#### pos

    protected int pos

Current position.

### Constructor Detail

#### PlatformOutputStreamImpl

    public PlatformOutputStreamImpl(PlatformMemory mem)

Constructor.

Parameters:
  `mem` - Underlying memory chunk.

### Method Detail

#### writeByte

    public void writeByte(byte val)

Write byte value.

Specified by:
  `writeByte` in interface `BinaryOutputStream`
Parameters:
  `val` - Byte value.

#### writeByteArray

    public void writeByteArray(byte[] val)

Write byte array.

Specified by:
  `writeByteArray` in interface `BinaryOutputStream`
Parameters:
  `val` - Byte array.

#### writeBoolean

    public void writeBoolean(boolean val)

Write boolean value.

Specified by:
  `writeBoolean` in interface `BinaryOutputStream`
Parameters:
  `val` - Boolean value.

#### writeBooleanArray

    public void writeBooleanArray(boolean[] val)

Write boolean array.

Specified by:
  `writeBooleanArray` in interface `BinaryOutputStream`
Parameters:
  `val` - Boolean array.

#### writeShort

    public void writeShort(short val)

Write short value.

Specified by:
  `writeShort` in interface `BinaryOutputStream`
Parameters:
  `val` - Short value.

#### writeShortArray

    public void writeShortArray(short[] val)

Write short array.

Specified by:
  `writeShortArray` in interface `BinaryOutputStream`
Parameters:
  `val` - Short array.

#### writeChar

    public void writeChar(char val)

Write char value.

Specified by:
  `writeChar` in interface `BinaryOutputStream`
Parameters:
  `val` - Char value.

#### writeCharArray

    public void writeCharArray(char[] val)

Write char array.

Specified by:
  `writeCharArray` in interface `BinaryOutputStream`
Parameters:
  `val` - Char array.

#### writeInt

    public void writeInt(int val)

Write int value.

Specified by:
  `writeInt` in interface `BinaryOutputStream`
Parameters:
  `val` - Int value.

#### writeIntArray

    public void writeIntArray(int[] val)

Write int array.

Specified by:
  `writeIntArray` in interface `BinaryOutputStream`
Parameters:
  `val` - Int array.

#### writeShort

    public void writeShort(int pos,
                           short val)

Write short value at the given position.

Specified by:
  `writeShort` in interface `BinaryOutputStream`
Parameters:
  `pos` - Position.
  `val` - Value.

#### writeInt

    public void writeInt(int pos,
                         int val)

Write int value to the given position.

Specified by:
  `writeInt` in interface `BinaryOutputStream`
Parameters:
  `pos` - Position.
  `val` - Value.

#### writeFloat

    public void writeFloat(float val)

Write float value.

Specified by:
  `writeFloat` in interface `BinaryOutputStream`
Parameters:
  `val` - Float value.

#### writeFloatArray

    public void writeFloatArray(float[] val)

Write float array.

Specified by:
  `writeFloatArray` in interface `BinaryOutputStream`
Parameters:
  `val` - Float array.

#### writeLong

    public void writeLong(long val)

Write long value.

Specified by:
  `writeLong` in interface `BinaryOutputStream`
Parameters:
  `val` - Long value.

#### writeLongArray

    public void writeLongArray(long[] val)

Write long array.

Specified by:
  `writeLongArray` in interface `BinaryOutputStream`
Parameters:
  `val` - Long array.

#### writeDouble

    public void writeDouble(double val)

Write double value.

Specified by:
  `writeDouble` in interface `BinaryOutputStream`
Parameters:
  `val` - Double value.

#### writeDoubleArray

    public void writeDoubleArray(double[] val)

Write double array.

Specified by:
  `writeDoubleArray` in interface `BinaryOutputStream`
Parameters:
  `val` - Double array.

#### write

    public void write(byte[] arr,
                      int off,
                      int len)

Write byte array.

Specified by:
  `write` in interface `BinaryOutputStream`
Parameters:
  `arr` - Array.
  `off` - Offset.
  `len` - Length.

#### write

    public void write(long addr,
                      int cnt)

Write data from unmanaged memory.

Specified by:
  `write` in interface `BinaryOutputStream`
Parameters:
  `addr` - Address.
  `cnt` - Count.

#### position

    public int position()

Specified by:
  `position` in interface `BinaryStream`
Returns:
  Position.

#### position

    public void position(int pos)

Specified by:
  `position` in interface `BinaryStream`
Parameters:
  `pos` - Position.

#### close

    public void close()

Close the stream releasing resources.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `BinaryOutputStream`

#### array

    public byte[] array()

Specified by:
  `array` in interface `BinaryStream`
Returns:
  Underlying array.

#### arrayCopy

    public byte[] arrayCopy()

Specified by:
  `arrayCopy` in interface `BinaryStream`
Returns:
  Copy of data in the stream.

#### offheapPointer

    public long offheapPointer()

Specified by:
  `offheapPointer` in interface `BinaryStream`
Returns:
  Offheap pointer if stream is offheap based and "forceHeap" flag is not set; otherwise `0`.

#### rawOffheapPointer

    public long rawOffheapPointer()

Specified by:
  `rawOffheapPointer` in interface `BinaryStream`
Returns:
  Offheap pointer if stream is offheap based; otherwise `0`.

#### hasArray

    public boolean hasArray()

Specified by:
  `hasArray` in interface `BinaryStream`
Returns:
  `True` is stream is array based.

#### unsafeEnsure

    public void unsafeEnsure(int cap)

Ensure capacity for unsafe writes.

Specified by:
  `unsafeEnsure` in interface `BinaryOutputStream`
Parameters:
  `cap` - Capacity.

#### unsafePosition

    public void unsafePosition(int pos)

Set position in unsafe mode.

Specified by:
  `unsafePosition` in interface `BinaryOutputStream`
Parameters:
  `pos` - Position.

#### unsafeWriteByte

    public void unsafeWriteByte(byte val)

Write byte in unsafe mode.

Specified by:
  `unsafeWriteByte` in interface `BinaryOutputStream`
Parameters:
  `val` - Value.

#### unsafeWriteBoolean

    public void unsafeWriteBoolean(boolean val)

Write boolean in unsafe mode.

Specified by:
  `unsafeWriteBoolean` in interface `BinaryOutputStream`
Parameters:
  `val` - Value.

#### unsafeWriteShort

    public void unsafeWriteShort(short val)

Write short in unsafe mode.

Specified by:
  `unsafeWriteShort` in interface `BinaryOutputStream`
Parameters:
  `val` - Value.

#### unsafeWriteShort

    public void unsafeWriteShort(int pos,
                                 short val)

Write short in unsafe mode.

Specified by:
  `unsafeWriteShort` in interface `BinaryOutputStream`
Parameters:
  `pos` - Position.
  `val` - Value.

#### unsafeWriteChar

    public void unsafeWriteChar(char val)

Write char in unsafe mode.

Specified by:
  `unsafeWriteChar` in interface `BinaryOutputStream`
Parameters:
  `val` - Value.

#### unsafeWriteInt

    public void unsafeWriteInt(int val)

Write int in unsafe mode.

Specified by:
  `unsafeWriteInt` in interface `BinaryOutputStream`
Parameters:
  `val` - Value.

#### unsafeWriteInt

    public void unsafeWriteInt(int pos,
                               int val)

Write int in unsafe mode.

Specified by:
  `unsafeWriteInt` in interface `BinaryOutputStream`
Parameters:
  `pos` - Position.
  `val` - Value.

#### unsafeWriteLong

    public void unsafeWriteLong(long val)

Write long in unsafe mode.

Specified by:
  `unsafeWriteLong` in interface `BinaryOutputStream`
Parameters:
  `val` - Value.

#### unsafeWriteFloat

    public void unsafeWriteFloat(float val)

Write float in unsafe mode.

Specified by:
  `unsafeWriteFloat` in interface `BinaryOutputStream`
Parameters:
  `val` - Value.

#### unsafeWriteDouble

    public void unsafeWriteDouble(double val)

Write double in unsafe mode.

Specified by:
  `unsafeWriteDouble` in interface `BinaryOutputStream`
Parameters:
  `val` - Value.

#### synchronize

    public void synchronize()

Synchronize output stream with underlying memory

Specified by:
  `synchronize` in interface `PlatformOutputStream`

#### ensureCapacity

    protected void ensureCapacity(int reqCap)

Ensure capacity.

Parameters:
  `reqCap` - Required byte count.

#### shift

    protected void shift(int cnt)

Shift position.

Parameters:
  `cnt` - Byte count.

#### capacity

    public int capacity()

Specified by:
  `capacity` in interface `BinaryStream`
Returns:
  Total capacity.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.5.0
Release Date | : May 23 2018