collections

package
v0.4.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Array16RangeKeys added in v0.2.0

func Array16RangeKeys(name string, length, from, to uint16) []kv.Key

Array16RangeKeys returns the KVStore keys for the items between [from, to) (`to` being not inclusive), assuming it has `length` elements.

func Array32ElemKey added in v0.3.0

func Array32ElemKey(name string, idx uint32) kv.Key

func Array32RangeKeys added in v0.2.0

func Array32RangeKeys(name string, length, from, to uint32) []kv.Key

Array32RangeKeys returns the KVStore keys for the items between [from, to) (`to` being not inclusive), assuming it has `length` elements.

func Array32SizeKey added in v0.3.0

func Array32SizeKey(name string) kv.Key

func MapElemKey added in v0.3.0

func MapElemKey(mapName string, keyInMap []byte) []byte

func MapSizeKey added in v0.3.0

func MapSizeKey(mapName string) []byte

Types

type Array16 added in v0.2.0

type Array16 struct {
	*ImmutableArray16
	// contains filtered or unexported fields
}

Array16 represents a dynamic array stored in a kv.KVStore

func NewArray16 added in v0.2.0

func NewArray16(kvStore kv.KVStore, name string) *Array16

func (*Array16) Erase added in v0.2.0

func (a *Array16) Erase() error

TODO implement with DelPrefix

func (*Array16) Extend added in v0.2.0

func (a *Array16) Extend(other *ImmutableArray16) error

func (*Array16) Immutable added in v0.2.0

func (a *Array16) Immutable() *ImmutableArray16

func (*Array16) MustErase added in v0.2.0

func (a *Array16) MustErase()

func (*Array16) MustExtend added in v0.2.0

func (a *Array16) MustExtend(other *ImmutableArray16)

func (*Array16) MustPush added in v0.2.0

func (a *Array16) MustPush(value []byte)

func (*Array16) MustSetAt added in v0.2.0

func (a *Array16) MustSetAt(idx uint16, value []byte)

func (*Array16) Push added in v0.2.0

func (a *Array16) Push(value []byte) error

adds to the end of the list

func (*Array16) SetAt added in v0.2.0

func (a *Array16) SetAt(idx uint16, value []byte) error

type Array32 added in v0.2.0

type Array32 struct {
	*ImmutableArray32
	// contains filtered or unexported fields
}

Array32 represents a dynamic array stored in a kv.KVStore

func NewArray32 added in v0.2.0

func NewArray32(kvStore kv.KVStore, name string) *Array32

func (*Array32) Erase added in v0.2.0

func (a *Array32) Erase() error

TODO implement with DelPrefix

func (*Array32) Extend added in v0.2.0

func (a *Array32) Extend(other *ImmutableArray32) error

func (*Array32) Immutable added in v0.2.0

func (a *Array32) Immutable() *ImmutableArray32

func (*Array32) MustErase added in v0.2.0

func (a *Array32) MustErase()

func (*Array32) MustExtend added in v0.2.0

func (a *Array32) MustExtend(other *ImmutableArray32)

func (*Array32) MustPush added in v0.2.0

func (a *Array32) MustPush(value []byte)

func (*Array32) MustSetAt added in v0.2.0

func (a *Array32) MustSetAt(idx uint32, value []byte)

func (*Array32) Push added in v0.2.0

func (a *Array32) Push(value []byte) error

adds to the end of the list

func (*Array32) SetAt added in v0.2.0

func (a *Array32) SetAt(idx uint32, value []byte) error

type ImmutableArray16 added in v0.2.0

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

ImmutableArray16 provides read-only access to an Array16 in a kv.KVStoreReader.

func NewArray16ReadOnly added in v0.2.0

func NewArray16ReadOnly(kvReader kv.KVStoreReader, name string) *ImmutableArray16

func (*ImmutableArray16) GetAt added in v0.2.0

func (a *ImmutableArray16) GetAt(idx uint16) ([]byte, error)

func (*ImmutableArray16) Len added in v0.2.0

func (a *ImmutableArray16) Len() (uint16, error)

