org.apache.ignite.internal.binary.streams

## Class BinaryHeapOutputStream

- java.lang.Object
- - org.apache.ignite.internal.binary.streams.BinaryAbstractStream
  - - org.apache.ignite.internal.binary.streams.BinaryAbstractOutputStream
    - - org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream

All Implemented Interfaces:
  AutoCloseable, BinaryOutputStream, BinaryStream

    public final class BinaryHeapOutputStream
    extends BinaryAbstractOutputStream

Binary heap output stream.

### Field Summary

### Fields inherited from class org.apache.ignite.internal.binary.streams.BinaryAbstractOutputStream

`MAX_ARRAY_SIZE`

### Fields inherited from class org.apache.ignite.internal.binary.streams.BinaryAbstractStream

`BYTE_ONE, BYTE_ZERO, pos`

### Constructor Summary

Constructors
Constructor and Description
`BinaryHeapOutputStream(int cap)` Constructor.
`BinaryHeapOutputStream(int cap, BinaryMemoryAllocatorChunk chunk)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`byte[]` `array()`
`byte[]` `arrayCopy()`
`int` `capacity()`
`void` `close()` Close the stream releasing resources.
`protected void` `copyAndShift(Object src, long off, int len)` Copy source object to the stream shift position afterwards.
`void` `ensureCapacity(int cnt)` Ensure capacity.
`boolean` `hasArray()`
`void` `unsafeWriteByte(byte val)` Write byte in unsafe mode.
`void` `unsafeWriteChar(char val)` Write char 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.
`protected void` `writeByteAndShift(byte val)` Write next byte to the stream.
`protected void` `writeCharFast(char val)` Write char value (fast path).
`protected void` `writeIntFast(int val)` Write int value (fast path).
`protected void` `writeLongFast(long val)` Write long value (fast path).
`protected void` `writeShortFast(short val)` Write short value (fast path).

### Methods inherited from class org.apache.ignite.internal.binary.streams.BinaryAbstractOutputStream

`capacity, offheapPointer, position, rawOffheapPointer, unsafeEnsure, unsafePosition, unsafeWriteBoolean, unsafeWriteDouble, unsafeWriteFloat, write, write, writeBoolean, writeBooleanArray, writeByte, writeByteArray, writeChar, writeCharArray, writeDouble, writeDoubleArray, writeFloat, writeFloatArray, writeInt, writeInt, writeIntArray, writeLong, writeLongArray, writeShort, writeShort, writeShortArray`

### Methods inherited from class org.apache.ignite.internal.binary.streams.BinaryAbstractStream

`position, shift`

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

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

### Methods inherited from interface org.apache.ignite.internal.binary.streams.BinaryStream

`position`

### Constructor Detail

#### BinaryHeapOutputStream

    public BinaryHeapOutputStream(int cap)

Constructor.

Parameters:
  `cap` - Initial capacity.

#### BinaryHeapOutputStream

    public BinaryHeapOutputStream(int cap,
                                  BinaryMemoryAllocatorChunk chunk)

Constructor.

Parameters:
  `cap` - Capacity.
  `chunk` - Chunk.

### Method Detail

#### close

    public void close()

Close the stream releasing resources.

#### ensureCapacity

    public void ensureCapacity(int cnt)

Ensure capacity.

Specified by:
  `ensureCapacity` in class `BinaryAbstractOutputStream`
Parameters:
  `cnt` - Required byte count.

#### array

    public byte[] array()

Returns:
  Underlying array.

#### arrayCopy

    public byte[] arrayCopy()

Returns:
  Copy of data in the stream.

#### hasArray

    public boolean hasArray()

Returns:
  `True` is stream is array based.

#### writeByteAndShift

    protected void writeByteAndShift(byte val)

Write next byte to the stream.

Specified by:
  `writeByteAndShift` in class `BinaryAbstractOutputStream`
Parameters:
  `val` - Value.

#### copyAndShift

    protected void copyAndShift(Object src,
                                long off,
                                int len)

Copy source object to the stream shift position afterwards.

Specified by:
  `copyAndShift` in class `BinaryAbstractOutputStream`
Parameters:
  `src` - Source.
  `off` - Offset.
  `len` - Length.

#### writeShortFast

    protected void writeShortFast(short val)

Write short value (fast path).

Specified by:
  `writeShortFast` in class `BinaryAbstractOutputStream`
Parameters:
  `val` - Short value.

#### writeCharFast

    protected void writeCharFast(char val)

Write char value (fast path).

Specified by:
  `writeCharFast` in class `BinaryAbstractOutputStream`
Parameters:
  `val` - Char value.

#### writeIntFast

    protected void writeIntFast(int val)

Write int value (fast path).

Specified by:
  `writeIntFast` in class `BinaryAbstractOutputStream`
Parameters:
  `val` - Int value.

#### writeLongFast

    protected void writeLongFast(long val)

Write long value (fast path).

Specified by:
  `writeLongFast` in class `BinaryAbstractOutputStream`
Parameters:
  `val` - Long value.

#### unsafeWriteByte

    public void unsafeWriteByte(byte val)

Write byte in unsafe mode.

Parameters:
  `val` - Value.

#### unsafeWriteShort

    public void unsafeWriteShort(short val)

Write short in unsafe mode.

Parameters:
  `val` - Value.

#### unsafeWriteShort

    public void unsafeWriteShort(int pos,
                                 short val)

Write short in unsafe mode.

Parameters:
  `pos` - Position.
  `val` - Value.

#### unsafeWriteChar

    public void unsafeWriteChar(char val)

Write char in unsafe mode.

Parameters:
  `val` - Value.

#### unsafeWriteInt

    public void unsafeWriteInt(int val)

Write int in unsafe mode.

Parameters:
  `val` - Value.

#### unsafeWriteInt

    public void unsafeWriteInt(int pos,
                               int val)

Write int in unsafe mode.

Parameters:
  `pos` - Position.
  `val` - Value.

#### unsafeWriteLong

    public void unsafeWriteLong(long val)

Write long in unsafe mode.

Parameters:
  `val` - Value.

#### capacity

    public int capacity()

Returns:
  Total capacity.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021