XDelta Compression Format

Overview

The XINA Delta (xd) compression format is a simple, high performance format for compression and decompression of a list of numeric values into a string. The compression is most efficient for data sets with frequently repeated values, or predictable value iterations.

The format consists of a few main features:

Format Grammar

The version 1 (v1) format grammar is defined here. Note: whitespace is not permitted in the format.

string

version

parameters

parameter

delta

blank

scalar

offset

all_values

values

value

blank_value

nonblank_value

number

integer

pos_integer

neg_integer

digits

digit

onenine

fraction

exponent

sign

Version

The version denotes the encoded format for backwards compatibility, in case of future updates or changes. If the string does not include the version, it is assumed to be version 0, which is detailed at the end of this document.

Blanks

The blank parameter indicates how blank (empty) values should be interpretted. 'br' (the default) repeats the previous encoded literal value. 'b' number assigns a static numeric value. 'bn' assigns the null value. 'br' will be the most efficient in most cases, unless the majority of a data set is a single value. The format is considered invalid if more than one blank parameter is specified.

Given the data set:

A br encoding would be:

A b0 encoding would be:

Which can be further reduced to:

Note, in this example, the first value must still be explicitly specified, per the first value non-blank rule.

Delta

The delta parameter defines the behavior for storing values as changing relative to the previous value. This can either be 'd0' (disabling the feature), 'd1' (the default, change from previous value), or 'd2' (change of change from previous value). The format is considered invalid if more than one delta parameter is specified.

Given the simple data set:

The d1 encoding would be:

Which, with br, can be reduced to:

Which can be further reduced to

The d2 encoding would be:

Which can be further reduced to:

Note that in d1 encoding, the first value is not a delta but a static value. Likewise, in d2, the first value is static, and the second is the delta relative to the first.

When dealing with null values, the delta rules simply ignore any null values, carrying state from the previous non-null value. For example, given the data set:

The d1 encoding would be:

Which can be further reduced to

Delta Considerations for Fractional Values

When using the delta feature with fractional values, errors may be introduced into the data, depending on the encoding and decoding environments and implementation, particularly with regard with how floating point data is handled. Because each value is computed based on the previous on, the potential for error increases across the data set. For this reason, when working with fractional values it is strongly recommended to used a fixed precision context, by chosing an adequate static precision at encode time and embedding it with the scalar value, described below. Alternatively, the file can be encoded with the d0 delta setting, disabling the feature. This can still provide significant compression benefit if the data set contains many repeated values.

Scalar / Offset

The scalar and offset parameters allow repetitive data to be further reduced. A single scalar value can be specified to either multiply ('*') or divide ('/') each value by, followed by a single positive ('+') or negative ('-') offset value. The scalar is always applied first, followed by the offset. The format is considered invalid if more than one scalar or more than one offset is present. These represent the operations to perform at decode time, so they are inversed during encoding. Note that a /0 scalar is invalid.

For example, given the data set:

50.0, 50.1, 50.3, 50.2, 49.9, 50.1

We can use a /10 scalar and +50 offset to encode as follows:

v1,d1,/10,+50:0,1,2,-1,-3,2

Note that each delta operation is relative to the previous untransformed value.

Values

There are six possible values:

Note that the first value of the full value set must not be blank (or repeated blanks), to preserve the ability to define an empty data set. That is, the strings:

"v1:", "v1,b0:"

Both denote a data set with no values.

Decoding Order of Operations

Implementation

We provide a reference encode / decode implementation in Java, TypeScript, and Python. Because the encoding process is very fast, multiple formats can usually be tested to find a reasonably optimal solution automatically.

General Recommendations

Changelog

Version 1

Version 0

For reference the v0 grammar (note, number, scalar, and offset formats remain unchanged from v1 grammar):

v0_string

v0_parameters

v0_parameter

v0_delta

v0_blank

v0_all_values

v0_values

v0_value

v0_repeater


Revision #17
Created 11 February 2026 20:09:19 by Nick Dobson
Updated 1 July 2026 03:16:40 by Nick Dobson