Len == 0/empty/non-existent are equivalent

func (*ImmutableArray16) MustGetAt added in v0.2.0

func (a *ImmutableArray16) MustGetAt(idx uint16) []byte

func (*ImmutableArray16) MustLen added in v0.2.0

func (a *ImmutableArray16) MustLen() uint16

type ImmutableArray32 added in v0.2.0

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

ImmutableArray32 provides read-only access to an Array32 in a kv.KVStoreReader.

func NewArray32ReadOnly added in v0.2.0

func NewArray32ReadOnly(kvReader kv.KVStoreReader, name string) *ImmutableArray32

func (*ImmutableArray32) GetAt added in v0.2.0

func (a *ImmutableArray32) GetAt(idx uint32) ([]byte, error)

func (*ImmutableArray32) Len added in v0.2.0

func (a *ImmutableArray32) Len() (uint32, error)

Len == 0/empty/non-existent are equivalent

func (*ImmutableArray32) MustGetAt added in v0.2.0

func (a *ImmutableArray32) MustGetAt(idx uint32) []byte

func (*ImmutableArray32) MustLen added in v0.2.0

func (a *ImmutableArray32) MustLen() uint32

type ImmutableMap

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

ImmutableMap provides read-only access to a Map in a kv.KVStoreReader.

func NewMapReadOnly

func NewMapReadOnly(kvReader kv.KVStoreReader, name string) *ImmutableMap

func (*ImmutableMap) GetAt

func (m *ImmutableMap) GetAt(key []byte) ([]byte, error)

func (*ImmutableMap) HasAt

func (m *ImmutableMap) HasAt(key []byte) (bool, error)

func (*ImmutableMap) Iterate

func (m *ImmutableMap) Iterate(f func(elemKey []byte, value []byte) bool) error

Iterate non-deterministic

func (*ImmutableMap) IterateKeys

func (m *ImmutableMap) IterateKeys(f func(elemKey []byte) bool) error

IterateKeys non-deterministic

func (*ImmutableMap) Len

func (m *ImmutableMap) Len() (uint32, error)

func (*ImmutableMap) MustGetAt

func (m *ImmutableMap) MustGetAt(key []byte) []byte

func (*ImmutableMap) MustHasAt

func (m *ImmutableMap) MustHasAt(key []byte) bool

func (*ImmutableMap) MustIterate

func (m *ImmutableMap) MustIterate(f func(elemKey []byte, value []byte) bool)

MustIterate non-deterministic

func (*ImmutableMap) MustIterateKeys

func (m *ImmutableMap) MustIterateKeys(f func(elemKey []byte) bool)

MustIterateKeys non-deterministic

func (*ImmutableMap) MustLen

func (m *ImmutableMap) MustLen() uint32

func (*ImmutableMap) Name

func (m *ImmutableMap) Name() string

type ImmutableTimestampedLog

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

ImmutableTimestampedLog provides read-only access to a TimestampedLog in a kv.KVStoreReader.

func NewTimestampedLogReadOnly

func NewTimestampedLogReadOnly(kvReader kv.KVStoreReader, name kv.Key) *ImmutableTimestampedLog

func (*ImmutableTimestampedLog) Earliest

func (l *ImmutableTimestampedLog) Earliest() (int64, error)

Earliest returns timestamp of the first record in the log, if any, or otherwise it is 0

func (*ImmutableTimestampedLog) Latest

func (l *ImmutableTimestampedLog) Latest() (int64, error)

Latest returns latest timestamp in the log

func (*ImmutableTimestampedLog) Len

func (l *ImmutableTimestampedLog) Len() (uint32, error)

func (*ImmutableTimestampedLog) LoadRecordsRaw

func (l *ImmutableTimestampedLog) LoadRecordsRaw(fromIdx, toIdx uint32, descending bool) ([][]byte, error)

LoadRecords returns all records in the slice

func (*ImmutableTimestampedLog) MustEarliest

func (l *ImmutableTimestampedLog) MustEarliest() int64

func (*ImmutableTimestampedLog) MustLatest

