stream

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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

func MergeDataStreams(s1 Record, s2 Record, allowOverwrite bool) (Record, error)

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

func (sr Record) CopyTo(t Record)

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

func (sr Record) GetData(name string) interface{}

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

func (sr Record) GetDataAsStringPreserveTimeZone(log logger.Logger, name string) (retval string)

GetDataAsStringPreserveTimeZone will convert interface{} value to a string. Times will be in local time.

func (Record) GetDataAsStringSlice

func (sr Record) GetDataAsStringSlice(log logger.Logger) []string

func (Record) GetDataAsStringUseUtcTime

func (sr Record) GetDataAsStringUseUtcTime(log logger.Logger, name string) (retval string)

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

func (sr Record) GetDataKeysAsSlice(log logger.Logger, keys []string) []string

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 (sr Record) GetDataLen() int

func (Record) GetDataMap

func (sr Record) GetDataMap() map[string]interface{}

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

func (sr Record) GetJson(log logger.Logger, keys []string) string

GetJson returns the JSON representation of sr.data using the supplied keys to fetch the data.

func (Record) GetSortedDataMapKeys

func (sr Record) GetSortedDataMapKeys() []string

GetSortedDataMapKeys will return a slice of the keys found in map sr.data.

func (Record) RecordIsNil

func (sr Record) RecordIsNil() bool

func (Record) SetData

func (sr Record) SetData(name string, value interface{})

Jump to

Keyboard shortcuts

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