Smart2Raw
Home Applications How it works Performance Get started

Commercial

Premium Licensing Investment

More

Technical scope Cite About
Get in touch

Get started

There is nothing to install. Smart2Raw is a single C11 header with no dependencies, no build system and no configuration.

Three lines

#include "smart2raw.h"

S2RPool p;
s2r_pool_init(&p, s2r_classify_array(values, n), n);   /* 1. classify */
for (size_t i = 0; i < n; i++) s2r_push(&p, values[i]); /* 2. store    */
size_t k = s2r_count_gt_fast(&p, 100);                  /* 3. operate  */

Compile with anything:

cc -O2 -std=c11 -I include your_program.c -o your_program

Let the library choose the shape

The obvious entry point is not always the right one. On 4 million timestamps the flat pool is 15.26 MB and 0.73 ms where the block-wise form is 4.11 MB and 0.04 ms — so ask before deciding:

S2RAdvice a;
s2r_recommend(values, n, &a);
printf("best: %s, %zu bytes (baseline %zu)\n", a.best, a.best_bytes, a.raw_bytes);

Save and load

S2RBlocked b;
s2r_blocked_build_auto(&b, values, n);   /* block size is planned, not guessed */
s2r_blocked_save(&b, "column.s2r");

The file is canonical little-endian with a CRC32, so it is identical on any host and a corrupted byte is caught on load rather than returned as data.

Downloads

The library

Source, 31 test suites, benchmarks, examples and language bindings.

GitHub →
Zenodo, version 3.5.0 →

The demo, as a single file

The whole library as WebAssembly inside one HTML file. Works offline, over file://, with no server. Nothing you paste into it leaves your machine.

smart2raw-live-en.html →

Windows executable

A console probe with no CRT, no runtime DLL and no installer — twelve kernel32 imports and nothing else. Point it at a CSV column.

s2r-probe.exe →
s2r-probe.exe data.csv --column 3 --save column.s2r

It prints the class chosen, the size against int64 and against dictionary, RLE and bitmap, the timed query, and exits with status 0 only when every internal check passed.

Where it runs

The same file, with the same tests passing: x86-64 with SSE2 and AVX2, ARM with NEON and SVE2, RISC-V with RVV, big-endian machines, and microcontrollers in lean mode (-DS2R_NO_STDIO -DS2R_NO_MMAP -DS2R_NO_SIMD). And, as of this site, in WebAssembly and in a Windows PE linked without a C runtime.

Licence

The published version is under AGPL-3.0-or-later. If you plan to build it into something you do not publish under the same licence, that needs a commercial licence — which is also how you reach the advanced version.