func (l *ImmutableTimestampedLog) MustLatest() int64

func (*ImmutableTimestampedLog) MustLen

func (l *ImmutableTimestampedLog) MustLen() uint32

func (*ImmutableTimestampedLog) MustLoadRecordsRaw

func (l *ImmutableTimestampedLog) MustLoadRecordsRaw(fromIdx, toIdx uint32, descending bool) [][]byte

func (*ImmutableTimestampedLog) MustTakeTimeSlice

func (l *ImmutableTimestampedLog) MustTakeTimeSlice(fromTs, toTs int64) *TimeSlice

func (*ImmutableTimestampedLog) TakeTimeSlice

func (l *ImmutableTimestampedLog) TakeTimeSlice(fromTs, toTs int64) (*TimeSlice, error)

TakeTimeSlice returns a slice structure, which contains existing indices firstIdx and lastIdx. Timestamps of all records between indices (inclusive) satisfy the condition >= T(firstIdx) and <=T(lastIdx) Any other pair of indices i1<fistId and/or i2>lastIdx does not satisfy the condition. In other words, returned slice contains all possible indices with timestamps between the two given Returned slice may be empty The algorithm uses binary search with logarithmic complexity.

type Map

type Map struct {
	*ImmutableMap
	// contains filtered or unexported fields
}

Map represents a dynamic key-value collection in a kv.KVStore.

func NewMap

func NewMap(kvStore kv.KVStore, name string) *Map

func (*Map) DelAt

func (m *Map) DelAt(key []byte) error

func (*Map) Erase

func (m *Map) Erase()

Erase the map.

func (*Map) Immutable

func (m *Map) Immutable() *ImmutableMap

func (*Map) MustDelAt

func (m *Map) MustDelAt(key []byte)

func (*Map) MustSetAt

func (m *Map) MustSetAt(key, value []byte)

func (*Map) SetAt

func (m *Map) SetAt(key, value []byte) error

type TimeSlice

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

func (*TimeSlice) Earliest

func (sl *TimeSlice) Earliest() int64

Earliest return timestamp of the first index or 0 if empty

func (*TimeSlice) FromToIndices

func (sl *TimeSlice) FromToIndices() (uint32, uint32)

func (*TimeSlice) FromToIndicesCapped

func (sl *TimeSlice) FromToIndicesCapped(maxLast uint32) (uint32, uint32)

func (*TimeSlice) IsEmpty

func (sl *TimeSlice) IsEmpty() bool

IsEmpty returns true if slice does not contains points

func (*TimeSlice) Latest

func (sl *TimeSlice) Latest() int64

Earliest returns timestamp of the last index or 0 if empty

func (*TimeSlice) NumPoints

func (sl *TimeSlice) NumPoints() uint32

NumPoints return number of indices (records) in the slice

type TimestampedLog

type TimestampedLog struct {
	*ImmutableTimestampedLog
	// contains filtered or unexported fields
}

TimestampedLog represents a dynamic append-only array of records, where each record is indexed sequentially and consistently timestamped. The sequence of timestamps is considered consistent if for any indices i<j, Ti<=Tj, i.e. non-decreasing

func NewTimestampedLog

func NewTimestampedLog(kvStore kv.KVStore, name kv.Key) *TimestampedLog

func (*TimestampedLog) Append

func (l *TimestampedLog) Append(ts int64, data []byte) error

Append appends data with timestamp to the end of the log. Returns error if timestamp is inconsistent, i.e. less than the latest timestamp

func (*TimestampedLog) Erase

func (l *TimestampedLog) Erase()

func (*TimestampedLog) Immutable

func (l *TimestampedLog) Immutable() *ImmutableTimestampedLog

func (*TimestampedLog) MustAppend

func (l *TimestampedLog) MustAppend(ts int64, data []byte)

type TimestampedLogRecord

type TimestampedLogRecord struct {
	Timestamp int64
	Data      []byte
}

func ParseRawLogRecord

func ParseRawLogRecord(raw []byte) (*TimestampedLogRecord, error)

Jump to

Keyboard shortcuts

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