dict

package
v0.6.1-alpha.15 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dict

type Dict map[kv.Key][]byte

Dict is an implementation kv.KVStore interface backed by an in-memory map. kv.KVStore represents a key-value store where both keys and values are arbitrary byte slices.

func FromBytes added in v0.2.0

func FromBytes(data []byte) (Dict, error)

func FromJSONDict added in v1.0.3

func FromJSONDict(jsonDict JSONDict) (Dict, error)

FromJSONDict returns a dict based off an JSONDict

func FromKVStore

func FromKVStore(s kv.KVStoreReader) Dict

FromKVStore convert (copy) any KVStore to dict

func FromMarshalUtil added in v0.2.0

func FromMarshalUtil(mu *marshalutil.MarshalUtil) (Dict, error)

func New

func New() Dict

New creates new

func (Dict) Bytes added in v0.2.0

func (d Dict) Bytes() []byte

func (Dict) Clone

func (d Dict) Clone() Dict

Clone creates clone (deep copy) of Dict

func (Dict) Del

func (d Dict) Del(key kv.Key)

Del removes key/value pair

func (Dict) Equals added in v0.2.0

func (d Dict) Equals(d1 Dict) bool

func (Dict) Extend

func (d Dict) Extend(from Dict)

Extend appends another Dict

func (Dict) ForEach

func (d Dict) ForEach(fun func(key kv.Key, value []byte) bool)

ForEach iterates non-deterministic!

func (Dict) Get

func (d Dict) Get(key kv.Key) []byte

Get takes a value. Returns nil if key does not exist

func (Dict) Has

func (d Dict) Has(key kv.Key) bool

Has checks if key exist

func (Dict) Hash

func (d Dict) Hash() hashing.HashValue

Hash takes deterministic has of the dict

func (Dict) IsEmpty

func (d Dict) IsEmpty() bool

IsEmpty returns of it has no records

func (Dict) Iterate

func (d Dict) Iterate(prefix kv.Key, f func(key kv.Key, value []byte) bool)

Iterate over keys with prefix

func (Dict) IterateKeys

func (d Dict) IterateKeys(prefix kv.Key, f func(key kv.Key) bool)

IterateKeys over keys with prefix

func (Dict) IterateKeysSorted added in v0.2.0

func (d Dict) IterateKeysSorted(prefix kv.Key, f func(key kv.Key) bool)

func (Dict) IterateSorted added in v0.2.0

func (d Dict) IterateSorted(prefix kv.Key, f func(key kv.Key, value []byte) bool)

func (Dict) JSONDict

func (d Dict) JSONDict() JSONDict

JSONDict returns a JSON-compatible representation of the Dict

func (Dict) Keys

func (d Dict) Keys() []kv.Key

Keys takes all keys

func (Dict) KeysSorted

func (d Dict) KeysSorted() []kv.Key

KeysSorted takes keys and sorts them

func (Dict) MarshalJSON

func (d Dict) MarshalJSON() ([]byte, error)

func (Dict) ReadFromMarshalUtil added in v0.2.0

func (d Dict) ReadFromMarshalUtil(mu *marshalutil.MarshalUtil) error

func (Dict) Set

func (d Dict) Set(key kv.Key, value []byte)

Set sets the value for the key

func (Dict) String

func (d Dict) String() string

func (*Dict) UnmarshalJSON

func (d *Dict) UnmarshalJSON(b []byte) error

func (Dict) WriteToMarshalUtil added in v0.2.0

func (d Dict) WriteToMarshalUtil(mu *marshalutil.MarshalUtil)

type Item

type Item struct {
	Key   string `json:"key" swagger:"desc(key (hex-encoded)),required"`
	Value string `json:"value" swagger:"desc(value (hex-encoded)),required"`
}

Item is a JSON-compatible representation of a single key-value pair

type JSONDict

type JSONDict struct {
	Items []Item
}

JSONDict is the JSON-compatible representation of a Dict

Jump to

Keyboard shortcuts

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