Documentation ¶
Overview ¶
Package bytemap provides a map[string]interface{} encoded as a byte slice.
Index ¶
- Constants
- type ByteMap
- func Build(iterate func(func(string, interface{})), valueFor func(string) interface{}, ...) ByteMap
- func FromSortedKeysAndFloats(keys []string, values []float64) ByteMap
- func FromSortedKeysAndValues(keys []string, values []interface{}) ByteMap
- func New(m map[string]interface{}) ByteMap
- func NewFloat(m map[string]float64) ByteMap
- func (bm ByteMap) AsMap() map[string]interface{}
- func (bm ByteMap) Get(key string) interface{}
- func (bm ByteMap) GetBytes(key string) []byte
- func (bm ByteMap) Iterate(includeValue bool, includeBytes bool, ...)
- func (bm ByteMap) IterateValueBytes(cb func(key string, valueBytes []byte) bool)
- func (bm ByteMap) IterateValues(cb func(key string, value interface{}) bool)
- func (bm ByteMap) Slice(includeKeys map[string]bool) ByteMap
- func (bm ByteMap) Split(includeKeys map[string]bool) (ByteMap, ByteMap)
Constants ¶
const ( TypeNil = iota TypeBool TypeByte TypeUInt16 TypeUInt32 TypeUInt64 TypeInt8 TypeInt16 TypeInt32 TypeInt64 TypeInt TypeFloat32 TypeFloat64 TypeString TypeTime TypeUInt TypeBytes TypeFloat64s TypeInts )
const ( SizeKeyLen = 2 SizeValueType = 1 SizeValueOffset = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteMap ¶
type ByteMap []byte
ByteMap is an immutable map[string]interface{} backed by a byte array.
func Build ¶
func Build(iterate func(func(string, interface{})), valueFor func(string) interface{}, iteratesSorted bool) ByteMap
Build builds a new ByteMap using a function that iterates over all included key/value paris and another function that returns the value for a given key/ index. If iteratesSorted is true, then the iterate order of iterate is considered to be in lexicographically sorted order over the keys and is stable over multiple invocations, and valueFor is not needed.
func FromSortedKeysAndFloats ¶
FromSortedKeysAndFloats constructs a ByteMap from sorted keys and float values.
func FromSortedKeysAndValues ¶
FromSortedKeysAndValues constructs a ByteMap from sorted keys and values.
func (ByteMap) GetBytes ¶
GetBytes gets the bytes slice for the given key, or nil if the key is not found.
func (ByteMap) Iterate ¶
func (bm ByteMap) Iterate(includeValue bool, includeBytes bool, cb func(key string, value interface{}, valueBytes []byte) bool)
Iterate iterates over the key/value pairs in this ByteMap and calls the given callback with each. If the callback returns false, iteration stops even if there remain unread values. includeValue and includeBytes determine whether to include the value, the bytes or both in the callback.
func (ByteMap) IterateValueBytes ¶
IterateValueBytes iterates over the key/value bytes pairs in this ByteMap and calls the given callback with each. If the callback returns false, iteration stops even if there remain unread values.
func (ByteMap) IterateValues ¶
IterateValues iterates over the key/value pairs in this ByteMap and calls the given callback with each. If the callback returns false, iteration stops even if there remain unread values.