Documentation ¶
Index ¶
- type FieldType
- type Record
- func (sr Record) CopyTo(t Record)
- func (sr Record) DataCanJoinByKeyFields(log logger.Logger, targetRec Record, joinKeys *om.OrderedMap) (retval int)
- func (sr Record) DataIsDeepEqual(log logger.Logger, targetRec Record, compareKeys *om.OrderedMap) (retval bool)
- func (sr Record) GetData(name string) interface{}
- func (sr Record) GetDataAndFieldTypesByKeys(log logger.Logger, keys *om.OrderedMap, l *[]interface{}, t *[]FieldType, ...)
- func (sr Record) GetDataAsStringPreserveTimeZone(log logger.Logger, name string) (retval string)
- func (sr Record) GetDataAsStringSlice(log logger.Logger) []string
- func (sr Record) GetDataAsStringUseUtcTime(log logger.Logger, name string) (retval string)
- func (sr Record) GetDataKeysAsSlice(log logger.Logger, keys []string) []string
- func (sr Record) GetDataLen() int
- func (sr Record) GetDataMap() map[string]interface{}
- func (sr Record) GetDataToColArray(log logger.Logger, keys *om.OrderedMap, t *[][]interface{}, idx *int)
- func (sr Record) GetJson(log logger.Logger, keys []string) string
- func (sr Record) GetSortedDataMapKeys() []string
- func (sr Record) RecordIsNil() bool
- func (sr Record) SetData(name string, value interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldType ¶
type FieldType struct { DatabaseType string HasNullable bool HasLength bool HasPrecisionScale bool Nullable bool Length int64 Precision int64 Scale int64 }
Metadata about a field in Record -> Data.
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record is used to communicate data between components.
func MergeDataStreams ¶
MergeDataStreams will combine records from s1 into a new record, followed by s2 into the new record before returning it. You can supply a nil s2 to create a copy of s1 that is returned. If allowOverwrite is true, an error is returned if a field in s2 already exists in s1.
func NewNilRecord ¶
func NewNilRecord() Record
func NewRecord ¶
func NewRecord() Record
NewRecord creates a new Record and returns it by value as we expect these records to go over channels by value too. Apparently passing pointers to a channel is slower than by value, but I wonder if this is true when maps are pointers anyway. https://stackoverflow.com/questions/41178729/why-passing-pointers-to-channel-is-slower https://segment.com/blog/allocation-efficiency-in-high-performance-go-services/
func (Record) DataCanJoinByKeyFields ¶
func (sr Record) DataCanJoinByKeyFields(log logger.Logger, targetRec Record, joinKeys *om.OrderedMap) (retval int)
DataCanJoinByKeyFields compares two input maps (m1 and m2) using key fields for equality (return 0) less-than (return -1) or greater-than (return 1) status where return values are: -1 if m1 is less than m2
0 if m1 matches m2 1 if m1 is greater than m2
func (Record) DataIsDeepEqual ¶
func (sr Record) DataIsDeepEqual(log logger.Logger, targetRec Record, compareKeys *om.OrderedMap) (retval bool)
DataIsDeepEqual compares two maps for equality using reflect.DeepEqual. Return TRUE for equality else false. Specify the keys to use for the comparison in ordered dict, compareKeys. Example: use contents of compareKeys["X"]="Y" to check if m1["X"] == m2["Y"] and repeat for all of the map contents. TODO: test handling of nested maps.
func (Record) GetDataAndFieldTypesByKeys ¶
func (sr Record) GetDataAndFieldTypesByKeys(log logger.Logger, keys *om.OrderedMap, l *[]interface{}, t *[]FieldType, idx *int)
GetDataAndFieldTypesByKeys builds a list of data values found in the supplied 'sr' Record using the keys supplied. Output: this function modifies the supplied lists 'l', 't' and 'idx' by reference. 'idx' is the last index in the slice 'l' that is populated. 'mapKeys' is the map whose keys are field names in sr.data, while its values are database table field names.
func (Record) GetDataAsStringPreserveTimeZone ¶
GetDataAsStringPreserveTimeZone will convert interface{} value to a string. Times will be in local time.
func (Record) GetDataAsStringSlice ¶
func (Record) GetDataAsStringUseUtcTime ¶
GetStringFromInterfacePreserveTimeZone will convert interface{} value to a string for the purposes of gt/lt comparison. Times will be converted to UTC for string comparison!
func (Record) GetDataKeysAsSlice ¶
GetDataKeysAsSlice builds a slice of strings containing the values found in sr.data for each of the supplied keys in slice keys.
func (Record) GetDataLen ¶
func (Record) GetDataMap ¶
func (Record) GetDataToColArray ¶
func (sr Record) GetDataToColArray(log logger.Logger, keys *om.OrderedMap, t *[][]interface{}, idx *int)
GetDataToColArray fetches from the Record values for each key in keys, placing the data in the target slice t. The slice t must be pre-allocated by the caller. idx is the position in t that we start to populate with data from the Record. For example, where *t is the [][]interface{} this is an array of column arrays and (*t)[0] is the first column.
func (Record) GetJson ¶
GetJson returns the JSON representation of sr.data using the supplied keys to fetch the data.
func (Record) GetSortedDataMapKeys ¶
GetSortedDataMapKeys will return a slice of the keys found in map sr.data.