Documentation
¶
Index ¶
- type Bitmap
- func And(x1, x2 *Bitmap) *Bitmap
- func AndNot(x1, x2 *Bitmap) *Bitmap
- func BitmapOf(dat ...uint64) *Bitmap
- func FastAnd(bitmaps ...*Bitmap) *Bitmap
- func FastOr(bitmaps ...*Bitmap) *Bitmap
- func Flip(rb *Bitmap, rangeStart, rangeEnd uint64) *Bitmap
- func FlipInt(bm *Bitmap, rangeStart, rangeEnd int) *Bitmap
- func New() *Bitmap
- func NewBitmap() *Bitmap
- func Or(x1, x2 *Bitmap) *Bitmap
- func ParOr(parallelism int, bitmaps ...*Bitmap) *Bitmap
- func Xor(x1, x2 *Bitmap) *Bitmap
- func (rb *Bitmap) Add(x uint64)
- func (rb *Bitmap) AddInt(x int)
- func (rb *Bitmap) AddMany(dat []uint64)
- 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 uint64) bool
- func (rb *Bitmap) CheckedRemove(x uint64) bool
- func (rb *Bitmap) Clear()
- func (rb *Bitmap) Clone() *Bitmap
- func (rb *Bitmap) CloneCopyOnWriteContainers()
- func (rb *Bitmap) Contains(x uint64) 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) GetSizeInBytes() uint64
- func (rb *Bitmap) HasRunCompression() bool
- func (rb *Bitmap) Intersects(x2 *Bitmap) bool
- func (rb *Bitmap) IsEmpty() bool
- func (rb *Bitmap) Iterator() IntPeekable64
- func (rb *Bitmap) ManyIterator() ManyIntIterable64
- func (rb *Bitmap) MarshalBinary() ([]byte, error)
- func (rb *Bitmap) Maximum() uint64
- func (rb *Bitmap) Minimum() uint64
- func (rb *Bitmap) Or(x2 *Bitmap)
- func (rb *Bitmap) OrCardinality(x2 *Bitmap) uint64
- func (rb *Bitmap) Rank(x uint64) uint64
- func (rb *Bitmap) ReadFrom(stream io.Reader) (p int64, err error)
- func (rb *Bitmap) Remove(x uint64)
- func (rb *Bitmap) RemoveRange(rangeStart, rangeEnd uint64)
- func (rb *Bitmap) ReverseIterator() IntIterable64
- func (rb *Bitmap) RunOptimize()
- func (rb *Bitmap) Select(x uint64) (uint64, error)
- func (rb *Bitmap) SetCopyOnWrite(val bool)
- func (rb *Bitmap) Stats() roaring.Statistics
- func (rb *Bitmap) String() string
- func (rb *Bitmap) ToArray() []uint64
- func (rb *Bitmap) ToBase64() (string, error)
- func (rb *Bitmap) ToBytes() ([]byte, error)
- func (rb *Bitmap) UnmarshalBinary(data []byte) error
- func (rb *Bitmap) WriteTo(stream io.Writer) (int64, error)
- func (rb *Bitmap) Xor(x2 *Bitmap)
- type IntIterable64
- type IntPeekable64
- type ManyIntIterable64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bitmap ¶
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.
func ParOr ¶
ParOr computes the union (OR) of all provided bitmaps in parallel, where the parameter "parallelism" determines how many workers are to be used (if it is set to 0, a default number of workers is chosen)
func (*Bitmap) AddInt ¶
AddInt adds the integer x to the bitmap (convenience method: the parameter is casted to uint32 and we call Add)
func (*Bitmap) And ¶
And computes the intersection between two bitmaps and stores the result in the current bitmap
func (*Bitmap) AndCardinality ¶
AndCardinality returns the cardinality of the intersection between two bitmaps, bitmaps are not modified
func (*Bitmap) AndNot ¶
AndNot computes the difference between two bitmaps and stores the result in the current bitmap
func (*Bitmap) CheckedAdd ¶
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 ¶
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 ¶
func (rb *Bitmap) Clear()
Clear resets the Bitmap to be logically empty, but may retain some memory allocations that may speed up future operations
func (*Bitmap) CloneCopyOnWriteContainers ¶
func (rb *Bitmap) CloneCopyOnWriteContainers()
CloneCopyOnWriteContainers clones all containers which have needCopyOnWrite set to true. This can be used to make sure it is safe to munmap a []byte that the roaring array may still have a reference to, after calling FromBuffer. More generally this function is useful if you call FromBuffer to construct a bitmap with a backing array buf and then later discard the buf array. Note that you should call CloneCopyOnWriteContainers on all bitmaps that were derived from the 'FromBuffer' bitmap since they map have dependencies on the buf array as well.
func (*Bitmap) ContainsInt ¶
ContainsInt returns true if the integer is contained in the bitmap (this is a convenience method, the parameter is casted to uint64 and Contains is called)
func (*Bitmap) 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.
func (*Bitmap) FromBase64 ¶
FromBase64 deserializes a bitmap from Base64
func (*Bitmap) GetCardinality ¶
GetCardinality returns the number of integers contained in the bitmap
func (*Bitmap) GetCopyOnWrite ¶
GetCopyOnWrite gets this bitmap's copy-on-write property
func (*Bitmap) GetSizeInBytes ¶
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) HasRunCompression ¶
HasRunCompression returns true if the bitmap benefits from run compression
func (*Bitmap) Intersects ¶
Intersects checks whether two bitmap intersects, bitmaps are not modified
func (*Bitmap) IsEmpty ¶
IsEmpty returns true if the Bitmap is empty (it is faster than doing (GetCardinality() == 0))
func (*Bitmap) Iterator ¶
func (rb *Bitmap) Iterator() IntPeekable64
Iterator creates a new IntPeekable to iterate over the integers contained in the bitmap, in sorted order; the iterator becomes invalid if the bitmap is modified (e.g., with Add or Remove).
func (*Bitmap) ManyIterator ¶
func (rb *Bitmap) ManyIterator() ManyIntIterable64
ManyIterator creates a new ManyIntIterable to iterate over the integers contained in the bitmap, in sorted order; the iterator becomes invalid if the bitmap is modified (e.g., with Add or Remove).
func (*Bitmap) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface for the bitmap (same as ToBytes)
func (*Bitmap) Maximum ¶
Maximum get the largest value stored in this roaring bitmap, assumes that it is not empty
func (*Bitmap) Minimum ¶
Minimum get the smallest value stored in this roaring bitmap, assumes that it is not empty
func (*Bitmap) Or ¶
Or computes the union between two bitmaps and stores the result in the current bitmap
func (*Bitmap) OrCardinality ¶
OrCardinality returns the cardinality of the union between two bitmaps, bitmaps are not modified
func (*Bitmap) Rank ¶
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be GetCardinality())
func (*Bitmap) ReadFrom ¶
ReadFrom reads a serialized version of this bitmap from stream. The format is compatible with other RoaringBitmap implementations (Java, C) and is documented here: https://github.com/RoaringBitmap/RoaringFormatSpec
func (*Bitmap) RemoveRange ¶
RemoveRange removes the integers in [rangeStart, rangeEnd) from the bitmap.
func (*Bitmap) ReverseIterator ¶
func (rb *Bitmap) ReverseIterator() IntIterable64
ReverseIterator creates a new IntIterable to iterate over the integers contained in the bitmap, in sorted order; the iterator becomes invalid if the bitmap is modified (e.g., with Add or Remove).
func (*Bitmap) RunOptimize ¶
func (rb *Bitmap) RunOptimize()
RunOptimize attempts to further compress the runs of consecutive values found in the bitmap
func (*Bitmap) SetCopyOnWrite ¶
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). Calling SetCopyOnWrite(true) on a bitmap created with FromBuffer is unsafe.
func (*Bitmap) Stats ¶
func (rb *Bitmap) Stats() roaring.Statistics
Stats returns details on container type usage in a Statistics struct.
func (*Bitmap) ToArray ¶
ToArray creates a new slice containing all of the integers stored in the Bitmap in sorted order
func (*Bitmap) ToBytes ¶
ToBytes returns an array of bytes corresponding to what is written when calling WriteTo
func (*Bitmap) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for the bitmap
type IntIterable64 ¶
IntIterable64 allows you to iterate over the values in a Bitmap
type IntPeekable64 ¶
type IntPeekable64 interface { IntIterable64 // PeekNext peeks the next value without advancing the iterator PeekNext() uint64 // AdvanceIfNeeded advances as long as the next value is smaller than minval AdvanceIfNeeded(minval uint64) }
IntPeekable64 allows you to look at the next value without advancing and advance as long as the next value is smaller than minval
type ManyIntIterable64 ¶
type ManyIntIterable64 interface { // pass in a buffer to fill up with values, returns how many values were returned NextMany([]uint64) int }
ManyIntIterable64 allows you to iterate over the values in a Bitmap