|
1 | | -# FastPFor |
| 1 | +# FastPFor for Rust |
2 | 2 |
|
3 | 3 | [](https://github.com/jjcfrancisco/fastpfor) |
4 | 4 | [](https://crates.io/crates/fastpfor) |
5 | 5 | [](https://docs.rs/fastpfor) |
6 | | -[](https://github.com/jjcfrancisco/fastpfor/blob/main/LICENSE-APACHE) |
| 6 | +[](https://github.com/jjcfrancisco/fastpfor/blob/main/LICENSE-APACHE) |
7 | 7 | [](https://github.com/jjcfrancisco/fastpfor/actions) |
8 | 8 |
|
9 | | -FastPFOR library written in Rust. |
| 9 | +This is a Rust wrapper for the [C++ FastPFor library](https://github.com/fast-pack/FastPFor), as well as a pure Rust re-implementation (work in progress). Supports 32-bit and 64-bit integers, and SIMD-optimized codecs for 128-bit and 256-bit vectors. Based on the [Decoding billions of integers per second through vectorization, 2012](https://arxiv.org/abs/1209.2137) paper. |
10 | 10 |
|
11 | | -## Requirements |
| 11 | +### Supported algorithms |
| 12 | +Unless otherwise specified, all codecs support `&[u32]` only. |
| 13 | +* BP32 |
| 14 | +* Copy |
| 15 | +* FastBinaryPacking8 |
| 16 | +* FastPFor128 (both `&[u32]` and `&[u64]`) |
| 17 | +* FastPFor256 (both `&[u32]` and `&[u64]`) |
| 18 | +* FastBinaryPacking16 |
| 19 | +* FastBinaryPacking32 |
| 20 | +* MaskedVByte |
| 21 | +* NewPFor |
| 22 | +* OptPFor |
| 23 | +* PFor2008 |
| 24 | +* PFor |
| 25 | +* SimdBinaryPacking |
| 26 | +* SimdFastPFor128 |
| 27 | +* SimdFastPFor256 |
| 28 | +* SimdGroupSimple |
| 29 | +* SimdGroupSimpleRingBuf |
| 30 | +* SimdNewPFor |
| 31 | +* SimdOptPFor |
| 32 | +* SimdPFor |
| 33 | +* SimdSimplePFor |
| 34 | +* Simple16 |
| 35 | +* Simple8b |
| 36 | +* Simple8bRle |
| 37 | +* Simple9 |
| 38 | +* Simple9Rle |
| 39 | +* SimplePFor |
| 40 | +* StreamVByte |
| 41 | +* VByte |
| 42 | +* VarInt (both `&[u32]` and `&[u64]`) |
| 43 | +* VarIntGb |
12 | 44 |
|
13 | | -# MacOS |
14 | | -To build FastPFor on macOS, you'll need to install SIMDe. Since Homebrew installs packages in /opt/homebrew (for Apple Silicon), you'll also need to explicitly set the include paths. |
| 45 | +## Usage |
| 46 | + |
| 47 | +### Crate Features |
| 48 | +* `cpp` - C++ implementation (default) |
| 49 | +* `rust` - Rust implementation (work in progress, opt-in) |
| 50 | + |
| 51 | +### Using C++ Wrapper |
| 52 | + |
| 53 | +```rust |
| 54 | +use fastpfor::cpp::{Codec32 as _, SimdFastPFor128Codec}; |
| 55 | + |
| 56 | +fn main() { |
| 57 | + let mut codec = SimdFastPFor128Codec::new(); |
| 58 | + |
| 59 | + // Encode |
| 60 | + let mut input = vec![1, 2, 3, 4, 5]; |
| 61 | + let mut output = vec![0; 10]; // must be large enough |
| 62 | + let enc_slice = codec.encode32(&input, &mut output).unwrap(); |
| 63 | + |
| 64 | + // Decode |
| 65 | + let mut decoded = vec![0; 10]; // must be large enough |
| 66 | + let dec_slice = codec.decode32(&enc_slice, &mut decoded).unwrap(); |
| 67 | + |
| 68 | + assert_eq!(input, dec_slice); |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +## Build Requirements |
| 73 | + |
| 74 | +When using the Rust implementation, no additional dependencies are required. |
| 75 | +When using the C++ implementation, you need to have a C++ compiler that supports C++14 and SIMD intrinsics. See [FastPFor C++ requirements](https://github.com/fast-pack/FastPFor?tab=readme-ov-file#software-requirements). |
| 76 | + |
| 77 | +### Linux |
| 78 | +The default GitHub action runner for Linux has all the needed dependencies. For local development, you may need to install the following packages. |
| 79 | + |
| 80 | +```bash |
| 81 | +# This list may be incomplete |
| 82 | +sudo apt-get install build-essential libsimde-dev |
| 83 | +``` |
| 84 | + |
| 85 | +### macOS |
| 86 | +To build FastPFor on macOS, you'll need to install SIMDe. Since Homebrew installs packages in `/opt/homebrew` (for Apple Silicon), you'll also need to explicitly set the include paths. |
15 | 87 |
|
16 | | -First, install SIMDe via Homebrew: |
17 | 88 | ```bash |
| 89 | +# install SIMDe via Homebrew |
18 | 90 | brew install simde |
19 | 91 | ``` |
20 | | -Then, ensure the compiler can find the required headers by setting: |
| 92 | + |
21 | 93 | ```bash |
| 94 | +# Ensure the compiler can find the required headers before building |
22 | 95 | export CXXFLAGS="-I/opt/homebrew/include" |
23 | 96 | export CFLAGS="-I/opt/homebrew/include" |
24 | 97 | ``` |
25 | 98 |
|
26 | | -## To do: |
27 | | -- [ x ] Rust wrapper for the [C++ library](https://github.com/fast-pack/FastPFor): try [`cxxbridge`](https://github.com/dtolnay/cxx) or [`bindgen`](https://crates.io/crates/bindgen) |
28 | | - |
29 | 99 | ## License |
30 | 100 |
|
31 | 101 | Licensed under either of |
|
0 commit comments