Registers

zio.blocks.schema.binding.Registers
See theRegisters companion object
class Registers

The mutable storage that Constructors and Deconstructors read and write: a byte area for primitive values and an object area for references. A value's position is a RegisterOffset: the getters and setters for primitives use its byte part as the index into the byte area, and getObject and setObject use its object part as the index into the object area. Primitives are stored as raw little-endian bytes, without boxing.

Registers(usedRegisters) allocates both areas at the sizes that usedRegisters gives. The setters grow an area when a value does not fit. The getters never grow an area: a position must be inside an area before it is read, and on the JVM reading beyond an area throws an IndexOutOfBoundsException. A position that was allocated but never written reads as 0, false or null.

A Registers is not thread-safe. The JSON reader and writer each keep one as a stack of record frames, so the JSON codec does not allocate registers for each record.

import zio.blocks.schema.binding._

val registers = Registers(RegisterOffset(objects = 1, ints = 1))
registers.setObject(RegisterOffset.Zero, "Zionomicon")
registers.setInt(RegisterOffset(objects = 1), 2021)
val title = registers.getObject(RegisterOffset.Zero)     // "Zionomicon"
val year  = registers.getInt(RegisterOffset(objects = 1)) // 2021

Attributes

See also
Companion
object
Source
Registers.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def clearObjects(offset: RegisterOffset): Unit

Sets the object slots from 0 up to, but not including, the object slot of offset to null, so this instance no longer holds those references. The byte area is not changed.

Sets the object slots from 0 up to, but not including, the object slot of offset to null, so this instance no longer holds those references. The byte area is not changed.

Attributes

Source
Registers.scala
def getBoolean(offset: RegisterOffset): Boolean

Reads the Boolean at the byte position of offset: true for any byte other than 0.

Reads the Boolean at the byte position of offset: true for any byte other than 0.

Attributes

Source
Registers.scala
def getByte(offset: RegisterOffset): Byte

Reads the Byte at the byte position of offset.

Reads the Byte at the byte position of offset.

Attributes

Source
Registers.scala
def getChar(offset: RegisterOffset): Char

Reads the Char at the byte position of offset.

Reads the Char at the byte position of offset.

Attributes

Source
Registers.scala
def getDouble(offset: RegisterOffset): Double

Reads the Double at the byte position of offset.

Reads the Double at the byte position of offset.

Attributes

Source
Registers.scala
def getFloat(offset: RegisterOffset): Float

Reads the Float at the byte position of offset.

Reads the Float at the byte position of offset.

Attributes

Source
Registers.scala
def getInt(offset: RegisterOffset): Int

Reads the Int at the byte position of offset.

Reads the Int at the byte position of offset.

Attributes

Source
Registers.scala
def getLong(offset: RegisterOffset): Long

Reads the Long at the byte position of offset.

Reads the Long at the byte position of offset.

Attributes

Source
Registers.scala
def getObject(offset: RegisterOffset): AnyRef

Reads the reference in the object slot of offset.

Reads the reference in the object slot of offset.

Attributes

Source
Registers.scala
def getShort(offset: RegisterOffset): Short

Reads the Short at the byte position of offset.

Reads the Short at the byte position of offset.

Attributes

Source
Registers.scala
def setBoolean(offset: RegisterOffset, value: Boolean): Unit

Writes value at the byte position of offset, as 1 for true and 0 for false, and grows the byte area first when it is too small.

Writes value at the byte position of offset, as 1 for true and 0 for false, and grows the byte area first when it is too small.

Attributes

Source
Registers.scala
def setByte(offset: RegisterOffset, value: Byte): Unit

Writes value as a Byte at the byte position of offset, taking 1 byte, and grows the byte area first when it is too small.

Writes value as a Byte at the byte position of offset, taking 1 byte, and grows the byte area first when it is too small.

Attributes

Source
Registers.scala
def setChar(offset: RegisterOffset, value: Char): Unit

Writes value as a Char at the byte position of offset, taking 2 bytes, and grows the byte area first when it is too small.

Writes value as a Char at the byte position of offset, taking 2 bytes, and grows the byte area first when it is too small.

Attributes

Source
Registers.scala
def setDouble(offset: RegisterOffset, value: Double): Unit

Writes value as a Double at the byte position of offset, taking 8 bytes, and grows the byte area first when it is too small.

Writes value as a Double at the byte position of offset, taking 8 bytes, and grows the byte area first when it is too small.

Attributes

Source
Registers.scala
def setFloat(offset: RegisterOffset, value: Float): Unit

Writes value as a Float at the byte position of offset, taking 4 bytes, and grows the byte area first when it is too small.

Writes value as a Float at the byte position of offset, taking 4 bytes, and grows the byte area first when it is too small.

Attributes

Source
Registers.scala
def setInt(offset: RegisterOffset, value: Int): Unit

Writes value as an Int at the byte position of offset, taking 4 bytes, and grows the byte area first when it is too small.

Writes value as an Int at the byte position of offset, taking 4 bytes, and grows the byte area first when it is too small.

Attributes

Source
Registers.scala
def setLong(offset: RegisterOffset, value: Long): Unit

Writes value as a Long at the byte position of offset, taking 8 bytes, and grows the byte area first when it is too small.

Writes value as a Long at the byte position of offset, taking 8 bytes, and grows the byte area first when it is too small.

Attributes

Source
Registers.scala
def setObject(offset: RegisterOffset, value: AnyRef): Unit

Writes value in the object slot of offset, and grows the object area first when it is too small.

Writes value in the object slot of offset, and grows the object area first when it is too small.

Attributes

Source
Registers.scala
def setRegisters(offset: RegisterOffset, registers: Registers): Unit

Copies all of registers into this instance at offset: its whole byte area to the byte position of offset and its whole object area to the object slot of offset, growing the areas here as needed. The whole areas are copied, including any space they grew to, not only the part that was written.

Copies all of registers into this instance at offset: its whole byte area to the byte position of offset and its whole object area to the object slot of offset, growing the areas here as needed. The whole areas are copied, including any space they grew to, not only the part that was written.

Attributes

Source
Registers.scala
def setShort(offset: RegisterOffset, value: Short): Unit

Writes value as a Short at the byte position of offset, taking 2 bytes, and grows the byte area first when it is too small.

Writes value as a Short at the byte position of offset, taking 2 bytes, and grows the byte area first when it is too small.

Attributes

Source
Registers.scala