org.apache.ignite.internal.binary.streams

## Class BinaryAbstractOutputStream

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

All Implemented Interfaces:
  AutoCloseable, BinaryOutputStream, BinaryStream

Direct Known Subclasses:
  BinaryHeapOutputStream, BinaryOffheapOutputStream

    public abstract class BinaryAbstractOutputStream
    extends BinaryAbstractStream
    implements BinaryOutputStream

Base binary output stream.

### Field Summary

Fields
`protected static int` `MAX_ARRAY_SIZE` The maximum size of array to allocate.

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

`BYTE_ONE, BYTE_ZERO, pos`

### Constructor Summary

Constructors
Constructor and Description
`BinaryAbstractOutputStream()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`protected static int` `capacity(int curCap, int reqCap)` Calculate new capacity.
`protected abstract void` `copyAndShift(Object src, long off, int len)` Copy source object to the stream shift position afterwards.
`protected abstract void` `ensureCapacity(int cnt)` Ensure capacity.
`long` `offheapPointer()`
`void` `position(int pos)`
`long` `rawOffheapPointer()`
`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` `unsafeWriteDouble(double val)` Write double in unsafe mode.
`void` `unsafeWriteFloat(float val)` Write float 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.
`protected abstract void` `writeByteAndShift(byte val)` Write next byte to the stream.
`void` `writeByteArray(byte[] val)` Write byte array.
`void` `writeChar(char val)` Write char value.
`void` `writeCharArray(char[] val)` Write char array.
`protected abstract void` `writeCharFast(char val)` Write char value (fast path).
`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.
`protected abstract void` `writeIntFast(int val)` Write int value (fast path).
`void` `writeLong(long val)` Write long value.
`void` `writeLongArray(long[] val)` Write long array.
`protected abstract void` `writeLongFast(long val)` Write long value (fast path).
`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.
`protected abstract void` `writeShortFast(short val)` Write short value (fast path).

### 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.BinaryOutputStream

`close, unsafeWriteByte, unsafeWriteChar, unsafeWriteInt, unsafeWriteInt, unsafeWriteLong, unsafeWriteShort, unsafeWriteShort`

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

`array, arrayCopy, capacity, hasArray, position`

### Field Detail

#### MAX_ARRAY_SIZE

    protected static final int MAX_ARRAY_SIZE

The maximum size of array to allocate. Some VMs reserve some header words in an array. Attempts to allocate larger arrays may result in OutOfMemoryError: Requested array size exceeds VM limit

See Also:
  `ArrayList.MAX_ARRAY_SIZE`, Constant Field Values

### Constructor Detail

#### BinaryAbstractOutputStream

    public BinaryAbstractOutputStream()

### 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.

#### 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.

#### writeIntArray

    public void writeIntArray(int[] val)

Write int array.

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

#### 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 void position(int pos)

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

#### 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`.

#### 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.

#### unsafeWriteBoolean

    public void unsafeWriteBoolean(boolean val)

Write boolean in unsafe mode.

Specified by:
  `unsafeWriteBoolean` 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.

#### capacity

    protected static int capacity(int curCap,
                                  int reqCap)

Calculate new capacity.

Parameters:
  `curCap` - Current capacity.
  `reqCap` - Required capacity.
Returns:
  New capacity.

#### writeByteAndShift

    protected abstract void writeByteAndShift(byte val)

Write next byte to the stream.

Parameters:
  `val` - Value.

#### copyAndShift

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

Copy source object to the stream shift position afterwards.

Parameters:
  `src` - Source.
  `off` - Offset.
  `len` - Length.

#### writeShortFast

    protected abstract void writeShortFast(short val)

Write short value (fast path).

Parameters:
  `val` - Short value.

#### writeCharFast

    protected abstract void writeCharFast(char val)

Write char value (fast path).

Parameters:
  `val` - Char value.

#### writeIntFast

    protected abstract void writeIntFast(int val)

Write int value (fast path).

Parameters:
  `val` - Int value.

#### writeLongFast

    protected abstract void writeLongFast(long val)

Write long value (fast path).

Parameters:
  `val` - Long value.

#### ensureCapacity

    protected abstract void ensureCapacity(int cnt)

Ensure capacity.

Parameters:
  `cnt` - Required byte count.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.6
Release Date | : September 11 2019