A C++ implementation with Python bindings of StreamVByte.
Project description
Table of Contents
About The Project
libstreamvbyte
is a C++
implementation of StreamVByte, with Python
bindings using pybind11
.
StreamVByte is a integer compression technique that use SIMD instructions (vectorization) to improve performance. The library is optimized for CPUs with the SSSE3
instruction set (which is supported by most x86_64 processors), and can also be used with ARM processors and other 32-bit architectures, although it will fall back to scalar implementations in those cases.
With libstreamvbyte
, you can quickly and efficiently compress integer sequences, reducing the amount of storage space and network bandwidth required. The library is easy to use and integrates seamlessly with Python
via pybind11
bindings. Whether you're working with large datasets or building a distributed computing system, libstreamvbyte
can help you improve performance and reduce the resources needed to handle your data.
Currently supports Python 3.10+
on Windows, Linux (manylinux_2_17
, musllinux_1_1
) and macOS (universal2
).
Getting Started
Installation
For Python
Install from PyPI
using pip
.
pip install libstreamvbyte
Or install from .whl
file.
pip install "path/to/your/downloaded/whl"
To find appropriate .whl
file, please visit releases.
For C++
You must have CMake
installed on your system.
# clone the repo
git clone https://github.com/wst24365888/libstreamvbyte
cd libstreamvbyte
# build and install
cmake .
make
sudo make install
Usage
For Python
Import libstreamvbyte
first.
import libstreamvbyte as svb
And here are the APIs.
# Encode an array of unsigned integers into a byte array.
encode(arg0: numpy.ndarray[numpy.uint32]) -> numpy.ndarray[numpy.uint8]
# Decode a byte array into an array of unsigned integers.
decode(arg0: numpy.ndarray[numpy.uint8], arg1: int) -> numpy.ndarray[numpy.uint32]
# Encode an array of signed integers into an array of unsigned integers.
encode_zigzag(arg0: numpy.ndarray[numpy.int32]) -> numpy.ndarray[numpy.uint32]
# Decode an array of unsigned integers into an array of signed integers.
decode_zigzag(arg0: numpy.ndarray[numpy.uint32]) -> numpy.ndarray[numpy.int32]
For C++
Include streamvbyte.h
first.
#include "streamvbyte.h"
For the APIs, please refer to include/streamvbyte.h.
Example
For Python
import libstreamvbyte as svb
N = 2**20 + 2
# type(original_data) == np.ndarray
# original_data.dtype == np.int32
original_data = np.random.randint(-2**31, 2**31, N, dtype=np.int32)
# type(compressed_bytes) == np.ndarray
# compressed_bytes.dtype == np.uint8
compressed_bytes = svb.encode(svb.encode_zigzag(original_data))
# type(recovered_data) == np.ndarray
# recovered_data.dtype == np.int32
recovered_data = svb.decode_zigzag(svb.decode(compressed_bytes, N))
For C++
#include "streamvbyte.h"
int main() {
std::size_t N = (1 << 20) + 2;
std::vector<int32_t> original_data(N);
for (std::size_t i = 0; i < N; ++i) {
original_data[i] = rand() - rand();
}
std::vector<uint8_t> compressed_bytes = streamvbyte::encode(streamvbyte::encode_zigzag(original_data));
std::vector<int32_t> recovered_data = streamvbyte::decode_zigzag(streamvbyte::decode(compressed_bytes, N));
return 0;
}
Compile it with linking to libstreamvbyte
.
g++ -o example example.cpp -lstreamvbyte
Roadmap
- Zigzag encoding/decoding.
- Support ARM processors with
NEON
intrinsics. - Differential coding (delta encoding/decoding).
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feat/amazing-feature
) - Commit your Changes with Conventional Commits
- Push to the Branch (
git push origin feat/amazing-feature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE for more information.
Reference
- Daniel Lemire, Nathan Kurz, Christoph Rupp, Stream VByte: Faster Byte-Oriented Integer Compression, Information Processing Letters 130, 2018.
Contact
Author
- HSING-HAN, WU (Xyphuz)
- Mail me: xyphuzwu@gmail.com
- About me: https://www.xyphuz.com
- GitHub: https://github.com/wst24365888
Project Link
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file libstreamvbyte-0.2.2.tar.gz
.
File metadata
- Download URL: libstreamvbyte-0.2.2.tar.gz
- Upload date:
- Size: 762.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 452d6da1990a989a59df8aa5e4270171abd39ce5c99a9437f5acafe9f2f51882 |
|
MD5 | 6df8b8ebbd13286216bbca2d025fc0ae |
|
BLAKE2b-256 | fc1d6b22718dae2fb2b62b2484fa37f854b5c4aad2ead661905134e06647a2af |
File details
Details for the file libstreamvbyte-0.2.2-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 58.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93679bd8ad8eb1406295edd8afe9c103bc2f258a75c02bd24fe0da4f728a15da |
|
MD5 | 9e8d336a5d7aec71d7b0a5ae0beb20bb |
|
BLAKE2b-256 | 88b5a8bf05a5766bce1fdbd0ceac01c1b13e242e4331147893c0f2e10d189aee |
File details
Details for the file libstreamvbyte-0.2.2-cp311-cp311-win32.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp311-cp311-win32.whl
- Upload date:
- Size: 46.3 kB
- Tags: CPython 3.11, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08adbe4cf31e1d480d1de1a42de5c2930a51cf7feb0cace8804156d7133f26ef |
|
MD5 | d6c8e09f4941f9905a25abc912661b72 |
|
BLAKE2b-256 | 124022cd27f09850d2148f970b3982899d39dedbeb6ccf96dd46ef0610d87010 |
File details
Details for the file libstreamvbyte-0.2.2-cp311-cp311-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp311-cp311-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 604.9 kB
- Tags: CPython 3.11, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9337181403acbf28d61aa8fd25b321ed4539c4ba1d135c63e29a17f7d9ec1ba |
|
MD5 | c3ce4dd9fd2cc9b819433387488c3256 |
|
BLAKE2b-256 | 18f19f0ddafdf7f18f70eda4c08a309f844ae960c0faf2e893e99fe685a82d0d |
File details
Details for the file libstreamvbyte-0.2.2-cp311-cp311-musllinux_1_1_i686.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp311-cp311-musllinux_1_1_i686.whl
- Upload date:
- Size: 660.9 kB
- Tags: CPython 3.11, musllinux: musl 1.1+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbee843cd4fe7ddaf5a835b20d071cbc2c8101973b071a93270260e36666279c |
|
MD5 | 78c29306d40613662c6c1dcb96d33564 |
|
BLAKE2b-256 | c2f3060f8f40296d309037d1d44fa137e5bdb03da173c743f6d53bc3026e9f5e |
File details
Details for the file libstreamvbyte-0.2.2-cp311-cp311-musllinux_1_1_aarch64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp311-cp311-musllinux_1_1_aarch64.whl
- Upload date:
- Size: 586.0 kB
- Tags: CPython 3.11, musllinux: musl 1.1+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3522e32f24993d30d502db5411d14ea03f2f6f8367eb38500076a096609bc5a0 |
|
MD5 | 7e3d123ca872ab39560eb06a451f5746 |
|
BLAKE2b-256 | c9962308c0e4b62935981ed066ffef30aae7922172c94a64d7f694ec46873813 |
File details
Details for the file libstreamvbyte-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 80.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c31f3641290686d0306b6e5b8172b9297f52743ad9ee563dfe95164ec5357665 |
|
MD5 | 9e02af912f4dae944c4048a40f28f0a5 |
|
BLAKE2b-256 | b5646169dc716f4ca8e009760c629ce30d51456bd999c86f33551d1fa39651df |
File details
Details for the file libstreamvbyte-0.2.2-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 85.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 406e64c192f7bbfc6b2856f668019587a4f38fba4daf244b6c9da5398b5a7ef2 |
|
MD5 | 4ad6f21fb2eef11444e0131cae274c1e |
|
BLAKE2b-256 | 3b4ee8998243aad0157a6b93ba422474ed317b71528948835cb3ca3ad2bd0e9f |
File details
Details for the file libstreamvbyte-0.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 74.9 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a40bba32e3eeb26afa978df00ad087d355c55cd512f94dd0fb0f2ef947e259d |
|
MD5 | 47f2b1ec8bdb68a16e1edbd35ee9832b |
|
BLAKE2b-256 | de4c9c80cac5e04e36092cc925235b540af3f3356fb451ced43749af4c4e8497 |
File details
Details for the file libstreamvbyte-0.2.2-cp311-cp311-macosx_10_9_universal2.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 102.3 kB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 805c63ce9551848e952bb82a72e60eb1b9346ae558386b7402d8ea28977fccce |
|
MD5 | e30e7ad0f386e29088916fdf8a293c67 |
|
BLAKE2b-256 | 1c5d4b99927d3d94307bbb74b16b2130277b1acbe9f46928e7cc6068cc5ed2ed |
File details
Details for the file libstreamvbyte-0.2.2-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 58.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58d9b48bf358cb54d1359b92c0165535e811aa1fd93c68640d7ecfe78d3b5012 |
|
MD5 | 16c9dbed78a37430c4f4136dd4c52759 |
|
BLAKE2b-256 | 5e5dc1b9c40a5efa618b1d6dd6ce12fa6da0ad46fb58a0014a670652f43faedd |
File details
Details for the file libstreamvbyte-0.2.2-cp310-cp310-win32.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp310-cp310-win32.whl
- Upload date:
- Size: 46.3 kB
- Tags: CPython 3.10, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3da9a4f042c994a25802eb64605fa5ba9bad7f615b556775a34e2bcce656ca95 |
|
MD5 | c7117f8556355c096c878a4081cc38ae |
|
BLAKE2b-256 | 1442608e4cb7007d5fd16c336d1adac7233194077a1fa2062153b69973ddb8ef |
File details
Details for the file libstreamvbyte-0.2.2-cp310-cp310-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp310-cp310-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 604.9 kB
- Tags: CPython 3.10, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3e7dae7e4bfb28f388d5617ec0ad1a5d97cc58f19f863e93d4a445798ccb628 |
|
MD5 | 5e32eb1048a1ee138c39f54f81aeb9a4 |
|
BLAKE2b-256 | 3cb4bd02f18b783227e2676dda43ca65de47612cde2b9239f8e9d97a79bf218e |
File details
Details for the file libstreamvbyte-0.2.2-cp310-cp310-musllinux_1_1_i686.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp310-cp310-musllinux_1_1_i686.whl
- Upload date:
- Size: 660.9 kB
- Tags: CPython 3.10, musllinux: musl 1.1+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a62e34f92a1d0ecaee3c1b4e89feac188d404417513d169cdcee4e4eb8a56a5 |
|
MD5 | a7de45a19c3a16172736b18c7d2f2abe |
|
BLAKE2b-256 | ac4f33467e28915eecd2114b41d2272ce25c4c6471b6d45b614cb37cded05c94 |
File details
Details for the file libstreamvbyte-0.2.2-cp310-cp310-musllinux_1_1_aarch64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp310-cp310-musllinux_1_1_aarch64.whl
- Upload date:
- Size: 586.0 kB
- Tags: CPython 3.10, musllinux: musl 1.1+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe5d0d2ac8b97f67450dca8b59c9464c53857704ca392901a80d5e3e661cf690 |
|
MD5 | 0b648e7563bbf3be3b94401e67111898 |
|
BLAKE2b-256 | dac35acfe6c1e444cf30686a5df7761cb44312565a524f141d69fd20830ff068 |
File details
Details for the file libstreamvbyte-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 80.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8001ac4d088685f3cde8d03b55455988b2022fa6add3a9e35e2e43f2f8bf175 |
|
MD5 | d02d3c074edaa36ff2ed167b6ed25218 |
|
BLAKE2b-256 | 10cd832e9a5b451fb41f151000db0141b61b3e6f3179e7a009ba2edad81c771f |
File details
Details for the file libstreamvbyte-0.2.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 85.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8225fbfb6a199370ea1ef4e6130e527cc28fa130d1f246a7fc9a559c240ba29 |
|
MD5 | fc3a59da8f0cf67d3b8f7c2b19493841 |
|
BLAKE2b-256 | d426dce86bc9d8e95d70cb7ddb7a139e7e1b596405f51b9615a312b105f0a4a5 |
File details
Details for the file libstreamvbyte-0.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 74.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d72c3a781b2a7f689b204ca6dab88d1d46ceb0fab4a3202ed57c4a1db34b9fe |
|
MD5 | fc1dcdf20509f98777222b0bb9783582 |
|
BLAKE2b-256 | 080ebf1f6da2ffb7f20939a63cb0713c6eeab6ca9f25ad6a50219e652a63196a |
File details
Details for the file libstreamvbyte-0.2.2-cp310-cp310-macosx_10_9_universal2.whl
.
File metadata
- Download URL: libstreamvbyte-0.2.2-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 102.3 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 204817b4621da4be7f265e15eec06b6b92273bcb3afcdbc84fc39bb8aa350fb3 |
|
MD5 | 70f51492c12a9239af159d753b703611 |
|
BLAKE2b-256 | 92ce740ae02721b0e5abdfa244736206f9eff4bfa81e64e32f61a4747238ed24 |