From the compressed data, you can later recover the original array quickly (at a rate of millions of integers per second).
// var FastIntegerCompression = require("fastintcompression");// if you use nodevar array = 1010000065999101001120000xFFFFFFFF;var buf = FastIntegerCompression;var back = FastIntegerCompression; // gets back [10,100000,65999,10,10,0,1,1,2000]
By default, non-negative 32-bit integers are expected. If you have signed (negative and positive) 32-bit integers, then you must use distinct functions since we need to code the sign bit:
// var FastIntegerCompression = require("fastintcompression");// if you use nodevar array = 101000006599910100-1-1-2000;var buf = FastIntegerCompression;var back = FastIntegerCompression; // gets back [10,100000,65999,10,10,0,-1,-1,-2000]
You can install the library under node with the command line
npm install fastintcompression
This code is made available under the Apache License 2.0.
This library is meant to compress arrays of small integers. It is not meant to compress text documents or arrays of large (or random) integers.
Go to benchmark repository (check the README.md file) and run the benchmark:
$ node test.jsPlatform: linux 3.13.0-91-generic x64Intel Core i7-4770 CPU @ 3.40GHzNode version 4.5.0, v8 version 184.108.40.206input size: 7.813K compressed size: 1000BFastIntegerCompression.compress x 337,845 ops/sec ±0.93%Fastest is FastIntegerCompression.compressFastIntegerCompression.uncompress x 187,694 ops/sec ±0.72%Fastest is FastIntegerCompression.uncompress
These numbers means that we can uncompress 187,694 1000-integer arrays per second. That's 187 millions of integers per second.
You might also like...
If you like this library, you might also like