Documentation
¶
Index ¶
- func Average(records []*api.Record, path string) (*float64, error)
- func Confidence(records []*api.Record, path string, caseSensitive bool) (*float64, error)
- func Count(records []*api.Record) int
- func CountDistinct(records []*api.Record, paths []string, caseSensitive bool) (int, error)
- func Extract(record *api.Record, path string) any
- func ExtractArray(record *api.Record, path string) ([]any, error)
- func ExtractNumber(record *api.Record, path string) (*float64, error)
- func ExtractString(record *api.Record, path string, caseSensitive bool) (*string, error)
- func ExtractTime(record *api.Record, path string) (*time.Time, error)
- func Filter(records []*api.Record, conditions []*FilterCondition) ([]*api.Record, error)
- func First(records []*api.Record) *api.Record
- func Flatten(records []*api.Record, path string) ([]any, error)
- func FlattenDistinct(records []*api.Record, path string, caseSensitive bool) ([]any, error)
- func Group(records []*api.Record, paths []string, caseSensitive bool) ([][]*api.Record, error)
- func Last(records []*api.Record) *api.Record
- func Limit(records []*api.Record, count int, offset int) []*api.Record
- func Max(records []*api.Record, path string) (*float64, error)
- func Median(records []*api.Record, path string) (*float64, error)
- func Min(records []*api.Record, path string) (*float64, error)
- func Newest(records []*api.Record, path string) (*api.Record, error)
- func Oldest(records []*api.Record, path string) (*api.Record, error)
- func Sort(records []*api.Record, criteria []*SortCriteria) ([]*api.Record, error)
- func StandardDeviation(records []*api.Record, path string) (*float64, error)
- func Sum(records []*api.Record, path string) (*float64, error)
- func Values(records []*api.Record, path string) []any
- func ValuesDistinct(records []*api.Record, path string, caseSensitive bool) ([]any, error)
- type FilterCondition
- type FrequencyDistributionEntry
- type SortCriteria
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Average ¶
Average returns the average value of the provided numeric path.
Using average on non-numeric paths will raise an error. Null values are ignored in the calculation. Returns null if all values are null.
func Confidence ¶
Confidence describes the probability of having the one truly correct value for the provided path.
The resulting value is a float ranging from 0 to 1 representing a percentage.
Example: For the values ["a","a","a","b"]
a: 3 * 0.75
b: 1 * 0.25
confidence: 62.5%
Null values are ignored in the calculation. Returns null if all values are null.
func Count ¶
Count returns the amount of records in the provided list.
Entries with nil values will be counted just as any non-nil entry.
func CountDistinct ¶
CountDistinct returns the number of unique non-null values for the provided path.
If multiple paths were provided, then each unique combination of the path values will be considered. If all paths are null, then this does not count as a new value. However, if at least one path has a value, then this does count as a new value.
func ExtractArray ¶
ExtractArray provides an array value of a record for the given path.
func ExtractNumber ¶
ExtractNumber provides a numeric value of a record for the given path.
func ExtractString ¶
ExtractString provides a string value of a record for the given path.
If the value of that path is an array or a map, it will stringify the value into JSON.
func ExtractTime ¶
ExtractTime provides a time value of a record for the given path.
func Filter ¶
Filter returns a new RecordInsights that only contains the records for which the FilterCondition applies.
If no records match the filter condition, then an empty RecordInsights is returned.
func Flatten ¶
Flatten merges the array on the given path of all records into a single array.
Using flatten on non-array fields will raise an error.
func FlattenDistinct ¶
FlattenDistinct merges the array on the given path of all records into a single array where each value is unique.
Using flatten on non-array fields will raise an error.
By default, the case of the value is ignored.
func Group ¶
Group returns a list of record lists where the records have been grouped by the provided paths.
func Limit ¶
Limit returns a new record list that contains up to 'count' records.
By default it takes the first records from the list. If offset was provided it will skip 'offset' records.
If the list does not provide enough records, then an empty list is returned.
func Max ¶
Max returns the highest value of the provided numeric path.
Returns null if all values are null.
func Median ¶
Median returns the median value of the provided numeric path.
Using median on non-numeric paths will raise an error. Null values are ignored in the calculation. Returns null if all values are null.
func Min ¶
Min returns the lowest value of the provided numeric path.
Using min on non-numeric paths will raise an error. Returns null if all values are null.
func Newest ¶
Newest returns the Record for where the provided time path has the highest (most recent) value.
Returns null if the list is empty or does not contain records with the provided path.
Using newest on non-time paths will raise an error.
func Oldest ¶
Oldest returns the Record for where the provided time path has the lowest (least recent) value.
Returns null if the list is empty or does not contain records with the provided path.
Using oldest on non-time paths will raise an error.
func Sort ¶
Sort returns a new RecordInsights that contains the records ordered by the provided SortCriteria.
func StandardDeviation ¶
StandardDeviation calculates the standard deviation for the provided numeric path.
Using standardDeviation on non-numeric paths will raise an error. Null values are ignored in the calculation. Returns null if all values are null.
func Sum ¶
Sum returns the sum of the provided numeric path.
Using sum on non-numeric paths will raise an error. Null values are ignored in the calculation. Returns null if all values are null.
Types ¶
type FilterCondition ¶
type FilterCondition struct { Path string Equals any IsNull *bool StartsWith *string EndsWith *string LikeRegex *string LessThan *float64 LessEquals *float64 GreaterThan *float64 GreaterEquals *float64 After *time.Time Since *time.Time Before *time.Time Until *time.Time Invert *bool CaseSensitive *bool }
FilterCondition defines the criteria for filtering a record list.
Each filter condition must have a filter upon which the checks are applied and should have at least one criteria defined.
Some criteria are mutually exclusive due to either logical reasons or type constraints. E.g. lessThan and after cannot be used together due to different type expectations.
type FrequencyDistributionEntry ¶
type FrequencyDistributionEntry struct { Value any `json:"value"` Frequency int `json:"frequency"` Percentage float64 `json:"percentage"` // contains filtered or unexported fields }
FrequencyDistributionEntry represents a single row of a frequency distribution table.
func FrequencyDistribution ¶
func FrequencyDistribution(records []*api.Record, path string, caseSensitive bool, top int, sortASC bool) ([]*FrequencyDistributionEntry, error)
FrequencyDistribution returns how often a non-null value for the provided field is present.
By default, the results are ordered with the highest percentage first, but it can be changed using the 'sortASC' option.
Using the 'top' option it is possible to limit the results to only the n highest or lowest results.
Values with with equal frequency will always be returned in the order of the first occurrence for that value.
type SortCriteria ¶
SortCriteria defines how to sort.