bitseq

package
v23.0.9+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package bitseq provides a structure and utilities for representing long bitmask as sequence of run-length encoded blocks. It operates directly on the encoded representation, it does not decode/encode.

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Handle

type Handle struct {
	sync.Mutex
	// 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) CheckConsistency

func (h *Handle) CheckConsistency() error

CheckConsistency checks if the bit sequence is in an inconsistent state and attempts to fix it. It looks for a corruption signature that may happen in docker 1.9.0 and 1.9.1.

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) FromByteArray

func (h *Handle) FromByteArray(ba []byte) error

FromByteArray reads his handle's data from a byte array

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 Handle into 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) ToByteArray

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

ToByteArray converts this handle's data into a byte array

func (*Handle) UnmarshalJSON

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

UnmarshalJSON decodes json message into Handle

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