bitseq

package
v24.0.0-beta.1+incompa... Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package bitseq provides a structure and utilities for representing a long bitmask which is persisted in a datastore. It is backed by bitmap.Bitmap which operates directly on the encoded representation, without uncompressing.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoBitAvailable is returned when no more bits are available to set
	ErrNoBitAvailable = bitmap.ErrNoBitAvailable
	// ErrBitAllocated is returned when the specific bit requested is already set
	ErrBitAllocated = bitmap.ErrBitAllocated
)

Functions

This section is empty.

Types

type Handle

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

Handle contains the sequence representing the bitmask and its identifier

func NewHandle

func NewHandle(app string, ds datastore.DataStore, id string, numElements uint64) (*Handle, error)

NewHandle returns a thread-safe instance of the bitmask handler

func (*Handle) Bits

func (h *Handle) Bits() uint64

Bits returns the length of the bit sequence

func (*Handle) CopyTo

func (h *Handle) CopyTo(o datastore.KVObject) error

CopyTo deep copies the handle into the passed destination object

func (*Handle) DataScope

func (h *Handle) DataScope() string

DataScope method returns the storage scope of the datastore

func (*Handle) Destroy

func (h *Handle) Destroy() error

Destroy removes from the datastore the data belonging to this handle

func (*Handle) Exists

func (h *Handle) Exists() bool

Exists method is true if this object has been stored in the DB.

func (*Handle) Index

func (h *Handle) Index() uint64

Index returns the latest DB Index as seen by this object

func (*Handle) IsSet

func (h *Handle) IsSet(ordinal uint64) bool

IsSet atomically checks if the ordinal bit is set. In case ordinal is outside of the bit sequence limits, false is returned.

func (*Handle) Key

func (h *Handle) Key() []string

Key provides the Key to be used in KV Store

func (*Handle) KeyPrefix

func (h *Handle) KeyPrefix() []string

KeyPrefix returns the immediate parent key that can be used for tree walk

func (*Handle) MarshalJSON

func (h *Handle) MarshalJSON() ([]byte, error)

MarshalJSON encodes h into a JSON message.

func (*Handle) New

func (h *Handle) New() datastore.KVObject

New method returns a handle based on the receiver handle

func (*Handle) Set

func (h *Handle) Set(ordinal uint64) error

Set atomically sets the corresponding bit in the sequence

func (*Handle) SetAny

func (h *Handle) SetAny(serial bool) (uint64, error)

SetAny atomically sets the first unset bit in the sequence and returns the corresponding ordinal

func (*Handle) SetAnyInRange

func (h *Handle) SetAnyInRange(start, end uint64, serial bool) (uint64, error)

SetAnyInRange atomically sets the first unset bit in the specified range in the sequence and returns the corresponding ordinal

func (*Handle) SetIndex

func (h *Handle) SetIndex(index uint64)

SetIndex method allows the datastore to store the latest DB Index into this object

func (*Handle) SetValue

func (h *Handle) SetValue(value []byte) error

SetValue unmarshals the data from the KV store

func (*Handle) Skip

func (h *Handle) Skip() bool

Skip provides a way for a KV Object to avoid persisting it in the KV Store

func (*Handle) String

func (h *Handle) String() string

func (*Handle) UnmarshalJSON

func (h *Handle) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a JSON message into h.

func (*Handle) Unselected

func (h *Handle) Unselected() uint64

Unselected returns the number of bits which are not selected

func (*Handle) Unset

func (h *Handle) Unset(ordinal uint64) error

Unset atomically unsets the corresponding bit in the sequence

func (*Handle) Value

func (h *Handle) Value() []byte

Value marshals the data to be stored in the KV store

Jump to

Keyboard shortcuts

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