collections

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0, BSD-2-Clause Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayElemKey

func ArrayElemKey(name string, idx uint16) kv.Key

func ArrayRangeKeys

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

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

func ArraySizeKey

func ArraySizeKey(name string) kv.Key

Types

type Array

type Array struct {
	*ImmutableArray
	// contains filtered or unexported fields
}

Array represents a dynamic array stored in a kv.KVStore

func NewArray

func NewArray(kv kv.KVStore, name string) *Array

func (*Array) Erase

func (a *Array) Erase() error

TODO implement with DelPrefix

func (*Array) Extend

func (a *Array) Extend(other *ImmutableArray) error

func (*Array) Immutable

func (a *Array) Immutable() *ImmutableArray

func (*Array) MustErase

func (a *Array) MustErase()

func (*Array) MustExtend

func (a *Array) MustExtend(other *ImmutableArray)

func (*Array) MustPush

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

func (*Array) MustSetAt

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

func (*Array) Push

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

adds to the end of the list

func (*Array) SetAt

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

type ImmutableArray

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

ImmutableArray provides read-only access to an Array in a kv.KVStoreReader.

func NewArrayReadOnly

func NewArrayReadOnly(kv kv.KVStoreReader, name string) *ImmutableArray

func (*ImmutableArray) GetAt

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

func (*ImmutableArray) Len

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

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

func (*ImmutableArray) MustGetAt

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

func (*ImmutableArray) MustLen

func (a *ImmutableArray) MustLen() uint16

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(kv 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) IterateBalances

func (m *ImmutableMap) IterateBalances(f func(color balance.Color, bal int64) bool) error

func (*ImmutableMap) IterateKeys

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

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

Iterate non-deterministic

func (*ImmutableMap) MustIterateKeys

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

Iterate 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(kv 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(kv kv.KVStore, name string) *Map

func (*Map) DelAt

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

func (*Map) Erase

func (m *Map) Erase()

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 []byte, value []byte)

func (*Map) SetAt

func (m *Map) SetAt(key []byte, 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(kv 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