Skip to main content

XBin Format Reference

The XBin (XINA Binary) format provides a XINA standard binary format for time based data files. It uses the file extension xbin.

The xbin format organizes key-value data by time. The data content is a series of rows in ascending time order, with each row having a single microsecond precision Unix time, unique within the file.

Segment Format

XBin data is often encoded in segments, which are defined by an initial signed integer byte length, then that number of bytes. These are referred to in this document as:

  • seg1 (up to 127 bytes)
  • seg2 (up to 32,767 bytes)
  • seg4 (up to 2,147,483,647 bytes)

If the length value of a segment is zero there is no following data and the value is considered empty.

Value Format

Each value starts with a 1 byte signed integer indicating the value type, followed by additional byte(s) containing the value itself, as applicable.

Value Type Definition

CodeValueLengthDescription
0null0literal null / empty string
1reference dict indexvariablesee below
2true boolean literal0
3false boolean literal0
41 byte signed integer1
52 byte signed integer2
64 byte signed integer4
78 byte signed integer8
84 byte floating point4
98 byte floating point8
10string1variableseg1 UTF-8 encoded string
11string2variableseg2 UTF-8 encoded string
12string4variableseg4 UTF-8 encoded string
13json1variableseg1 UTF-8 encoded JSON
14json2variableseg2 UTF-8 encoded JSON
15json4variableseg4 UTF-8 encoded JSON
16xstring1variableseg1 xstring
17xstring2variableseg2 xstring
18xstring4variableseg4 xstring
19xjsonarray1variableseg1 xjson array
20xjsonarray2variableseg2 xjson array
21xjsonarray4variableseg4 xjson array
22xjsonobject1variableseg1 xjson array
23xjsonobject2variableseg2 xjson array
24xjsonobject4variableseg4 xjson array
(-128, -1)code dict index0see below

XString Format

The xstring value type allows chaining mutliple encoded values to be interpretted as a string. The xstring segment length must be the total number of bytes of all encoded values in the string.

XJSON Array Format

The xjsonarray value type allows chaining mutliple encoded values to be interpretted as a JSON array. The xjsonarray segment length must be the total number of bytes of all encoded values in the array.

UUID

The file starts with a 16 byte binary encoded UUID. This is intended to uniquely identify the file, but the exact implementation and usage beyond this is not explicitly defined as part of the format definition. For XINA purposes two xbin files with the same UUID would be expected to be identical.

Header

This is followed by a seg4, which contains a single JSON object with UTF-8 encoding. It may be empty. This is currently a placeholder with no defined parameters.

Rows

Each row starts with an 8 byte signed integer containing Unix time with microsecond precision. This is followed by a 4 byte unsigned integer denoting the length of the row in bytes.

Values

Each value starts with a 1 byte unsigned integer indicating the value reference type.

This is followed by a 1 byte unsigned integer indicating the value type.

Value Type Definition

CodeValueDescription
0nullliteral null / empty string
1string value referencesee below
2true boolean literal
3false boolean literal
41 byte signed integer
52 byte signed integer
64 byte signed integer
78 byte signed integer
84 byte floating point
98 byte floating point
10string1seg1 UTF-8 encoded string
11string2seg2 UTF-8 encoded string
12string4seg4 UTF-8 encoded string
13json1seg1 UTF-8 encoded JSON
14json2seg2 UTF-8 encoded JSON
15json4seg4 UTF-8 encoded JSON