Documentation ¶
Overview ¶
goroar is an implementation of Roaring Bitmaps in Golang. Roaring bitmaps is a new form of compressed bitmaps, proposed by Daniel Lemire et. al., which often offers better compression and fast access than other compressed bitmap approaches.
Example (Goroar) ¶
ExampleGoroar demonstrates how to use the goroar library.
package main import ( "fmt" "github.com/fzandona/goroar" ) func main() { rb1 := goroar.BitmapOf(1, 2, 3, 4, 5) rb2 := goroar.BitmapOf(2, 3, 4) rb3 := goroar.New() fmt.Println("Cardinality: ", rb1.Cardinality()) fmt.Println("Contains 3? ", rb1.Contains(3)) rb1.And(rb2) rb3.Add(1) rb3.Add(5) rb3.Or(rb1) // prints 1, 2, 3, 4, 5 for value := range rb3.Iterator() { fmt.Println(value) } }
Output:
Example (Large) ¶
ExampleLarge demonstrates how to use the goroar library.
package main import ( "fmt" "github.com/fzandona/goroar" ) func main() { rb1 := goroar.New() rb2 := goroar.New() for i := 0; i < 1000000; i += 2 { rb1.Add(uint32(i)) rb2.Add(uint32(i + 1)) } fmt.Println(rb1.Cardinality(), rb2.Cardinality()) rb1.Or(rb2) rb1.Stats() }
Output:
Index ¶
- type RoaringBitmap
- func (rb *RoaringBitmap) Add(x uint32)
- func (rb *RoaringBitmap) And(other *RoaringBitmap)
- func (rb *RoaringBitmap) AndNot(other *RoaringBitmap)
- func (rb *RoaringBitmap) Cardinality() int
- func (rb *RoaringBitmap) Clone() *RoaringBitmap
- func (rb *RoaringBitmap) Contains(i uint32) bool
- func (rb *RoaringBitmap) Iterator() <-chan uint32
- func (rb *RoaringBitmap) Or(other *RoaringBitmap)
- func (rb *RoaringBitmap) SizeInBytes() int
- func (rb *RoaringBitmap) Stats()
- func (rb *RoaringBitmap) String() string
- func (rb *RoaringBitmap) Xor(other *RoaringBitmap)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RoaringBitmap ¶
type RoaringBitmap struct {
// contains filtered or unexported fields
}
func BitmapOf ¶
func BitmapOf(values ...uint32) *RoaringBitmap
BitmapOf generates a new bitmap with the specified values set to true. The provided values don't have to be in sorted order, but it may be preferable to sort them from a performance point of view.
func (*RoaringBitmap) Add ¶
func (rb *RoaringBitmap) Add(x uint32)
Add adds a uint32 value to the RoaringBitmap
func (*RoaringBitmap) And ¶
func (rb *RoaringBitmap) And(other *RoaringBitmap)
And computes the bitwise AND operation. The receiving RoaringBitmap is modified - the input one is not.
func (*RoaringBitmap) AndNot ¶
func (rb *RoaringBitmap) AndNot(other *RoaringBitmap)
AndNot computes the bitwise andNot operation (difference) The receiving RoaringBitmap is modified - the input one is not.
func (*RoaringBitmap) Cardinality ¶
func (rb *RoaringBitmap) Cardinality() int
Cardinality returns the number of distinct integers (uint32) in the bitmap.
func (*RoaringBitmap) Clone ¶
func (rb *RoaringBitmap) Clone() *RoaringBitmap
Clone returns a copy of the original RoaringBitmap
func (*RoaringBitmap) Contains ¶
func (rb *RoaringBitmap) Contains(i uint32) bool
Contains checks whether the value in included, which is equivalent to checking if the corresponding bit is set (get in BitSet class).
func (*RoaringBitmap) Iterator ¶
func (rb *RoaringBitmap) Iterator() <-chan uint32
Iterator returns an iterator over the RoaringBitmap which can be used with "for range".
func (*RoaringBitmap) Or ¶
func (rb *RoaringBitmap) Or(other *RoaringBitmap)
Or computes the bitwise OR operation. The receiving RoaringBitmap is modified - the input one is not.
func (*RoaringBitmap) SizeInBytes ¶
func (rb *RoaringBitmap) SizeInBytes() int
func (*RoaringBitmap) Stats ¶
func (rb *RoaringBitmap) Stats()
Stats prints statistics about the Roaring Bitmap's internals.
func (*RoaringBitmap) String ¶
func (rb *RoaringBitmap) String() string
func (*RoaringBitmap) Xor ¶
func (rb *RoaringBitmap) Xor(other *RoaringBitmap)
Xor computes the bitwise XOR operation. The receiving RoaringBitmap is modified - the input one is not.