histogram

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SortNameAsc   = maputil.SortNameAsc
	SortNameDesc  = maputil.SortNameDesc
	SortValueAsc  = maputil.SortValueAsc
	SortValueDesc = maputil.SortValueDesc
)

Variables

This section is empty.

Functions

func HistogramSetTimeKeyCount added in v1.5.0

func HistogramSetTimeKeyCount(hset HistogramSet) (statictimeseries.DataSeries, error)

HistogramSetTimeKeyCount returns a DataSeries when the first key is a RFC3339 time and a sum of items is desired per time.

func HistogramSetTimeKeyCountTable added in v1.5.0

func HistogramSetTimeKeyCountTable(hset HistogramSet, interval timeutil.Interval, countColName string) (table.Table, error)

func HistogramSetTimeKeyCountWriteXLSX added in v1.5.0

func HistogramSetTimeKeyCountWriteXLSX(filename string, hset HistogramSet, interval timeutil.Interval, countColName string) error

Types

type Histogram

type Histogram struct {
	Name        string
	Bins        map[string]int
	Counts      map[string]int // how many items have counts.
	Percentages map[string]float64
	BinCount    uint
	Sum         int
}

Histogram stats is used to count how many times an item appears and how many times number of appearances appear.

func NewHistogram

func NewHistogram(name string) *Histogram

func ParseFileCSV added in v1.4.0

func ParseFileCSV(file string, name string, binNameColIdx, binFrequencyColIdx uint) (*Histogram, error)

ParseFileCSV reads a CSV using default settings of `,` separator, header row and BOM to be stripped. If you have other configurations, use `table.ReadFile()` directly and call `HistogramFromTable()`.

func ParseTable added in v1.4.0

func ParseTable(tbl table.Table, binNameColIdx, binFrequencyColIdx uint) (*Histogram, error)

ParseTable parses a `table.Table` to a `Histogram` given a table, binName column index and binFrequency column index. Empty rows are skipped.

func (*Histogram) Add

func (hist *Histogram) Add(binName string, binCount int)

func (*Histogram) BinNameExists added in v1.5.0

func (hist *Histogram) BinNameExists(binName string) bool

func (*Histogram) BinNames added in v1.5.0

func (hist *Histogram) BinNames() []string

func (*Histogram) Inflate

func (hist *Histogram) Inflate()

func (*Histogram) ItemCount added in v1.5.0

func (hist *Histogram) ItemCount() uint

ItemCount returns the number of bins.

func (*Histogram) ItemCounts added in v1.5.0

func (hist *Histogram) ItemCounts(sortBy string) []maputil.Record

ItemCounts returns sorted item names and values.

func (*Histogram) Stats added in v1.5.0

func (hist *Histogram) Stats() point.PointSet

func (*Histogram) ToTable added in v1.5.0

func (hist *Histogram) ToTable(colNameBinName, colNameBinCount string) *table.Table

func (*Histogram) TotalCount added in v1.5.0

func (hist *Histogram) TotalCount() uint64

func (*Histogram) TransformBinNames added in v1.5.0

func (hist *Histogram) TransformBinNames(xfFunc func(input string) string) *Histogram

TransformBinNames modifies bin names and returns a new histogram.

func (*Histogram) TransformBinNamesByPrefix added in v1.5.0

func (hist *Histogram) TransformBinNamesByPrefix(xfMap map[string]string) *Histogram

TransformBinNamesByPrefix modifies bin names and returns a new histogram.

func (*Histogram) TransformBinNamesExactMatch added in v1.5.0

func (hist *Histogram) TransformBinNamesExactMatch(xfMap map[string]string) *Histogram

TransformBinNamesExactMatch modifies bin names and returns a new histogram.

func (*Histogram) WriteTableASCII added in v1.5.0

func (hist *Histogram) WriteTableASCII(writer io.Writer, header []string, sortBy string, inclTotal bool)

WriteTable writes an ASCII Table. For CLI apps, pass `os.Stdout` for `io.Writer`.

func (*Histogram) WriteXLSX added in v1.5.0

func (hist *Histogram) WriteXLSX(filename, sheetname, colNameBinName, colNameBinCount string) error

type HistogramSet

type HistogramSet struct {
	Name         string
	HistogramMap map[string]*Histogram
	KeyIsTime    bool
}

func HistogramSetDatetimeToQuarter added in v1.5.0

func HistogramSetDatetimeToQuarter(name string, fsetIn *HistogramSet) (*HistogramSet, error)

HistogramSetDatetimeToQuarter converts a HistogramSet by date to one by quarter.s.

func NewHistogramSet

func NewHistogramSet(name string) *HistogramSet

func NewHistogramSetWithData added in v1.5.0

func NewHistogramSetWithData(name string, data map[string]map[string]int) *HistogramSet

func (*HistogramSet) Add

func (hset *HistogramSet) Add(histName, binName string, count int)

func (*HistogramSet) AddDateUidCount added in v1.5.0

func (hset *HistogramSet) AddDateUidCount(dt time.Time, uid string, count int)

func (*HistogramSet) BinNameExists added in v1.5.0

func (hset *HistogramSet) BinNameExists(binName string) bool

func (*HistogramSet) HistogramBinNames added in v1.5.0

func (hset *HistogramSet) HistogramBinNames(setName string) []string

func (*HistogramSet) HistogramNameExists added in v1.5.0

func (hset *HistogramSet) HistogramNameExists(histName string) bool

func (*HistogramSet) HistogramNames added in v1.5.0

func (hset *HistogramSet) HistogramNames() []string

HistogramNames returns the number of histograms.

func (*HistogramSet) ItemCount added in v1.5.0

func (hset *HistogramSet) ItemCount() uint

ItemCount returns the number of histograms.

func (*HistogramSet) ItemCounts added in v1.5.0

func (hset *HistogramSet) ItemCounts() *Histogram

ItemCounts returns the number of histograms.

func (*HistogramSet) ItemNames added in v1.5.0

func (hset *HistogramSet) ItemNames() []string

ItemNames returns the number of histograms. Alias for `HistogramNames()`.

func (*HistogramSet) LeafStats added in v1.5.0

func (hset *HistogramSet) LeafStats(name string) *Histogram

func (*HistogramSet) ToDataSeriesDistinct added in v1.5.0

func (hset *HistogramSet) ToDataSeriesDistinct() (statictimeseries.DataSeries, error)

func (*HistogramSet) TotalCount added in v1.5.0

func (hset *HistogramSet) TotalCount() uint64

func (*HistogramSet) TransformHistogramNames added in v1.5.0

func (hset *HistogramSet) TransformHistogramNames(xfFunc func(input string) string) *HistogramSet

TransformHistogramNames modifies histogram names and returns a new histogram set.

func (*HistogramSet) TransformHistogramNamesByPrefix added in v1.5.0

func (hset *HistogramSet) TransformHistogramNamesByPrefix(xfMap map[string]string) *HistogramSet

TransformHistogramNamesByPrefix modifies bin names and returns a new histogram.

func (*HistogramSet) TransformHistogramNamesExactMatch added in v1.5.0

func (hset *HistogramSet) TransformHistogramNamesExactMatch(xfMap map[string]string) *HistogramSet

TransformHistogramNamesExactMatch modifies bin names and returns a new histogram.

func (*HistogramSet) WriteXLSX added in v1.5.0

func (hset *HistogramSet) WriteXLSX(path, colName1, colName2, colNameCount string) error

type HistogramSetMetadata

type HistogramSetMetadata struct {
	Names          []string `json:"names,omitempty"`
	NameCount      int      `json:"nameCount,omitempty"`
	UniqueBinCount int      `json:"uniqueBinCount,omitempty"`
}

func NewHistogramSetMetadata

func NewHistogramSetMetadata(histSet *HistogramSet) *HistogramSetMetadata

type HistogramSets added in v1.5.0

type HistogramSets struct {
	Name            string
	HistogramSetMap map[string]*HistogramSet
}

func NewHistogramSets added in v1.5.0

func NewHistogramSets() *HistogramSets

func NewHistogramSetsCSVs added in v1.5.0

func NewHistogramSetsCSVs(filenames []string, key1ColIdx, key2ColIdx, uidColIdx uint) (*HistogramSets, table.Table, error)

NewHistogramSetsCSVs expects multiple files to have same columns.

func NewHistogramSetsTable added in v1.5.0

func NewHistogramSetsTable(tbl table.Table, key1ColIdx, key2ColIdx, uidColIdx uint) (*HistogramSets, error)

func (*HistogramSets) Add added in v1.5.0

func (hsets *HistogramSets) Add(setKey1, setKey2, binName string, binValue int, trimSpace bool)

func (*HistogramSets) Counts added in v1.5.0

func (hsets *HistogramSets) Counts() *HistogramSetsCounts

func (*HistogramSets) Flatten added in v1.5.0

func (hsets *HistogramSets) Flatten(name string) *HistogramSet

func (*HistogramSets) ItemCount added in v1.5.0

func (hsets *HistogramSets) ItemCount() uint

ItemCount returns the number of histogram sets.

type HistogramSetsCounts added in v1.5.0

type HistogramSetsCounts struct {
	UidCounts     map[string]map[string]uint
	UidCountsKey1 map[string]uint
	UidCountsKey2 map[string]uint
	Key1Names     []string
	Key2Names     []string
}

HistogramSetsCounts returns UID counts. When used with NewHistogramSetsCSV(), it can provide a sanity check for raw record counts against aggregate query values, e.g. compare counts of raw records to GROUP BY counts.

func NewHistogramSetsCounts added in v1.5.0

func NewHistogramSetsCounts(hsets HistogramSets) *HistogramSetsCounts

func (*HistogramSetsCounts) Inflate added in v1.5.0

func (hcounts *HistogramSetsCounts) Inflate()

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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