Macaw.Data.Operations.Transforms.Ladder.Packed (macaw_data v0.18.0)

View Source

A ladder piece as one binary (spec/04 §4.5.1; macaw_data#38, #46): its segments as fixed-width records, so a partial the caller's cache holds is a few words on its heap, an off-heap binary beside it, and the merge reads buffers rather than terms. The Elixir walk and the native kernel (Ladder.partial/4) answer the same bytes.

The packed form, little-endian throughout:

<<1, s_type, y_type, 0, segments::32, heads::binary-size(8 * segments), buckets::binary>>
  • s_type and y_type: 0 every point's s (or y) an int64, 1 every one a float64 (both 0 with no bucket);
  • a head per segment in row order, 8 bytes: <<0, 0::24, row::32>> a gap, its first row; <<1, 0::24, buckets::32>> a run, its count of buckets;
  • the runs' buckets in order, 88 bytes each: <<b::signed-64>>, then its first, last, least and greatest points, each <<row::32, s::64, y::64>>.

The term form, <<2, external term format of the segments>>, holds a piece whose points are not all of one number type, or past int64 (a log scale's integer bucket, a macaw form's mixed readings): every value is kept exactly, as the walk answered it.

Summary

Types

A piece's segments, as Ladder reads them.

Functions

A piece's segments read as view v's: each gap {:gap, {v, row}} and each bucket {b, {v, summary}}, as Ladder.runs/1 joins them.

A piece's segments as one binary: packed where its points share their types, else as a term.

A piece's segments, as pack/1 was given them.

Types

segments()

@type segments() :: [run: [{integer(), tuple()}], gap: non_neg_integer()]

A piece's segments, as Ladder reads them.

Functions

located(piece, v)

@spec located(binary(), non_neg_integer()) :: list()

A piece's segments read as view v's: each gap {:gap, {v, row}} and each bucket {b, {v, summary}}, as Ladder.runs/1 joins them.

pack(segments)

@spec pack(segments()) :: binary()

A piece's segments as one binary: packed where its points share their types, else as a term.

unpack(piece)

@spec unpack(binary()) :: segments()

A piece's segments, as pack/1 was given them.