• Stars
    star
    40
  • Rank 680,660 (Top 14 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C++ library to pack and unpack vectors of integers having a small range of values using a technique called Frame of Reference

Frame of Reference (FOR) C++ library

What is this?

C++ library to pack and unpack vectors of integers having a small range of values using a technique called Frame of Reference (Goldstein et al. 1998). It should run fast even though it is written in simple C++.

Code from this library is part Apache Arrow and Apache Impala.

Code usage :

Given an array of 32-bit integers, you can compress it as follows:

#include "compression.h"

...

uint32_t * inputdata = ... // length values
uint32_t * compresseddata = ... // enough data
uint32_t *out = compress(inputdata, length, compresseddata);
// compressed data lies between compresseddata and out
uint32_t nvalue = 0;
uint32_t * recoverydata = ... // available buffer with at least length elements
uncompress(compresseddata, recoverydata, nvalue);
// nvalue will be equal to length

There is a similar API with turbocompress and turbouncompress with the difference that compresseddata uses an uint8_t pointer type.

#include "turbocompression.h"

...

uint32_t * inputdata = ... // length values
uint8_t * compresseddata = ... // enough data
uint8_t *out = turbocompress(inputdata, length, compresseddata);
// compressed data lies between compresseddata and out
uint32_t nvalue = 0;
uint32_t * recoverydata = ... // available buffer with at least length elements
turbouncompress(compresseddata, recoverydata, nvalue);
// nvalue will be equal to length

We can also compress 64-bit arrays:

#include "turbocompression.h"

...

uint64_t * inputdata = ... // length values
uint8_t * compresseddata = ... // enough data
uint8_t *out = turbocompress64(inputdata, length, compresseddata);
// compressed data lies between compresseddata and out
uint32_t nvalue = 0;
uint64_t * recoverydata = ... // available buffer with at least length elements
turbouncompress64(compresseddata, recoverydata, nvalue);
// nvalue will be equal to length

Usage (with Makefile)

To run a simple benchmark, do

 make
 ./test sampledata.txt

where sampledata.txt is a text data file with one integer per line.

For a parallelized version, type

 make testmp
 ./testmp sampledata.txt

This requires OpenMP support however.

Building (with CMake under macOS and Linux)

You need to have cmake installed and available as a command.

 mkdir release
 cd release
 cmake ..
 make
 make test

Building (Visual Studio under Windows)

We are assuming that you have a common Windows PC with at least Visual Studio 2015, and an x64 processor.

To build with at least Visual Studio 2015 from the command line:

  • Grab the FrameOfReference code from GitHub, e.g., by cloning it using GitHub Desktop.
  • Install CMake. When you install it, make sure to ask that cmake be made available from the command line.
  • Create a subdirectory within FrameOfReference, such as VisualStudio.
  • Using a shell, go to this newly created directory. For example, within GitHub Desktop, you can right-click on Β FrameOfReference in your GitHub repository list, and select Open in Git Shell, then type cd VisualStudio in the newly created shell.
  • Type cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. in the shell while in the VisualStudio repository.
  • This last command created a Visual Studio solution file in the newly created directory (e.g., FrameOfReference.sln). Open this file in Visual Studio. You should now be able to build the project and run the tests. For example, in the Solution Explorer window (available from the View menu), right-click ALL_BUILD and select Build. To test the code, still in the Solution Explorer window, select RUN_TESTS and select Build.

To build with at least Visual Studio 2017 directly in the IDE:

  • Grab the FrameOfReference code from GitHub, e.g., by cloning it using GitHub Desktop.
  • Select the Visual C++ tools for CMake optional component when installing the C++ Development Workload within Visual Studio.
  • Within Visual Studio use File > Open > Folder... to open the FrameOfReference folder.
  • Right click on CMakeLists.txt in the parent directory within Solution Explorer and select Build to build the project.
  • For testing, in the Standard toolbar, drop the Select Startup Item... menu and choose one of the tests. Run the test by pressing the button to the left of the dropdown.

Requirements:

This was tested with GNU G++ and clang++ After suitable adjustments, it should build under most C++ compilers.

Other relevant libraries

References

  • Daniel Lemire, Nathan Kurz, Christoph Rupp, Stream VByte: Faster Byte-Oriented Integer Compression, Information Processing Letters (to appear) https://arxiv.org/abs/1709.08990
  • Goldstein J, Ramakrishnan R, Shaft U. Compressing relations and indexes. Proceedings of the Fourteenth International Conference on Data Engineering, ICDE ’98, IEEE Computer Society: Washington, DC, USA, 1998; 370–379.
  • Daniel Lemire and Leonid Boytsov, Decoding billions of integers per second through vectorization, Software Practice & Experience 45 (1), 2015. http://arxiv.org/abs/1209.2137 http://onlinelibrary.wiley.com/doi/10.1002/spe.2203/abstract
  • Daniel Lemire, Leonid Boytsov, Nathan Kurz, SIMD Compression and the Intersection of Sorted Integers, Software Practice & Experience 46 (6), 2016. http://arxiv.org/abs/1401.6399
  • Jeff Plaisance, Nathan Kurz, Daniel Lemire, Vectorized VByte Decoding, International Symposium on Web Algorithms 2015, 2015. http://arxiv.org/abs/1503.07387
  • Wayne Xin Zhao, Xudong Zhang, Daniel Lemire, Dongdong Shan, Jian-Yun Nie, Hongfei Yan, Ji-Rong Wen, A General SIMD-based Approach to Accelerating Compression Algorithms, ACM Transactions on Information Systems 33 (3), 2015. http://arxiv.org/abs/1502.01916
  • Jianguo Wang, Chunbin Lin, Yannis Papakonstantinou, Steven Swanson, An Experimental Study of Bitmap Compression vs. Inverted List Compression, SIGMOD 2017 http://db.ucsd.edu/wp-content/uploads/2017/03/sidm338-wangA.pdf

More Repositories

1

FastPFor

The FastPFOR C++ library: Fast integer compression
C++
876
star
2

Code-used-on-Daniel-Lemire-s-blog

This is a repository for the code posted on my blog
C
720
star
3

fast_double_parser

Fast function to parse strings into double (binary64) floating-point values, enforces the RFC 7159 (JSON standard) grammar: 4x faster than strtod
C++
574
star
4

javaewah

A compressed alternative to the Java BitSet class
Java
560
star
5

JavaFastPFOR

A simple integer compression library in Java
Java
505
star
6

simdcomp

A simple C library for compressing lists of integers using binary packing
C
480
star
7

EWAHBoolArray

A compressed bitmap class in C++.
C++
430
star
8

SIMDCompressionAndIntersection

A C++ library to compress and intersect sorted lists of integers using SIMD instructions
C++
420
star
9

fastbase64

SIMD-accelerated base64 codecs
C
388
star
10

streamvbyte

Fast integer compression in C using the StreamVByte codec
C
372
star
11

FastPriorityQueue.js

a fast heap-based priority queue in JavaScript
JavaScript
328
star
12

fastvalidate-utf-8

header-only library to validate utf-8 strings at high speeds (using SIMD instructions)
C
286
star
13

fastrange

A fast alternative to the modulo reduction
C
272
star
14

fastmod

A C/C++ header file for fast 32-bit division remainders (and divisibility tests) on 64-bit hardware.
C++
264
star
15

clhash

C library implementing the ridiculously fast CLHash hashing function
C
256
star
16

externalsortinginjava

External-Memory Sorting in Java
Java
248
star
17

rollinghashcpp

Rolling Hash C++ Library
C++
185
star
18

FastBitSet.js

Speed-optimized BitSet implementation for modern browsers and JavaScript engines
JavaScript
150
star
19

docker_programming_station

A simple script to help programmers who want to work within Docker
Shell
142
star
20

despacer

C library to remove white space from strings as fast as possible
C
133
star
21

StronglyUniversalStringHashing

Benchmark showing the we can randomly hash strings very quickly with good universality
C++
133
star
22

testingRNG

Testing common random-number generators (RNG)
C++
131
star
23

MaskedVByte

Fast decoder for VByte-compressed integers
C
115
star
24

cbitset

A simple bitset library in C
C
110
star
25

lbimproved

Dynamic Time Warping (DTW) library implementing lower bounds (LB_Keogh, LB_Improved...)
C++
105
star
26

dictionary

High-performance dictionary coding
C++
99
star
27

SIMDxorshift

Fast random number generators: Vectorized (SIMD) version of xorshift128+
C
99
star
28

csharpewah

Compressed bitmaps in C#
C#
82
star
29

fastrand

Fast random number generation in an interval in Python: Up to 10x faster than random.randint.
C
77
star
30

bloofi

Bloofi: A java implementation of multidimensional Bloom filters
Java
75
star
31

rollinghashjava

Rolling hash functions in Java
Java
75
star
32

LittleIntPacker

C library to pack and unpack short arrays of integers as fast as possible
C
70
star
33

simdpcg

Vectorized version of the PCG random number generator
C
68
star
34

TypedFastBitSet.js

Speed-optimized BitSet implementation for modern browsers and JavaScript engines, uses typed arrays
TypeScript
67
star
35

FastIntegerCompression.js

Fast integer compression library in JavaScript
JavaScript
54
star
36

simdprune

Pruning elements in SIMD vectors (i.e., packing left elements)
C
50
star
37

testingmlp

Testing memory-level parallelism
C
49
star
38

FastDifferentialCoding

Fast differential coding functions (using SIMD instructions)
C
49
star
39

multiplatform_simd_recipes

SIMD recipes, for various platforms (collection of code snippets)
C
43
star
40

runningmaxmin

Fast maximum-minimum filters implemented in C++
C++
43
star
41

validateutf8-experiments

Reproducible experimeents on UTF-8 validation using SIMD instructions
C++
40
star
42

fasthashing

A Variable-Length String Hashing Library in C++
C++
40
star
43

fast_division

Simple C++ code to benchmark fast division algorithms
C++
40
star
44

SwiftBitset

A fast Bitset class in Swift
Swift
36
star
45

FastShuffleExperiments

How fast can we shuffle values?
C++
33
star
46

programmingishard

Long-term book project
32
star
47

StablePriorityQueue.js

A stable heap-based priority queue in JavaScript
JavaScript
27
star
48

fastscancount

Fast implementations of the scancount algorithm: C++ header-only library
C++
24
star
49

SIMDgameoflife

Vectorized (AVX) version of the game of life
C
23
star
50

CMemoryUsage

Measuring memory usage in C and C++
C
23
star
51

CRoaringUnityBuild

Dumps of CRoaring unity builds (for convenience)
C
23
star
52

SwiftWyhash

Fast random number generator in pure Swift
Swift
23
star
53

kodakimagecollection

Set of images made available royalty-free by Kodak
22
star
54

sparsebitmap

A simple sparse bitmap implementation in java
Java
21
star
55

IndexWikipedia

A simple utility to index wikipedia dumps using Lucene.
Java
21
star
56

PiecewiseLinearTimeSeriesApproximation

code from Daniel Lemire, A Better Alternative to Piecewise Linear Time Series Segmentation, SIAM Data Mining 2007, 2007.
C++
21
star
57

Concise

C++ implementation of Concise and WAH compressed bitsets
C++
19
star
58

MemoryLanes

iOS app to test memory-level parallelism
C++
18
star
59

fastrandom

Go
18
star
60

crackingxoroshiro128plus

How to "crack" xoroshiro128+: from two outputs, derive a possible seed
Python
18
star
61

talks

Random material having to do with Daniel Lemire's talks
C++
18
star
62

RealisticTabularDataSets

Some realistic tabular datasets for testing (CSV)
17
star
63

StarSchemaBenchmark

O'Neil et al.'s Star Schema Benchmark: curated code
C
16
star
64

vectorclass

Random number generator for large applications using vector instructions
C++
15
star
65

simple_fastfloat_benchmark

C
15
star
66

simplebitmapbenchmark

Simple benchmark between compressed bitmap libraries in Java
Java
15
star
67

zobristhashing

Zobrist hashing in C
C
14
star
68

BitSliceIndex

Experiments on bit-slice indexing
Java
14
star
69

SIMDIntersections

Vectorized intersections (research code)
C++
14
star
70

microbenchmarks

Private microbenchmarks
Java
13
star
71

backward_multiplication

Multiplying... backward?
C++
12
star
72

pospopcnt_avx512

benchmarking positional population count
Assembly
11
star
73

costofsafety

Quick experiment to see how expensive safety is in C, for research
C
11
star
74

constantdivisionbenchmarks

Benchmarks for constant-division problems (not a library! for research only!)
C++
11
star
75

createfasthash

Code from article http://locklessinc.com/articles/fast_hash/
C
9
star
76

SwiftCallingCHeader

Calling a C header from Swift (example)
Swift
8
star
77

arraylayout

Pat Morin's arraylayout
TeX
8
star
78

WebAssemblyVSJavaScript

Project to compare the performance of WebAssembly with JavaScript
JavaScript
7
star
79

rowreorderingcpplibrary

This is a set of row-reordering algorithms and data compression compression schemes implemented in C++.
C++
7
star
80

ComputerLanguageBenchmark

Captured as http://benchmarksgame.alioth.debian.org is closing
HTML
7
star
81

fastheap

Fast heap data structures in Go (golang)
Go
6
star
82

iosbitmapdecoding

Experimenting with bitmap decoding on ios
C++
6
star
83

notesdecours

Notes de cours
Java
6
star
84

gutenberg-headers

Removing Manually-Generated Boilerplate from Project Gutenberg e-Books
Java
6
star
85

gobitmapbenchmark

A Go project to benchmark various bitmap implementations (this is not a library!)
Go
6
star
86

citationdata

Influential references dataset
6
star
87

simple_simdjson_python_wrapper

Simple use of simdjson from python (for research purposes)
C++
6
star
88

pythonmaxmin

Fast minimum-maximal filter in Python
Python
6
star
89

jstypes

Doing C-like arithmetic and logical operations in JavaScript (full 64-bit support)
JavaScript
5
star
90

hierarchicalbinbuffering

Hierarchical Bin Buffering C++ Library
C++
5
star
91

fast_float_supplemental_tests

Supplemental tests for the fast_float library (credit: Nigel Tao)
C++
5
star
92

HashVSTree

Do hash table use more memory than trees? A case study in Java.
Java
5
star
93

zone_benchmarks

zone-file parsing benchmark
C
5
star
94

DivisionBenchmark

A not-so-exciting benchmark to measure the performance of some division functions
C++
4
star
95

RoaringVSConciseBenchmark

A benchmark comparing roaring and concise
Java
4
star
96

exercices_lucene

Exercises pour s'approprier lucene, le moteur de recherche
Java
4
star
97

roaring_rust_benchmark

Basic benchmark to compare different Roaring bitmap implementations in Rust
Rust
4
star
98

datasciencebook

Python
4
star
99

viewsizeestimation

Unassuming hashing-based view-size estimation techniques
C++
4
star
100

jackson-json-bench

A silly benchmark for Jackson (JSON parser)
Java
4
star