#index #indexing #bits #bitvector

indexed_bitvec

An indexed bitvector with (hopefully) fast rank and select operations

6 stable releases

✓ Uses Rust 2018 edition

4.0.1 Jan 13, 2019
2.4.0 Jan 1, 2019
2.3.0 Dec 24, 2018
2.0.0 Jul 22, 2018

#198 in Algorithms

Download history 367/week @ 2019-12-07 1/week @ 2019-12-14 4/week @ 2019-12-21 8/week @ 2019-12-28 101/week @ 2020-01-11 17/week @ 2020-01-18 2/week @ 2020-01-25 1/week @ 2020-02-01 9/week @ 2020-02-08 9/week @ 2020-02-15 37/week @ 2020-02-22 2/week @ 2020-02-29 14/week @ 2020-03-07 8/week @ 2020-03-14 39/week @ 2020-03-21

177 downloads per month
Used in packed_integer_array

Apache-2.0

130KB
3K SLoC

Indexed Bitvector

Build status Latest version Documentation

This library provides an indexing system for bitvectors which should hopefully allow fast rank and select operations.

This library is based on the design proposed by Zhou, Andersen and Kaminsky in Space–Efficient, High–Performance Rank & Select Structures on Uncompressed Bit Sequences.

Timings

Timings were made:

  • Using criterion for the timing
  • For a 1GB vector (slightly larger in fact)
  • Compiled in release mode
  • With LTO, codegen-units 1, non-incremental build
  • With RUSTFLAGS='-C target-cpu=native'
  • CPU: Intel® Core™ i7-7700K CPU @ 4.20GHz
Operation Time
build_index ~200ms
count ~2ns
rank ~55ns
select ~110ns

The use of target-cpu is likely to have a significant effect on the speed of the operations as it allows llvm & rust to use vectorisation & popcount instructions that might be available, so consider working out how to compile for the specific cpu you want to run the program on.

The timing of building the index has not been left in the code, as criterion does so many iterations to time it that it makes running the benchmarks take 15 minutes.

See also

I think there is an implementation of the same approach in a Haskell succinct vector library.

Zhou, Andersen and Kaminsky. Space–Efficient, High–Performance Rank & Select Structures on Uncompressed Bit Sequences

Dependencies

~0.6–1MB
~25K SLoC