statistics

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CondColumn

type CondColumn struct {
	Field string
	Icon  string
}

条件字条 =,!,>,<

type CondDateReduceResult

type CondDateReduceResult map[string]DateReduceResult

计算条件结果集

type CondMapData

type CondMapData map[*MapCond]MapData

条件数据集合

type CondReduceResult

type CondReduceResult map[string]ReduceResult

计算条件结果集

type DateReduceResult

type DateReduceResult map[int]map[string]map[int]ReduceResult

计算条件时间结果集

type MapCond

type MapCond struct {
	Name      string  //条件名称
	Condition utils.M //条件数据
	IsAll     bool    //是否全部数据统计
}

条件类型

func NewMapCond

func NewMapCond(name string, cond_data utils.M, is_all bool) *MapCond

创建一个统计条件类

func (*MapCond) Compared

func (mc *MapCond) Compared(v1, v2 interface{}, icon string) bool

以传入的条件对比两个值

func (*MapCond) Valid

func (mc *MapCond) Valid(data utils.M) bool

验证数据是否满足条件

type MapData

type MapData map[string][]*MapValue

数据集合

type MapReduce

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

统计功能类

func NewMapReduce

func NewMapReduce() *MapReduce

创建统计功能实体类

func (*MapReduce) Map

func (u *MapReduce) Map(key string, data utils.M, conditions []*MapCond)

分类数据

func (*MapReduce) Reduce

func (u *MapReduce) Reduce() CondReduceResult

最后返回MAP后的计算结果

func (*MapReduce) ReduceDate

func (u *MapReduce) ReduceDate() CondDateReduceResult

返回带时间周期的计算结果集 以年,月,周,日的统计结果

func (*MapReduce) Run

func (u *MapReduce) Run(keys []string, data []utils.M, conditions []*MapCond)

开始运行统计

func (*MapReduce) SetDateColumn

func (u *MapReduce) SetDateColumn(key string)

设置记录时间字段

type MapValue

type MapValue struct {
	Value    interface{}
	Datetime *StatDate
}

MAP带时间值

type ReduceResult

type ReduceResult map[string]*ReduceValue

计算结果集

type ReduceValue

type ReduceValue struct {
	Count int     //计算个数
	Value float64 //计算合值
}

计算结果值

func (*ReduceValue) Add

func (r *ReduceValue) Add(val *ReduceValue)

reduce相加

type Stat

type Stat interface {
	Map(data interface{}) interface{}
	Reduce(data interface{}) interface{}
}

type StatDate

type StatDate struct {
	Year    int //年
	Month   int //月
	Week    int //年中第几周
	Day     int //月份中的第几天
	YearDay int //年份中的第几天
}

统计时间

func NewStatDate

func NewStatDate(unix_time interface{}) *StatDate

新创建一个统计时间

Jump to

Keyboard shortcuts

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