Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tagless Encodings

Tagless encodings may be specified by encoding tags in template placeholders and in tagless-element sequences. In binary, this allows the opcode to be elided from the encoding of values that fill tagless slots.

Consider the following data:

[
  { sum: 123, sample_count: 12 },
  { sum: 54, sample_count: 8 },
  { sum: 125, sample_count: 15 },
  { sum: 314, sample_count: 30 },
]

With a macro such as (metric {sum: (:? {#int}), sample_count: (:? {#int}), unit: ms}), it can be encoded using a tagless-element list as follows

[{:metric} // {:<macro_name>} specifies a macro-shape
  (123 12),
  (54 8),
  (125 15),
  (314 30),
]

The available tagless encodings are enumerated in the following table.

Ion TypeEncoding NameSize in bytesBinary Encoding TagEncoding
intintvariable0x60[FlexInt][flexint]
int810x61[FixedInt][fixedint]
int1620x62[FixedInt][fixedint]
int3240x64[FixedInt][fixedint]
int6480x68[FixedInt][fixedint]
uintvariable0xE0[FlexUInt][flexuint]
uint810xE1[FixedUInt][fixeduint]
uint1620xE2[FixedUInt][fixeduint]
uint3240xE4[FixedUInt][fixeduint]
uint6480xE8[FixedUInt][fixeduint]
floatfloat1620x6B[Little-endian IEEE-754 half-precision float][f16]
float3240x6C[Little-endian IEEE-754 single-precision float][f32]
float6480x6D[Little-endian IEEE-754 double-precision float][f64]
decimalsmall_decimalvariable (2+)0x70Tuple of (int,int8) representing the coefficient and exponent respectively.
timestamptimestamp_day20x82[Day precision timestamp][t1]
timestamp_min40x83[Minute precision timestamp][t2]
timestamp_s50x84[Second precision timestamp][t3]
timestamp_ms60x85[Millisecond precision timestamp][t4]
timestamp_us70x86[Microsecond precision timestamp][t5]
timestamp_ns80x87[Nanosecond precision timestamp][t6]
symbolsymbolvariable0xEE[FlexSym][flexsym]

Although both primitive and macro-shape encodings may be used in tagless-element sequences, only the primitive encodings in the above table may be used in tagless template placeholders.