dict

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: 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 FromGoMap

func FromGoMap(d map[kv.Key][]byte) Dict

FromGoMap casts map to Dict

func FromKVStore

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

FromKVStore convert (copy) any KVStore to dict

func New

func New() Dict

New creates new

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

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

ForEachDeterministic iterates in the order of alphabetically sorted keys

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

func (d Dict) Read(r io.Reader) 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) Write

func (d Dict) Write(w io.Writer) error

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