ArraySchema

class ArraySchema<T>(val elementSchema: FateSchema<T>) : FateSchema<Array<T>>

A schema for arrays of T, written as a 4-byte element count followed by each element.

List, Set and Collection fields use the same format, so a List<Double> field has the same bytes as a Double[] field. Kotlin's primitive arrays have their own schemas (DoubleArraySchema and friends) that write the same bytes without boxing.

Binary format

The schema:

[4 bytes: tag] [element schema blob]

An encoded array:

[4 bytes: element count N] [element1] [element2] ... [elementN]

Constructors

Link copied to clipboard
constructor(elementSchema: FateSchema<T>)

Properties

Link copied to clipboard
Link copied to clipboard
open override val schema: ByteArray

The schema definition as bytes, which the writer puts in the log.

Link copied to clipboard
open override val schemaSize: Int

Number of bytes in this schema's definition.

Link copied to clipboard
open override val tag: Int

The integer that identifies this schema's type in the log.

Functions

Link copied to clipboard
open override fun encodeObject(buffer: ByteBuffer, obj: Array<T>)

Writes the given object into the buffer.

Link copied to clipboard
open fun encodeSchema(buffer: ByteBuffer)

Writes the whole schema definition, starting with the tag, into the buffer.

Link copied to clipboard
open override fun objSize(obj: Array<T>): Int

Returns the number of bytes encodeObject writes for the given object.