Documentation ¶
Index ¶
- Constants
- func AndCardinality(a, b *Bitmap) (answer uint64)
- func Memclr(b []uint16)
- type BSI
- func (b *BSI) Append(offsets []uint32, data []byte) ([]uint32, []byte)
- func (b *BSI) BitCount() int
- func (b *BSI) CompareValue(parallelism int, op Operation, valueOrStart, end int64, foundSet *Bitmap) *Bitmap
- func (b *BSI) Each(f func(idx byte, bs *Bitmap) error) error
- func (b *BSI) Extract(foundSet *Bitmap) map[uint64]int64
- func (b *BSI) GetCardinality() uint64
- func (b *BSI) GetExistenceBitmap() *Bitmap
- func (b *BSI) GetSizeInBytes() int
- func (b *BSI) GetValue(columnID uint64) (value int64, exists bool)
- func (b *BSI) MinMax(parallelism int, op Operation, foundSet *Bitmap) int64
- func (a *BSI) Or(b *BSI) *BSI
- func (b *BSI) Reset()
- func (b *BSI) SetValue(columnID uint64, value int64)
- func (b *BSI) String() string
- func (b *BSI) Sum(foundSet *Bitmap) (sum int64, count uint64)
- func (b *BSI) ToBuffer() []byte
- func (b *BSI) ToBufferWith(offsets []uint32, data []byte) ([]uint32, []byte)
- func (b *BSI) ValueExists(columnID uint64) bool
- type Batch
- type BatchAction
- type Bitmap
- func And(a, b *Bitmap) *Bitmap
- func FastAnd(bitmaps ...*Bitmap) *Bitmap
- func FastOr(bitmaps ...*Bitmap) *Bitmap
- func FastParOr(numGo int, bitmaps ...*Bitmap) *Bitmap
- func FromBuffer(data []byte) *Bitmap
- func FromBufferWithCopy(src []byte) *Bitmap
- func FromSortedList(vals []uint64) *Bitmap
- func NewBitmap() *Bitmap
- func NewBitmapWith(numKeys int) *Bitmap
- func Or(a, b *Bitmap) *Bitmap
- func (ra *Bitmap) And(bm *Bitmap)
- func (b *Bitmap) AndCardinality(a *Bitmap) (answer uint64)
- func (ra *Bitmap) AndNot(bm *Bitmap)
- func (ra *Bitmap) BSI(id uint64, svalue int64)
- func (ra *Bitmap) BSISum(shard uint64, match *Bitmap) (sum int64)
- func (ra *Bitmap) Batch() Batch
- func (ra *Bitmap) Bool(id uint64, value bool)
- func (ra *Bitmap) Cleanup()
- func (ra *Bitmap) Clone() *Bitmap
- func (ra *Bitmap) Contains(x uint64) bool
- func (ra *Bitmap) Debug(x uint64) string
- func (ra *Bitmap) Each(f func(value uint64))
- func (ra *Bitmap) EachOk(f func(value uint64) bool) (ok bool)
- func (ra *Bitmap) ExtractBSI(shard uint64, match *Bitmap, f func(id uint64, value int64))
- func (ra *Bitmap) ExtractMutex(match *Bitmap, f func(row uint64, columns *Bitmap) error) error
- func (ra *Bitmap) False(shard uint64, match *Bitmap) *Bitmap
- func (ra *Bitmap) Finish(includesBase bool) ([]byte, io.Closer, error)
- func (ra *Bitmap) GetCardinality() int
- func (ra *Bitmap) GetSizeInBytes() int
- func (ra *Bitmap) IsEmpty() bool
- func (r *Bitmap) ManyIterator() *ManyItr
- func (ra *Bitmap) Maximum() uint64
- func (ra *Bitmap) MergeNewer(value []byte) error
- func (ra *Bitmap) MergeOlder(value []byte) error
- func (ra *Bitmap) Minimum() uint64
- func (ra *Bitmap) Mutex(id uint64, value uint64)
- func (bm *Bitmap) NewIterator() *Iterator
- func (bm *Bitmap) NewRangeIterators(numRanges int) []*Iterator
- func (ra *Bitmap) OffsetRange(offset, start, end uint64) *Bitmap
- func (dst *Bitmap) Or(src *Bitmap)
- func (ra *Bitmap) Rank(x uint64) int
- func (ra *Bitmap) Remove(x uint64) bool
- func (ra *Bitmap) RemoveRange(lo, hi uint64)
- func (ra *Bitmap) Reset()
- func (ra *Bitmap) Row(shard, rowID uint64) *Bitmap
- func (ra *Bitmap) Select(x uint64) (uint64, error)
- func (ra *Bitmap) Set(x uint64) bool
- func (ra *Bitmap) SetMany(vals []uint64)
- func (bm *Bitmap) Split(externalSize func(start, end uint64) uint64, maxSz uint64) []*Bitmap
- func (ra *Bitmap) String() string
- func (ra *Bitmap) ToArray() []uint64
- func (ra *Bitmap) ToBuffer() []byte
- func (ra *Bitmap) ToBufferWithCopy() []byte
- func (ra *Bitmap) True(shard uint64, match *Bitmap) *Bitmap
- type Iterator
- type ManyItr
- type Next
- type Operation
Constants ¶
const ( // Min64BitSigned - Minimum 64 bit value Min64BitSigned = -9223372036854775808 // Max64BitSigned - Maximum 64 bit value Max64BitSigned = 9223372036854775807 )
Variables ¶
This section is empty.
Functions ¶
func AndCardinality ¶
Types ¶
type BSI ¶
BSI is at its simplest is an array of bitmaps that represent an encoded binary value. The advantage of a BSI is that comparisons can be made across ranges of values whereas a bitmap can only represent the existence of a single value for a given column ID. Another usage scenario involves storage of high cardinality values.
It depends upon the bitmap libraries. It is not thread safe, so upstream concurrency guards must be provided.
func NewBSI ¶
NewBSI constructs a new BSI. Note that it is your responsibility to ensure that the min/max values are set correctly. Queries CompareValue, MinMax, etc. will not work correctly if the min/max values are not set correctly.
func NewBSIFromBuffer ¶
func (*BSI) CompareValue ¶
func (b *BSI) CompareValue(parallelism int, op Operation, valueOrStart, end int64, foundSet *Bitmap) *Bitmap
CompareValue compares value. Values should be in the range of the BSI (max, min). If the value is outside the range, the result might erroneous. The operation parameter indicates the type of comparison to be made. For all operations with the exception of RANGE, the value to be compared is specified by valueOrStart. For the RANGE parameter the comparison criteria is >= valueOrStart and <= end. The parallelism parameter indicates the number of CPU threads to be applied for processing. A value of zero indicates that all available CPU resources will be potentially utilized.
func (*BSI) GetCardinality ¶
GetCardinality returns a count of unique column IDs for which a value has been set.
func (*BSI) GetExistenceBitmap ¶
GetExistenceBitmap returns a pointer to the underlying existence bitmap of the BSI
func (*BSI) GetSizeInBytes ¶
GetSizeInBytes - the size in bytes of the data structure
func (*BSI) GetValue ¶
GetValue gets the value at the column ID. Second param will be false for non-existent values.
func (*BSI) Or ¶
We only perform Or on a and b. we don't want to modify a or b because there is a posibility a is read from buffer which may corrupt the backing slice..
func (*BSI) Sum ¶
Sum all values contained within the foundSet. As a convenience, the cardinality of the foundSet is also returned (for calculating the average).
func (*BSI) ToBufferWith ¶
func (*BSI) ValueExists ¶
ValueExists tests whether the value exists.
type Batch ¶ added in v1.5.1
type Batch [][]uint64
func (Batch) Run ¶ added in v1.5.1
func (b Batch) Run(ra *Bitmap, action BatchAction)
type BatchAction ¶ added in v1.5.1
type Bitmap ¶
type Bitmap struct {
// contains filtered or unexported fields
}
func FastOr ¶
FastOr would merge given Bitmaps into one Bitmap. This is faster than doing an OR over the bitmaps iteratively.
func FastParOr ¶
FastParOr would group up bitmaps and call FastOr on them concurrently. It would then merge the groups into final Bitmap. This approach is simpler and faster than operating at a container level, because we can't operate on array containers belonging to the same Bitmap concurrently because array containers can expand, leaving no clear boundaries.
If FastParOr is called with numGo=1, it just calls FastOr.
Experiments with numGo=4 shows that FastParOr would be 2x the speed of FastOr, but 4x the memory usage, even under 50% CPU usage. So, use wisely.
func FromBuffer ¶
FromBuffer returns a pointer to bitmap corresponding to the given buffer. This bitmap shouldn't be modified because it might corrupt the given buffer.
func FromBufferWithCopy ¶
FromBufferWithCopy creates a copy of the given buffer and returns a bitmap based on the copied buffer. This bitmap is safe for both read and write operations.
func FromSortedList ¶
func NewBitmapWith ¶
func (*Bitmap) AndCardinality ¶
func (*Bitmap) ExtractBSI ¶ added in v1.5.1
func (*Bitmap) ExtractMutex ¶ added in v1.5.1
func (*Bitmap) GetCardinality ¶
func (*Bitmap) GetSizeInBytes ¶
func (*Bitmap) ManyIterator ¶
TODO: See if this is needed, we should remove this
func (*Bitmap) MergeNewer ¶ added in v1.5.2
func (*Bitmap) MergeOlder ¶ added in v1.5.2
func (*Bitmap) NewIterator ¶
func (*Bitmap) NewRangeIterators ¶
func (*Bitmap) OffsetRange ¶ added in v1.5.1
func (*Bitmap) RemoveRange ¶
Remove range removes [lo, hi) from the bitmap.
func (*Bitmap) Split ¶
Split splits the bitmap based on maxSz and the externalSize function. It splits the bitmap such that size of each split bitmap + external size corresponding to its elements approximately equal to maxSz (it can be greater than maxSz sometimes). The splits are returned in sorted order. externalSize is a function that should return the external size corresponding to elements in range [start, end]. External size is used to calculate the split boundaries.