package bitutil

Import Path
	github.com/apache/arrow-go/v18/arrow/bitutil (on go.dev)

Dependency Relation
	imports 9 packages, and imported by 10 packages


Package-Level Type Names (total 6)
/* sort by: | */
Data []byte Len int64 Offset int64 func VisitWordsAndWrite(args []Bitmap, out []Bitmap, visitor func(in, out []uint64)) error func VisitWordsAndWrite(args []Bitmap, out []Bitmap, visitor func(in, out []uint64)) error
BitmapReader is a simple bitmap reader for a byte slice. Len returns the total number of bits in the bitmap Next advances the reader to the next bit in the bitmap. NotSet returns true if the current bit is not set Pos returns the current bit position in the bitmap that the reader is looking at Set returns true if the current bit is set func NewBitmapReader(bitmap []byte, offset, length int) *BitmapReader
BitmapWordReader is a reader for bitmaps that reads a word at a time (a word being an 8 byte uint64) and then provides functions to grab the individual trailing bytes after the last word NextTrailingByte returns the next trailing byte of the bitmap after the last word along with the number of valid bits in that byte. When validBits < 8, that is the last byte. If the bitmap ends on a byte alignment, then the last byte can also return 8 valid bits. Thus the TrailingBytes function should be used to know how many trailing bytes to read. NextWord returns the next full word read from the bitmap, should not be called if Words() is 0 as it will step outside of the bounds of the bitmap slice and panic. We don't perform the bounds checking in order to improve performance. (*BitmapWordReader) TrailingBytes() int (*BitmapWordReader) Words() int func NewBitmapWordReader(bitmap []byte, offset, length int) *BitmapWordReader
BitmapWordWriter is a bitmap writer for writing a full word at a time (a word being a uint64). After the last full word is written, PutNextTrailingByte can be used to write the remaining trailing bytes. PutNextTrailingByte writes the number of bits indicated by validBits from b to the bitmap. PutNextWord writes the given word to the bitmap, potentially splitting across two adjacent words. func NewBitmapWordWriter(bitmap []byte, start, len int) *BitmapWordWriter
BitmapWriter is a simple writer for writing bitmaps to byte slices AppendBools writes a series of booleans to the bitmapwriter and returns the number of remaining bytes left in the buffer for writing. (*BitmapWriter) Clear() Finish flushes the final byte out to the byteslice in case it was not already on a byte aligned boundary. Next increments the writer to the next bit for writing. (*BitmapWriter) Pos() int Reset resets the position and view of the slice to restart writing a bitmap to the same byte slice. (*BitmapWriter) Set() func NewBitmapWriter(bitmap []byte, start, length int) *BitmapWriter
OptionalBitIndexer is a convenience wrapper for getting bits from a bitmap which may or may not be nil. Bitmap []byte Offset int (*OptionalBitIndexer) GetBit(i int) bool
Package-Level Functions (total 31)
BitIsNotSet returns true if the bit at index i in buf is not set (0).
BitIsSet returns true if the bit at index i in buf is set (1).
func BitmapAnd(left, right []byte, lOffset, rOffset int64, out []byte, outOffset int64, length int64)
func BitmapAndAlloc(mem memory.Allocator, left, right []byte, lOffset, rOffset int64, length, outOffset int64) *memory.Buffer
func BitmapAndNot(left, right []byte, lOffset, rOffset int64, out []byte, outOffset int64, length int64)
func BitmapAndNotAlloc(mem memory.Allocator, left, right []byte, lOffset, rOffset int64, length, outOffset int64) *memory.Buffer
func BitmapEquals(left, right []byte, lOffset, rOffset int64, length int64) bool
func BitmapOp(op bitOp, left, right []byte, lOffset, rOffset int64, out []byte, outOffset, length int64)
func BitmapOpAlloc(mem memory.Allocator, op bitOp, left, right []byte, lOffset, rOffset int64, length int64, outOffset int64) *memory.Buffer
func BitmapOr(left, right []byte, lOffset, rOffset int64, out []byte, outOffset int64, length int64)
func BitmapOrAlloc(mem memory.Allocator, left, right []byte, lOffset, rOffset int64, length, outOffset int64) *memory.Buffer
func BitmapXor(left, right []byte, lOffset, rOffset int64, out []byte, outOffset int64, length int64)
func BitmapXorAlloc(mem memory.Allocator, left, right []byte, lOffset, rOffset int64, length, outOffset int64) *memory.Buffer
CeilByte rounds size to the next multiple of 8.
CeilByte64 rounds size to the next multiple of 8.
ClearBit sets the bit at index i in buf to 0.
CopyBitmap copies the bitmap indicated by src, starting at bit offset srcOffset, and copying length bits into dst, starting at bit offset dstOffset.
CountSetBits counts the number of 1's in buf up to n bits.
InvertBitmap copies a bit range of a bitmap, inverting it as it copies over into the destination.
IsMultipleOf64 returns whether v is a multiple of 64
IsMultipleOf8 returns whether v is a multiple of 8.
NewBitmapReader creates and returns a new bitmap reader for the given bitmap
NewBitmapWordReader sets up a word reader, calculates the number of trailing bits and number of trailing bytes, along with the number of words.
NewBitmapWordWriter initializes a new bitmap word writer which will start writing into the byte slice at bit offset start, expecting to write len bits.
NewBitmapWriter returns a sequential bitwise writer that preserves surrounding bit values as it writes.
NextPowerOf2 rounds x to the next power of two.
SetBit sets the bit at index i in buf to 1.
SetBitsTo is a convenience function to quickly set or unset all the bits in a bitmap starting at startOffset for length bits.
SetBitTo sets the bit at index i in buf to val.
VisitWordsAndWrite visits words of bits from each input bitmap and collects outputs to a slice of output Bitmaps. All bitmaps must have identical lengths. The first bit in a visited bitmap may be offset within the first visited word, but words will otherwise contain densely packed bits loaded from the bitmap. That offset within the first word is returned. NOTE: this function is efficient on 3+ sufficiently large bitmaps. It also has a large prolog/epilog overhead and should be used carefully in other cases. For 2 or fewer bitmaps, and/or smaller bitmaps, try BitmapReader and or other utilities.
Package-Level Variables (total 4)
var BitMask [8]byte
PrecedingBitmask is a convenience set of values as bitmasks for checking prefix bits of a byte
TrailingBitmask is the bitwise complement version of kPrecedingBitmask