Skip to content

Repository files navigation

RoaringBitmap for .NET

This is a fairly simple port of the Java bitmap library RoaringBitmap by Daniel Lemire et al. You can find the original version here: https://github.com/lemire/RoaringBitmap Most of the algorithms are ports of the original Java algorithms. This is an early version, the test coverage is ok, but edge case tests are probably missing. Target Framework is .NET 4.6

Details

  • Immutable data structure using readonly fields and private constructors, so it's thread-safe
  • Overloaded operators for AND, OR, NOT and XOR
  • Support for the Set Difference Operator using RoaringBitmap.AndNot

NuGet

https://www.nuget.org/packages/RoaringBitmap/

TODO

  • Add RunContainer support

How to use it?

Compile the RoaringBitmap.sln and use 'RoaringBitmap.Create' to create your bitmap, then use bitwise operations on it.

varrb=RoaringBitmap.Create(1,2,3,4,5,7,8,9,10);varrb2=RoaringBitmap.Create(Enumerable.Range(10000,200000));varrb3=rb|rb2;

Performance

As this is a fairly direct port of the immutable part of the Java Version of RoaringBitmap we can directly compare the Java Benchmark with this version, both benchmarks are equivalent and are also used for the Unit Testing to make sure they are actually doing the same. The CensusIncome dataset shows slightly faster performance numbers than the Java version. The Census1881 dataset is, except for AND, quite a bit faster than the Java version.

BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Core(TM) i7-4790K CPU 4.00GHz, ProcessorCount=8
Frequency=3906246 Hz, Resolution=256.0003 ns, Timer=TSC
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1586.0
DefaultJob : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1586.0
Type=MicroBenchmarkCensusIncome Mode=Throughput
MethodMeanStdDevGen 0Allocated
Or2.2688 ms0.0042 ms846.87503.89 MB
Xor2.3919 ms0.0073 ms872.91673.96 MB
And2.2721 ms0.0031 ms233.33331.32 MB
AndNot2.3636 ms0.0040 ms517.18752.49 MB
Iterate89.4243 ms0.0203 ms-43.52 kB
BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Core(TM) i7-4790K CPU 4.00GHz, ProcessorCount=8
Frequency=3906246 Hz, Resolution=256.0003 ns, Timer=TSC
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1586.0
DefaultJob : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1586.0
Type=MicroBenchmarkCensus1881 Mode=Throughput 
MethodMeanStdDevGen 0Gen 1Allocated
Or234.7337 us0.1643 us82.4219-392.01 kB
Xor194.7747 us3.3360 us88.0859-392.01 kB
And65.8376 us0.3064 us5.7617-35.42 kB
AndNot156.3676 us0.0581 us73.437510.4167330.47 kB
Iterate10,166.3848 us7.7011 us--68.35 kB

The Java output from the recent 0.6.32-SNAPSHOT version looks like this:

# JMH 1.17 (released 47 days ago)# VM version: JDK 1.8.0_112, VM 25.112-b15# VM invoker: C:\Program Files\Java\jre1.8.0_112\bin\java.exe# VM options: -DBITMAP_TYPES=ROARING_ONLY# Warmup: 5 iterations, 1 s each# Measurement: 5 iterations, 1 s each# Timeout: 10 min per iteration# Threads: 1 thread, will synchronize iterations# Benchmark mode: Average time, time/op
MethodDatasetScore / ErrorUnits
Andcensus-income2251,305 ± 34,711us/op
Andcensus188153,618 ± 0,603us/op
AndNotcensus-income2829,971 ± 5,168us/op
AndNotcensus1881474,517 ± 6,497us/op
Orcensus-income2916,778 ± 3,628us/op
Orcensus1881748,054 ± 15,839us/op
Xorcensus-income2845,861 ± 18,825us/op
Xorcensus1881811,914 ± 1,656us/op

About

.NET Implementation of RoaringBitmap

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages