Documentation ¶
Overview ¶
Package mframe provides a DataFrame struct and methods to manipulate it. This file contains the Filter and FindFirstByKey methods. The Filter method filters the DataFrame based on a given operator, key, value, and options. The FindFirstByKey method returns the first row that matches a given key.
Index ¶
- func Contains(value, substring string) bool
- func EndsWith(value, suffix string) bool
- func Equals(left, right interface{}) bool
- func InCIDR(value, cidr string) bool
- func InList[v float64 | string, result bool](value v, list []v) result
- func MajorThan(left, right float64) bool
- func MatchesRegExp(value, regExp string) bool
- func StartsWith(value, prefix string) bool
- type BooleansBTree
- type DataFrame
- func (d *DataFrame) Append(df *DataFrame, key string)
- func (d *DataFrame) Average(name, field string) *DataFrame
- func (d *DataFrame) CleanExpired()
- func (d *DataFrame) Count(name string) *DataFrame
- func (d *DataFrame) CountUnique(name, field string) *DataFrame
- func (d *DataFrame) Filter(operator, key string, value interface{}, options map[string]bool) *DataFrame
- func (d *DataFrame) FindFirstByKey(key string) (uuid.UUID, string, interface{})
- func (d *DataFrame) Init(ttl time.Duration)
- func (d *DataFrame) Insert(data map[string]interface{})
- func (d *DataFrame) Max(name, field string) *DataFrame
- func (d *DataFrame) Median(name, field string) *DataFrame
- func (d *DataFrame) Min(name, field string) *DataFrame
- func (d *DataFrame) RemoveElement(id uuid.UUID)
- func (d *DataFrame) SliceOf(field string) []interface{}
- func (d *DataFrame) SliceOfFloat64(field string) []float64
- func (d *DataFrame) Stats(name string)
- func (d *DataFrame) Sum(name, field string) *DataFrame
- func (d *DataFrame) ToSlice() []map[string]interface{}
- func (d *DataFrame) Variance(name, field string) *DataFrame
- type ExpireAtBTree
- type KeysBTree
- type NumericsBTree
- type Row
- type StringsBTree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchesRegExp ¶
func StartsWith ¶
Types ¶
type BooleansBTree ¶
BooleansBTree is a map of string keys to map of boolean keys to map of UUID keys to boolean values.
type DataFrame ¶
type DataFrame struct { Data map[uuid.UUID]Row Keys KeysBTree Strings StringsBTree Numerics NumericsBTree Booleans BooleansBTree ExpireAt ExpireAtBTree Locker sync.RWMutex TTL time.Duration }
DataFrame is a struct that holds data in a map of UUID keys to Row values, and several B-tree maps for indexing.
func (*DataFrame) Append ¶
Append appends the rows of a DataFrame to another DataFrame, adding a key column with the specified key value.
func (*DataFrame) Average ¶
Average returns a new DataFrame with the average of values in a column of the original DataFrame. The name parameter is used to set the name of the new column with the average value. The field parameter is used to specify the name of the column to calculate the average from.
func (*DataFrame) CleanExpired ¶
func (d *DataFrame) CleanExpired()
CleanExpired removes elements from the DataFrame that have expired based on their expiration time. It runs in an infinite loop, checking for expired elements every second.
func (*DataFrame) Count ¶
Count returns a new DataFrame with the count of rows in the original DataFrame. The name parameter is used to set the name of the new column with the count value.
func (*DataFrame) CountUnique ¶
CountUnique returns a new DataFrame with the count of unique values in a column of the original DataFrame. The name parameter is used to set the name of the new column with the count value. The field parameter is used to specify the name of the column to count unique values from.
func (*DataFrame) Filter ¶
func (d *DataFrame) Filter(operator, key string, value interface{}, options map[string]bool) *DataFrame
Filter filters the DataFrame based on a given operator, key, value, and options. The supported operators are: - "==": equal to - "!=": not equal to - ">": greater than - "<": less than - ">=": greater than or equal to - "<=": less than or equal to - "in list": in list of values - "not in list": not in list of values - "regexp": matches regular expression - "not regexp": does not match regular expression - "in cidr": in CIDR range - "not in cidr": not in CIDR range - "contains": contains substring - "not contains": does not contain substring
func (*DataFrame) FindFirstByKey ¶
FindFirstByKey returns the first row that matches a given key.
func (*DataFrame) Insert ¶
Insert adds a new row to the DataFrame with the given data. The data is a map of string keys to interface{} values. The function indexes the data and adds it to the DataFrame. The function also generates a new UUID for the row and sets its expiration time. The function is thread-safe and uses a mutex to protect the DataFrame from concurrent writes.
func (*DataFrame) Max ¶
Max returns a new DataFrame with the maximum value in a column of the original DataFrame. The name parameter is used to set the name of the new column with the maximum value. The field parameter is used to specify the name of the column to find the maximum value from.
func (*DataFrame) Median ¶
Median returns a new DataFrame with the median of values in a column of the original DataFrame. The name parameter is used to set the name of the new column with the median value. The field parameter is used to specify the name of the column to calculate the median from.
func (*DataFrame) Min ¶
Min returns a new DataFrame with the minimum value in a column of the original DataFrame. The name parameter is used to set the name of the new column with the minimum value. The field parameter is used to specify the name of the column to find the minimum value from.
func (*DataFrame) RemoveElement ¶
RemoveElement removes an element from the DataFrame by its ID. It deletes the element from the Data, ExpireAt, Strings, Numerics, and Booleans maps.
func (*DataFrame) SliceOf ¶
SliceOf returns a slice of interface{} representing the values of a specific field in the DataFrame.
func (*DataFrame) SliceOfFloat64 ¶
SliceOfFloat64 returns a slice of float64 representing the values of a specific field in the DataFrame. If a value cannot be converted to float64, it is skipped.
func (*DataFrame) Sum ¶
Sum returns a new DataFrame with the sum of values in a column of the original DataFrame. The name parameter is used to set the name of the new column with the sum value. The field parameter is used to specify the name of the column to sum values from.
func (*DataFrame) ToSlice ¶
ToSlice returns a slice of maps representing the DataFrame's data. Each map contains the column names as keys and the corresponding row values as values.
func (*DataFrame) Variance ¶
Variance returns a new DataFrame with the variance of values in a column of the original DataFrame. The name parameter is used to set the name of the new column with the variance value. The field parameter is used to specify the name of the column to calculate the variance from.
type ExpireAtBTree ¶
ExpireAtBTree is a map of UUID keys to time.Time values.
type NumericsBTree ¶
NumericsBTree is a map of string keys to map of float64 keys to map of UUID keys to boolean values.