dict

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: Apache-2.0, BSD-2-Clause Imports: 10 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 FromKVStore

func FromKVStore(s kv.KVStore) (Dict, error)

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, error)

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

func (Dict) Has

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

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

Iterate over keys with prefix

func (Dict) IterateKeys

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

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

func (Dict) IterateSorted added in v0.2.0

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

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

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

MustGet retrieves value by key

func (Dict) MustHas

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

MustHas checks if the value exists

func (Dict) MustIterate

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

MustIterate iterated of key/value pairs. In general, non-deterministic

func (Dict) MustIterateKeys

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

MustIterateKeys iterated of keys of the dictionary. In general, non-deterministic

func (Dict) MustIterateKeysSorted added in v0.2.0

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

func (Dict) MustIterateSorted added in v0.2.0

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

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 `swagger:"desc(Key (base64-encoded))"`
	Value string `swagger:"desc(Value (base64-encoded))"`
}

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