Documentation
¶
Overview ¶
Package roaring is an implementation of Roaring Bitmaps in Go. They provide fast compressed bitmap data structures (also called bitset). They are ideally suited to represent sets of integers over relatively small ranges. See http://roaringbitmap.org for details.
Index ¶
- Constants
- func BoundSerializedSizeInBytes(cardinality uint64, universeSize uint64) uint64
- type Bitmap
- func And(x1, x2 *Bitmap) *Bitmap
- func AndNot(x1, x2 *Bitmap) *Bitmap
- func BitmapOf(dat ...uint32) *Bitmap
- func FastAnd(bitmaps ...*Bitmap) *Bitmap
- func FastOr(bitmaps ...*Bitmap) *Bitmap
- func Flip(bm *Bitmap, rangeStart, rangeEnd uint64) *Bitmap
- func FlipInt(bm *Bitmap, rangeStart, rangeEnd int) *Bitmap
- func HeapOr(bitmaps ...*Bitmap) *Bitmap
- func HeapXor(bitmaps ...*Bitmap) *Bitmap
- func New() *Bitmap
- func NewBitmap() *Bitmap
- func Or(x1, x2 *Bitmap) *Bitmap
- func Xor(x1, x2 *Bitmap) *Bitmap
- func (rb *Bitmap) Add(x uint32)
- func (rb *Bitmap) AddInt(x int)
- func (rb *Bitmap) AddMany(dat []uint32)
- func (rb *Bitmap) AddRange(rangeStart, rangeEnd uint64)
- func (rb *Bitmap) And(x2 *Bitmap)
- func (rb *Bitmap) AndCardinality(x2 *Bitmap) uint64
- func (rb *Bitmap) AndNot(x2 *Bitmap)
- func (rb *Bitmap) CheckedAdd(x uint32) bool
- func (rb *Bitmap) CheckedRemove(x uint32) bool
- func (rb *Bitmap) Clear()
- func (rb *Bitmap) Clone() *Bitmap
- func (rb *Bitmap) Contains(x uint32) bool
- func (rb *Bitmap) ContainsInt(x int) bool
- func (rb *Bitmap) Equals(o interface{}) bool
- func (rb *Bitmap) Flip(rangeStart, rangeEnd uint64)
- func (rb *Bitmap) FlipInt(rangeStart, rangeEnd int)
- func (rb *Bitmap) FromBase64(str string) (int64, error)
- func (rb *Bitmap) GetCardinality() uint64
- func (rb *Bitmap) GetCopyOnWrite() (val bool)
- func (rb *Bitmap) GetSerializedSizeInBytes() uint64
- func (rb *Bitmap) GetSizeInBytes() uint64
- func (rb *Bitmap) Intersects(x2 *Bitmap) bool
- func (rb *Bitmap) IsEmpty() bool
- func (rb *Bitmap) Iterator() IntIterable
- func (rb *Bitmap) MarshalBinary() ([]byte, error)
- func (rb *Bitmap) Or(x2 *Bitmap)
- func (rb *Bitmap) OrCardinality(x2 *Bitmap) uint64
- func (rb *Bitmap) Rank(x uint32) uint64
- func (rb *Bitmap) ReadFrom(stream io.Reader) (int64, error)
- func (rb *Bitmap) ReadFromMsgpack(stream io.Reader) (int64, error)
- func (rb *Bitmap) Remove(x uint32)
- func (rb *Bitmap) RemoveRange(rangeStart, rangeEnd uint64)
- func (rb *Bitmap) RunOptimize()
- func (rb *Bitmap) Select(x uint32) (uint32, error)
- func (rb *Bitmap) SetCopyOnWrite(val bool)
- func (bm *Bitmap) Stats() Statistics
- func (rb *Bitmap) String() string
- func (rb *Bitmap) ToArray() []uint32
- func (rb *Bitmap) ToBase64() (string, error)
- func (rb *Bitmap) UnmarshalBinary(data []byte) error
- func (rb *Bitmap) WriteTo(stream io.Writer) (int64, error)
- func (rb *Bitmap) WriteToMsgpack(stream io.Writer) (int64, error)
- func (rb *Bitmap) Xor(x2 *Bitmap)
- type IntIterable
- type RunIterator16
- func (ri *RunIterator16) Cur() uint16
- func (z *RunIterator16) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *RunIterator16) EncodeMsg(en *msgp.Writer) (err error)
- func (ri *RunIterator16) HasNext() bool
- func (z *RunIterator16) MarshalMsg(b []byte) (o []byte, err error)
- func (z *RunIterator16) Msgsize() (s int)
- func (ri *RunIterator16) Next() uint16
- func (ri *RunIterator16) Remove() uint16
- func (z *RunIterator16) UnmarshalMsg(bts []byte) (o []byte, err error)
- type RunIterator32
- func (ri *RunIterator32) Cur() uint32
- func (z *RunIterator32) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *RunIterator32) EncodeMsg(en *msgp.Writer) (err error)
- func (ri *RunIterator32) HasNext() bool
- func (z *RunIterator32) MarshalMsg(b []byte) (o []byte, err error)
- func (z *RunIterator32) Msgsize() (s int)
- func (ri *RunIterator32) Next() uint32
- func (ri *RunIterator32) Remove() uint32
- func (z *RunIterator32) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Statistics
Constants ¶
const MaxUint16 = 65535
MaxUint16 is the largest 16 bit unsigned int. This is the largest value an interval16 can store.
const MaxUint32 = 4294967295
MaxUint32 is the largest uint32 value.
Variables ¶
This section is empty.
Functions ¶
func BoundSerializedSizeInBytes ¶ added in v0.2.1
BoundSerializedSizeInBytes returns an upper bound on the serialized size in bytes assuming that one wants to store "cardinality" integers in [0, universe_size)
Types ¶
type Bitmap ¶ added in v0.2.0
type Bitmap struct {
// contains filtered or unexported fields
}
Bitmap represents a compressed bitmap where you can add integers.
func FastAnd ¶
FastAnd computes the intersection between many bitmaps quickly Compared to the And function, it can take many bitmaps as input, thus saving the trouble of manually calling "And" many times.
func FastOr ¶
FastOr computes the union between many bitmaps quickly, as opposed to having to call Or repeatedly. It might also be faster than calling Or repeatedly.
func Flip ¶
Flip negates the bits in the given range (i.e., [rangeStart,rangeEnd)), any integer present in this range and in the bitmap is removed, and any integer present in the range and not in the bitmap is added, a new bitmap is returned leaving the current bitmap unchanged. The function uses 64-bit parameters even though a Bitmap stores 32-bit values because it is allowed and meaningful to use [0,uint64(0x100000000)) as a range while uint64(0x100000000) cannot be represented as a 32-bit value.
func HeapOr ¶ added in v0.1.1
HeapOr computes the union between many bitmaps quickly using a heap. It might be faster than calling Or repeatedly.
func HeapXor ¶ added in v0.1.1
HeapXor computes the symmetric difference between many bitmaps quickly (as opposed to calling Xor repeated). Internally, this function uses a heap. It might be faster than calling Xor repeatedly.
func NewBitmap ¶ added in v0.2.0
func NewBitmap() *Bitmap
NewBitmap creates a new empty Bitmap (see also New)
func (*Bitmap) AddInt ¶ added in v0.2.0
AddInt adds the integer x to the bitmap (convenience method: the parameter is casted to uint32 and we call Add)
func (*Bitmap) AddRange ¶ added in v0.2.0
AddRange adds the integers in [rangeStart, rangeEnd) to the bitmap. The function uses 64-bit parameters even though a Bitmap stores 32-bit values because it is allowed and meaningful to use [0,uint64(0x100000000)) as a range while uint64(0x100000000) cannot be represented as a 32-bit value.
func (*Bitmap) And ¶ added in v0.2.0
And computes the intersection between two bitmaps and stores the result in the current bitmap
func (*Bitmap) AndCardinality ¶ added in v0.2.0
AndCardinality returns the cardinality of the intersection between two bitmaps, bitmaps are not modified
func (*Bitmap) AndNot ¶ added in v0.2.0
AndNot computes the difference between two bitmaps and stores the result in the current bitmap
func (*Bitmap) CheckedAdd ¶ added in v0.2.0
CheckedAdd adds the integer x to the bitmap and return true if it was added (false if the integer was already present)
func (*Bitmap) CheckedRemove ¶ added in v0.2.0
CheckedRemove removes the integer x from the bitmap and return true if the integer was effectively remove (and false if the integer was not present)
func (*Bitmap) Clear ¶ added in v0.2.0
func (rb *Bitmap) Clear()
Clear removes all content from the Bitmap and frees the memory
func (*Bitmap) Contains ¶ added in v0.2.0
Contains returns true if the integer is contained in the bitmap
func (*Bitmap) ContainsInt ¶ added in v0.2.0
ContainsInt returns true if the integer is contained in the bitmap (this is a convenience method, the parameter is casted to uint32 and Contains is called)
func (*Bitmap) Equals ¶ added in v0.2.0
Equals returns true if the two bitmaps contain the same integers
func (*Bitmap) Flip ¶ added in v0.2.0
Flip negates the bits in the given range (i.e., [rangeStart,rangeEnd)), any integer present in this range and in the bitmap is removed, and any integer present in the range and not in the bitmap is added. The function uses 64-bit parameters even though a Bitmap stores 32-bit values because it is allowed and meaningful to use [0,uint64(0x100000000)) as a range while uint64(0x100000000) cannot be represented as a 32-bit value.
func (*Bitmap) FlipInt ¶ added in v0.2.0
FlipInt calls Flip after casting the parameters (convenience method)
func (*Bitmap) FromBase64 ¶ added in v0.2.0
FromBase64 deserializes a bitmap from Base64
func (*Bitmap) GetCardinality ¶ added in v0.2.0
GetCardinality returns the number of integers contained in the bitmap
func (*Bitmap) GetCopyOnWrite ¶ added in v0.2.4
GetCopyOnWrite gets this bitmap's copy-on-write property
func (*Bitmap) GetSerializedSizeInBytes ¶ added in v0.2.0
GetSerializedSizeInBytes computes the serialized size in bytes of the Bitmap. It should correspond to the number of bytes written when invoking WriteTo
func (*Bitmap) GetSizeInBytes ¶ added in v0.2.0
GetSizeInBytes estimates the memory usage of the Bitmap. Note that this might differ slightly from the amount of bytes required for persistent storage
func (*Bitmap) Intersects ¶ added in v0.2.0
Intersects checks whether two bitmap intersects, bitmaps are not modified
func (*Bitmap) IsEmpty ¶ added in v0.2.0
IsEmpty returns true if the Bitmap is empty (it is faster than doing (GetCardinality() == 0))
func (*Bitmap) Iterator ¶ added in v0.2.0
func (rb *Bitmap) Iterator() IntIterable
Iterator creates a new IntIterable to iterate over the integers contained in the bitmap, in sorted order
func (*Bitmap) MarshalBinary ¶ added in v0.2.6
MarshalBinary implements the encoding.BinaryMarshaler interface for the bitmap
func (*Bitmap) Or ¶ added in v0.2.0
Or computes the union between two bitmaps and stores the result in the current bitmap
func (*Bitmap) OrCardinality ¶ added in v0.2.0
OrCardinality returns the cardinality of the union between two bitmaps, bitmaps are not modified
func (*Bitmap) Rank ¶ added in v0.2.0
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be GetCardinality())
func (*Bitmap) ReadFrom ¶ added in v0.2.0
ReadFrom reads a serialized version of this bitmap from stream
func (*Bitmap) ReadFromMsgpack ¶ added in v0.3.0
ReadFromMsgpack reads a msgpack2/snappy-streaming serialized version of this bitmap from stream
func (*Bitmap) RemoveRange ¶ added in v0.2.0
RemoveRange removes the integers in [rangeStart, rangeEnd) from the bitmap. The function uses 64-bit parameters even though a Bitmap stores 32-bit values because it is allowed and meaningful to use [0,uint64(0x100000000)) as a range while uint64(0x100000000) cannot be represented as a 32-bit value.
func (*Bitmap) RunOptimize ¶ added in v0.3.0
func (rb *Bitmap) RunOptimize()
RunOptimize attempts to further compress the runs of consecutive values found in the bitmap
func (*Bitmap) SetCopyOnWrite ¶ added in v0.2.4
SetCopyOnWrite sets this bitmap to use copy-on-write so that copies are fast and memory conscious if the parameter is true, otherwise we leave the default where hard copies are made (copy-on-write requires extra care in a threaded context).
func (*Bitmap) Stats ¶ added in v0.3.0
func (bm *Bitmap) Stats() Statistics
func (*Bitmap) ToArray ¶ added in v0.2.0
ToArray creates a new slice containing all of the integers stored in the Bitmap in sorted order
func (*Bitmap) UnmarshalBinary ¶ added in v0.2.6
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for the bitmap
func (*Bitmap) WriteTo ¶ added in v0.2.0
WriteTo writes a serialized version of this bitmap to stream
func (*Bitmap) WriteToMsgpack ¶ added in v0.3.0
WriteTo writes a msgpack2/snappy-streaming compressed serialized version of this bitmap to stream
type IntIterable ¶
IntIterable allows you to iterate over the values in a Bitmap
type RunIterator16 ¶ added in v0.3.0
type RunIterator16 struct {
// contains filtered or unexported fields
}
RunIterator16 advice: you must call Next() at least once before calling Cur(); and you should call HasNext() before calling Next() to insure there are contents.
func (*RunIterator16) Cur ¶ added in v0.3.0
func (ri *RunIterator16) Cur() uint16
Cur returns the current value pointed to by the iterator.
func (*RunIterator16) DecodeMsg ¶ added in v0.3.0
func (z *RunIterator16) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*RunIterator16) EncodeMsg ¶ added in v0.3.0
func (z *RunIterator16) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*RunIterator16) HasNext ¶ added in v0.3.0
func (ri *RunIterator16) HasNext() bool
HasNext returns false if calling Next will panic. It returns true when there is at least one more value available in the iteration sequence.
func (*RunIterator16) MarshalMsg ¶ added in v0.3.0
func (z *RunIterator16) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*RunIterator16) Msgsize ¶ added in v0.3.0
func (z *RunIterator16) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*RunIterator16) Next ¶ added in v0.3.0
func (ri *RunIterator16) Next() uint16
Next returns the next value in the iteration sequence.
func (*RunIterator16) Remove ¶ added in v0.3.0
func (ri *RunIterator16) Remove() uint16
Remove removes the element that the iterator is on from the run container. You can use Cur if you want to double check what is about to be deleted.
func (*RunIterator16) UnmarshalMsg ¶ added in v0.3.0
func (z *RunIterator16) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type RunIterator32 ¶ added in v0.3.0
type RunIterator32 struct {
// contains filtered or unexported fields
}
RunIterator32 advice: you must call Next() at least once before calling Cur(); and you should call HasNext() before calling Next() to insure there are contents.
func (*RunIterator32) Cur ¶ added in v0.3.0
func (ri *RunIterator32) Cur() uint32
Cur returns the current value pointed to by the iterator.
func (*RunIterator32) DecodeMsg ¶ added in v0.3.0
func (z *RunIterator32) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*RunIterator32) EncodeMsg ¶ added in v0.3.0
func (z *RunIterator32) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*RunIterator32) HasNext ¶ added in v0.3.0
func (ri *RunIterator32) HasNext() bool
HasNext returns false if calling Next will panic. It returns true when there is at least one more value available in the iteration sequence.
func (*RunIterator32) MarshalMsg ¶ added in v0.3.0
func (z *RunIterator32) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*RunIterator32) Msgsize ¶ added in v0.3.0
func (z *RunIterator32) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*RunIterator32) Next ¶ added in v0.3.0
func (ri *RunIterator32) Next() uint32
Next returns the next value in the iteration sequence.
func (*RunIterator32) Remove ¶ added in v0.3.0
func (ri *RunIterator32) Remove() uint32
Remove removes the element that the iterator is on from the run container. You can use Cur if you want to double check what is about to be deleted.
func (*RunIterator32) UnmarshalMsg ¶ added in v0.3.0
func (z *RunIterator32) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Statistics ¶ added in v0.3.0
Source Files
¶
- arraycontainer.go
- arraycontainer_gen.go
- bitmapcontainer.go
- bitmapcontainer_gen.go
- fastaggregation.go
- popcnt.go
- popcnt_asm.go
- priorityqueue.go
- rle.go
- rle16.go
- rle16_gen.go
- rle_gen.go
- rlecommon.go
- rlei.go
- roaring.go
- roaringarray.go
- roaringarray_gen.go
- serialization.go
- serialization_littleendian.go
- setutil.go
- shortiterator.go
- util.go