ToonEx.Btoon.ObjectTable (toon_ex v1.3.1)

Copy Markdown View Source

A columnar table of homogeneous numeric columns (tag 0x0D).

An object table is the binary equivalent of the TOON tabular array form: each column holds the raw buffer for one field, decoded in bulk. Decoding with typed_arrays: :views returns this struct; otherwise rows are materialised as a list of maps.

Examples

iex> table = Btoon.ObjectTable.from_rows([%{"x" => 1, "y" => 2.5}, %{"x" => 3, "y" => 4.5}])
iex> Btoon.ObjectTable.rows(table)
[%{"x" => 1, "y" => 2.5}, %{"x" => 3, "y" => 4.5}]

Summary

Functions

Returns the column definitions.

Builds an object table from a list of maps. All maps must share the same keys and every column must be homogeneous numeric (Btoon.Types.encodable).

Row count of the table.

Materialises the table as a list of maps.

Types

t()

@type t() :: %ToonEx.Btoon.ObjectTable{
  columns: [ToonEx.Btoon.ObjectTable.Column.t()],
  row_count: non_neg_integer()
}

Functions

columns(object_table)

@spec columns(t()) :: [ToonEx.Btoon.ObjectTable.Column.t()]

Returns the column definitions.

from_rows(rows)

@spec from_rows([%{optional(String.t()) => term()}]) :: t()

Builds an object table from a list of maps. All maps must share the same keys and every column must be homogeneous numeric (Btoon.Types.encodable).

row_count(object_table)

@spec row_count(t()) :: non_neg_integer()

Row count of the table.

rows(object_table)

@spec rows(t()) :: [%{optional(String.t()) => term()}]

Materialises the table as a list of maps.