Documentation ¶
Index ¶
- Constants
- func TryConvertToMarshalMap(value interface{}, formatKey func(string) string) interface{}
- type BytePool
- type Float32Slice
- type Int64Slice
- type MarshalMap
- func (mmap MarshalMap) Array(key string) ([]interface{}, error)
- func (mmap MarshalMap) Bool(key string) (bool, error)
- func (mmap MarshalMap) Bytes(key string) ([]byte, error)
- func (mmap MarshalMap) Clone() MarshalMap
- func (mmap MarshalMap) Delete(key string)
- func (mmap MarshalMap) Duration(key string) (time.Duration, error)
- func (mmap MarshalMap) Float(key string) (float64, error)
- func (mmap MarshalMap) Int(key string) (int64, error)
- func (mmap MarshalMap) Int64Array(key string) ([]int64, error)
- func (mmap MarshalMap) Int64Slice(key string) ([]int64, error)
- func (mmap MarshalMap) Map(key string) (map[interface{}]interface{}, error)
- func (mmap MarshalMap) MarshalMap(key string) (MarshalMap, error)
- func (mmap MarshalMap) Set(key string, val interface{})
- func (mmap MarshalMap) Slice(key string) ([]interface{}, error)
- func (mmap MarshalMap) String(key string) (string, error)
- func (mmap MarshalMap) StringArray(key string) ([]string, error)
- func (mmap MarshalMap) StringArrayMap(key string) (map[string][]string, error)
- func (mmap MarshalMap) StringMap(key string) (map[string]string, error)
- func (mmap MarshalMap) StringSlice(key string) ([]string, error)
- func (mmap MarshalMap) StringSliceMap(key string) (map[string][]string, error)
- func (mmap MarshalMap) Uint(key string) (uint64, error)
- func (mmap MarshalMap) Value(key string) (val interface{}, exists bool)
- type TrieNode
- type Uint64Slice
Constants ¶
const ( // MarshalMapSeparator defines the rune used for path separation MarshalMapSeparator = '/' // MarshalMapArrayBegin defines the rune starting array index notation MarshalMapArrayBegin = '[' // MarshalMapArrayEnd defines the rune ending array index notation MarshalMapArrayEnd = ']' )
Variables ¶
This section is empty.
Functions ¶
func TryConvertToMarshalMap ¶
TryConvertToMarshalMap converts collections to MarshalMap if possible. This is a deep conversion, i.e. each element in the collection will be traversed. You can pass a formatKey function that will be applied to all string keys that are detected.
Types ¶
type BytePool ¶
type BytePool struct {
// contains filtered or unexported fields
}
BytePool is a fragmentation friendly way to allocated byte slices.
func NewBytePool ¶
func NewBytePool() BytePool
NewBytePool creates a new BytePool with each slab using 1 MB of storage. The pool contains 5 slabs of different sizes: 64B, 512B, 1KB, 10KB and 100KB. Allocations above 100KB will be allocated directly.
func NewBytePoolWithSize ¶
NewBytePoolWithSize creates a new BytePool with each slab size using n MB of storage. See NewBytePool() for slab size details.
type Float32Slice ¶
type Float32Slice []float32
Float32Slice is a typedef to allow sortable float32 slices
func (Float32Slice) IsSorted ¶
func (s Float32Slice) IsSorted() bool
IsSorted is a shortcut for sort.IsSorted(s)
func (Float32Slice) Len ¶
func (s Float32Slice) Len() int
func (Float32Slice) Less ¶
func (s Float32Slice) Less(i, j int) bool
func (Float32Slice) Set ¶
func (s Float32Slice) Set(v float32)
Set sets all values in this slice to the given value
func (Float32Slice) Swap ¶
func (s Float32Slice) Swap(i, j int)
type Int64Slice ¶
type Int64Slice []int64
Int64Slice is a typedef to allow sortable int64 slices
func (Int64Slice) IsSorted ¶
func (s Int64Slice) IsSorted() bool
IsSorted is a shortcut for sort.IsSorted(s)
func (Int64Slice) Len ¶
func (s Int64Slice) Len() int
func (Int64Slice) Less ¶
func (s Int64Slice) Less(i, j int) bool
func (Int64Slice) Set ¶
func (s Int64Slice) Set(v int64)
Set sets all values in this slice to the given value
func (Int64Slice) Swap ¶
func (s Int64Slice) Swap(i, j int)
type MarshalMap ¶
type MarshalMap map[string]interface{}
MarshalMap is a wrapper type to attach converter methods to maps normally returned by marshalling methods, i.e. key/value parsers. All methods that do a conversion will return an error if the value stored behind key is not of the expected type or if the key is not existing in the map.
func ConvertToMarshalMap ¶
func ConvertToMarshalMap(value interface{}, formatKey func(string) string) (MarshalMap, error)
ConvertToMarshalMap tries to convert a compatible map type to a marshal map. Compatible types are map[interface{}]interface{}, map[string]interface{} and of course MarshalMap. The same rules as for ConvertValueToMarshalMap apply.
func NewMarshalMap ¶
func NewMarshalMap() MarshalMap
NewMarshalMap creates a new marshal map (string -> interface{})
func (MarshalMap) Array ¶
func (mmap MarshalMap) Array(key string) ([]interface{}, error)
Array returns a value at key that is expected to be a []interface{}
func (MarshalMap) Bool ¶
func (mmap MarshalMap) Bool(key string) (bool, error)
Bool returns a value at key that is expected to be a boolean
func (MarshalMap) Bytes ¶ added in v1.0.4
func (mmap MarshalMap) Bytes(key string) ([]byte, error)
Bytes returns a value at key that is expected to be a []byte
func (MarshalMap) Clone ¶ added in v1.0.2
func (mmap MarshalMap) Clone() MarshalMap
Clone creates a copy of the given MarshalMap.
func (MarshalMap) Delete ¶ added in v1.0.3
func (mmap MarshalMap) Delete(key string)
Delete a value from a given path. The path must point to a map key. Deleting from arrays is not supported.
func (MarshalMap) Duration ¶
func (mmap MarshalMap) Duration(key string) (time.Duration, error)
Duration returns a value at key that is expected to be a string
func (MarshalMap) Float ¶
func (mmap MarshalMap) Float(key string) (float64, error)
Float returns a value at key that is expected to be a float64 or compatible float value.
func (MarshalMap) Int ¶
func (mmap MarshalMap) Int(key string) (int64, error)
Int returns a value at key that is expected to be an int64 or compatible integer value.
func (MarshalMap) Int64Array ¶
func (mmap MarshalMap) Int64Array(key string) ([]int64, error)
Int64Array returns a value at key that is expected to be a []int64 This function supports conversion (by copy) from
- []interface{}
func (MarshalMap) Int64Slice ¶ added in v1.0.4
func (mmap MarshalMap) Int64Slice(key string) ([]int64, error)
Int64Slice is an alias for Int64Array
func (MarshalMap) Map ¶
func (mmap MarshalMap) Map(key string) (map[interface{}]interface{}, error)
Map returns a value at key that is expected to be a map[interface{}]interface{}.
func (MarshalMap) MarshalMap ¶
func (mmap MarshalMap) MarshalMap(key string) (MarshalMap, error)
MarshalMap returns a value at key that is expected to be another MarshalMap This function supports conversion (by copy) from
- map[interface{}]interface{}
func (MarshalMap) Set ¶ added in v1.0.3
func (mmap MarshalMap) Set(key string, val interface{})
Set a value for a given path. The path must point to a map key. Setting array elements is not supported.
func (MarshalMap) Slice ¶ added in v1.0.4
func (mmap MarshalMap) Slice(key string) ([]interface{}, error)
Slice is an alias for Array
func (MarshalMap) String ¶
func (mmap MarshalMap) String(key string) (string, error)
String returns a value at key that is expected to be a string
func (MarshalMap) StringArray ¶
func (mmap MarshalMap) StringArray(key string) ([]string, error)
StringArray returns a value at key that is expected to be a []string This function supports conversion (by copy) from
- []interface{}
func (MarshalMap) StringArrayMap ¶
func (mmap MarshalMap) StringArrayMap(key string) (map[string][]string, error)
StringArrayMap returns a value at key that is expected to be a map[string][]string. This function supports conversion (by copy) from
- map[interface{}][]interface{}
- map[interface{}]interface{}
- map[string]interface{}
func (MarshalMap) StringMap ¶
func (mmap MarshalMap) StringMap(key string) (map[string]string, error)
StringMap returns a value at key that is expected to be a map[string]string. This function supports conversion (by copy) from
- map[interface{}]interface{}
- map[string]interface{}
func (MarshalMap) StringSlice ¶ added in v1.0.4
func (mmap MarshalMap) StringSlice(key string) ([]string, error)
StringSlice is an alias for StringArray
func (MarshalMap) StringSliceMap ¶ added in v1.0.4
func (mmap MarshalMap) StringSliceMap(key string) (map[string][]string, error)
StringSliceMap is an alias for StringArrayMap
func (MarshalMap) Uint ¶
func (mmap MarshalMap) Uint(key string) (uint64, error)
Uint returns a value at key that is expected to be an uint64 or compatible integer value.
func (MarshalMap) Value ¶
func (mmap MarshalMap) Value(key string) (val interface{}, exists bool)
Value returns a value from a given value path. Fields can be accessed by their name. Nested fields can be accessed by using "/" as a separator. Arrays can be addressed using the standard array notation "[<index>]". Examples: "key" -> mmap["key"] single value "key1/key2" -> mmap["key1"]["key2"] nested map "key1[0]" -> mmap["key1"][0] nested array "key1[0]key2" -> mmap["key1"][0]["key2"] nested array, nested map
type TrieNode ¶
type TrieNode struct { PathLen int Payload interface{} // contains filtered or unexported fields }
TrieNode represents a single node inside a trie. Each node can contain a payload which can be retrieved after a successfull match. In addition to that PathLen will contain the length of the match.
func (*TrieNode) Add ¶
Add adds a new data path to the trie. The TrieNode returned is the (new) root node so you should always reassign the root with the return value of Add.
func (*TrieNode) ForEach ¶
ForEach applies a function to each node in the tree including and below the passed node.
func (*TrieNode) Match ¶
Match compares the trie to the given data stream. Match returns true if data can be completely matched to the trie.
func (*TrieNode) MatchStart ¶
MatchStart compares the trie to the beginning of the given data stream. MatchStart returns true if the beginning of data can be matched to the trie.
type Uint64Slice ¶
type Uint64Slice []uint64
Uint64Slice is a typedef to allow sortable uint64 slices
func (Uint64Slice) IsSorted ¶
func (s Uint64Slice) IsSorted() bool
IsSorted is a shortcut for sort.IsSorted(s)
func (Uint64Slice) Len ¶
func (s Uint64Slice) Len() int
func (Uint64Slice) Less ¶
func (s Uint64Slice) Less(i, j int) bool
func (Uint64Slice) Set ¶
func (s Uint64Slice) Set(v uint64)
Set sets all values in this slice to the given value
func (Uint64Slice) Swap ¶
func (s Uint64Slice) Swap(i, j int)