objectmap

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressMatchKey

func AddressMatchKey(address []int) string

func ExtendAddress

func ExtendAddress(address []int, index ...int) []int

func GetNestedAttributeByAddress

func GetNestedAttributeByAddress(
	v interface{}, attrAddress []int) interface{}

Types

type AttrDictionaryRec

type AttrDictionaryRec struct {
	Address []int
	// contains filtered or unexported fields
}

func (*AttrDictionaryRec) AddressToDictionaryRec

func (dictRec *AttrDictionaryRec) AddressToDictionaryRec(address []int) *AttrDictionaryRec

func (*AttrDictionaryRec) AddressToFullAddress

func (dictRec *AttrDictionaryRec) AddressToFullAddress(address []int) []int

func (*AttrDictionaryRec) AddressToFullPath

func (dictRec *AttrDictionaryRec) AddressToFullPath(address []int) string

func (*AttrDictionaryRec) AttributePathToAddress

func (dictRec *AttrDictionaryRec) AttributePathToAddress(attrPath string) ([]int, error)

AttributePathToAddress

AttributePathToAddress indexes a leaf attribute name for fast lookup and efficient object representation. LeafAttribute here denotes an attribute that is either a scalar value or an array, but not a struct. Attributes that point to nested objects are registered together with the nested objects' attributes using flattened dotted notation. For example, consider the following Json structure:

{
  "person": {
    "name": "John",
    "age": 25,
    "children": [
      {
        "name": "Jane",
        "age": 3
      },
      {
        "name": "Jim",
        "age": 1
      }
    ]
  }
}

Assuming that all the structure's attributes are referenced, it will be mapped to the following attributes:

"person.name"
"person.age"
"person.children[]"

Note that "person" is not mapped as it is not a leaf attribute. Neither is "person.children.name" mapped, as we stop at the first array attribute, using [] suffix to indicate that the value is an array and not a scalar.

type AttributeAddress

type AttributeAddress struct {
	Address []int

	// Keep the original Path string around in case we need to issue an error message
	Path string

	// ParentParameterIndex: index into the parentParameter array pointing to the parent Address value
	// The attribute Address is a concatenation of this value and the Address above
	ParentParameterIndex int

	// FullAddress is used for matching an attribute Address with the filters that use it.
	// It may not have the actual values of array indexes when used inside "for each" loops.
	FullAddress []int
}

type MapperConfig

type MapperConfig interface {
	MapScalar(interface{}) interface{}
	GetAppCtx() *types.AppContext
}

type ObjectAttributeMap

type ObjectAttributeMap struct {
	DictRec *AttrDictionaryRec
	Values  []interface{}
}

func (*ObjectAttributeMap) GetAttribute

func (attrMap *ObjectAttributeMap) GetAttribute(attrPath string) (interface{}, error)

func (*ObjectAttributeMap) GetAttributeByAddress

func (attrMap *ObjectAttributeMap) GetAttributeByAddress(attrAddress []int, frame interface{}) (interface{}, error)

func (*ObjectAttributeMap) GetNumElementsAtAddress

func (attrMap *ObjectAttributeMap) GetNumElementsAtAddress(address *AttributeAddress, frames []interface{}) (int, error)

type ObjectAttributeMapper

type ObjectAttributeMapper struct {
	RootDictRec *AttrDictionaryRec
	Ctx         *types.AppContext
	Config      MapperConfig
	// contains filtered or unexported fields
}

ObjectAttributeMapper object indexes object field names used in general filters. It then uses these indexes to create EventAttributeMap object representation that only store the fields referenced by the filters. EventAttributeMap also allows fast access to these fields when evaluating filters.

func NewObjectAttributeMapper

func NewObjectAttributeMapper(config MapperConfig) *ObjectAttributeMapper

func (*ObjectAttributeMapper) FreeObjects

func (mapper *ObjectAttributeMapper) FreeObjects()

func (*ObjectAttributeMapper) MapObject

func (mapper *ObjectAttributeMapper) MapObject(v interface{}, attrCallback func([]int)) *ObjectAttributeMap

func (*ObjectAttributeMapper) NewObjectAttributeMap

func (mapper *ObjectAttributeMapper) NewObjectAttributeMap() *ObjectAttributeMap

type PathSegment

type PathSegment struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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