bitmap

package
v0.0.0-...-8043eea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOutOfBoundsOffset = fmt.Errorf("ERR requested bit offset is out of bounds")

ErrOutOfBoundsOffset is returned when the requested bit offset is beyond the bitmap's bounds.

Functions

This section is empty.

Types

type BasicOps

type BasicOps struct {
	// contains filtered or unexported fields
}

BasicOps handles basic bitmap operations

func NewBasicOps

func NewBasicOps(cache *sync.Map, version *sync.Map) *BasicOps

NewBasicOps creates a new BasicOps instance

func (*BasicOps) CreateBitmap

func (b *BasicOps) CreateBitmap(key string, size int) error

CreateBitmap creates a new bitmap of given size

func (*BasicOps) GetBit

func (b *BasicOps) GetBit(key string, offset int64) (int, error)

GetBit retrieves the bit value (0 or 1) at the given offset within the bitmap associated with the key. If the key is not found, it returns 0 and nil error. If the value associated with the key is not a byte slice, it returns an error. If the offset is beyond the bounds of the bitmap, it returns 0 and nil error.

func (*BasicOps) GetBitmap

func (b *BasicOps) GetBitmap(key string) []byte

GetBitmap returns the underlying byte slice for a key

func (*BasicOps) SetBit

func (b *BasicOps) SetBit(key string, offset int64, value int) (int, error)

SetBit sets the bit at the given offset to the specified value (0 or 1) within the bitmap associated with the key. It returns the original bit value at the offset before the update. Returns an error if the value is not 0 or 1, or if there's an issue with the cache.

type BitwiseOps

type BitwiseOps struct {
	// contains filtered or unexported fields
}

func NewBitwiseOps

func NewBitwiseOps(basicOps *BasicOps) *BitwiseOps

func (*BitwiseOps) BitOp

func (b *BitwiseOps) BitOp(operation string, destkey string, keys ...string) (int64, error)

BitOp performs a bitwise operation on multiple bitmaps

type CountOps

type CountOps struct {
	// contains filtered or unexported fields
}

func NewCountOps

func NewCountOps(basicOps *BasicOps) *CountOps

func (*CountOps) BitCount

func (c *CountOps) BitCount(key string, start, end int64) (int64, error)

BitCount returns the number of set bits (1) in the bitmap

func (*CountOps) BitPos

func (c *CountOps) BitPos(key string, bit int, start, end int64, reverse bool) (int64, error)

BitPos finds the position of the first bit set to a given value (0 or 1)

func (*CountOps) CountBitsInRange

func (c *CountOps) CountBitsInRange(b byte, start, end int) int

CountBitsInRange counts bits in a specific range within a byte

type FieldOps

type FieldOps struct {
	// contains filtered or unexported fields
}

func NewFieldOps

func NewFieldOps(basicOps *BasicOps) *FieldOps

func (*FieldOps) BitField

func (f *FieldOps) BitField(key string, commands []models.BitFieldCommand) ([]int64, error)

BitField executes multiple bitfield commands on a bitmap

func (*FieldOps) BitFieldRO

func (f *FieldOps) BitFieldRO(key string, commands []models.BitFieldCommand) ([]int64, error)

BitFieldRO executes read-only bitfield operations

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(bcache *sync.Map, version *sync.Map) *Manager

func (*Manager) BitCount

func (m *Manager) BitCount(key string, start, end int64) (int64, error)

func (*Manager) BitField

func (m *Manager) BitField(key string, commands []models.BitFieldCommand) ([]int64, error)

func (*Manager) BitFieldRO

func (m *Manager) BitFieldRO(key string, commands []models.BitFieldCommand) ([]int64, error)

func (*Manager) BitOp

func (m *Manager) BitOp(operation string, destkey string, keys ...string) (int64, error)

func (*Manager) BitPos

func (m *Manager) BitPos(key string, bit int, start, end int64, reverse bool) (int64, error)

func (*Manager) GetBit

func (m *Manager) GetBit(key string, offset int64) (int, error)

func (*Manager) GetBitmap

func (m *Manager) GetBitmap(key string) []byte

func (*Manager) SetBit

func (m *Manager) SetBit(key string, offset int64, value int) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL