Documentation ¶
Index ¶
- Variables
- type AlphabeticalSortable
- type BooleanCell
- type Bucket
- type Cell
- type Dataset
- type DatetimeBucketOptions
- type DatetimeCell
- func (cell *DatetimeCell) FieldDefinition() *Field
- func (cell *DatetimeCell) IsMetricable(m measurer) bool
- func (cell *DatetimeCell) MeasurableCell() MeasurableCell
- func (cell *DatetimeCell) Value() interface{}
- func (cell *DatetimeCell) ValueForPeriod(period DatetimePeriod, location *time.Location) (string, error)
- type DatetimePeriod
- type Field
- type MeasurableCell
- type Metric
- type NumberCell
- type NumericalSortable
- type Query
- type RangeBucketOptions
- type ResultBucket
- type ResultTable
- type Resultset
- type SortOptions
- type Sortable
- type StringCell
- type Table
Constants ¶
This section is empty.
Variables ¶
var ( ErrTargetDepthTooLow = fmt.Errorf("Tabulate: target depth should be 1 or above") ErrTargetDepthNotReached = fmt.Errorf("Tabulate: reached deepest bucket before hitting target depth") )
Concrete errors.
var MetricDelimeter = ":"
MetricDelimeter is a string used to separate metric field's from names.
Functions ¶
This section is empty.
Types ¶
type AlphabeticalSortable ¶
type AlphabeticalSortable bool
AlphabeticalSortable is a simple sorter that sorts alphabetically in the direction of the boolean, true meaning ascending and false being descending.
func (*AlphabeticalSortable) Less ¶
func (sortable *AlphabeticalSortable) Less(a, b *ResultBucket) bool
Less implements Sortable by comparing the value field of each result.
type BooleanCell ¶
type BooleanCell struct {
// contains filtered or unexported fields
}
BooleanCell implements the Cell{} interface.
func (*BooleanCell) FieldDefinition ¶
func (cell *BooleanCell) FieldDefinition() *Field
FieldDefinition returns the field definition (name) representing the cell.
func (*BooleanCell) IsMetricable ¶
func (cell *BooleanCell) IsMetricable(m measurer) bool
IsMetricable determines whether the measurer{} provided can be run by the cell.
func (*BooleanCell) MeasurableCell ¶
func (cell *BooleanCell) MeasurableCell() MeasurableCell
MeasurableCell returns the cells MeasurableCell{}.
func (*BooleanCell) Value ¶
func (cell *BooleanCell) Value() interface{}
Value returns the cell value.
type Bucket ¶
type Bucket struct { Bucket *Bucket Field *Field DatetimeOptions *DatetimeBucketOptions Sort *SortOptions RangeOptions *RangeBucketOptions }
Bucket defines how to compare and group data which is then aggregated on.
type Cell ¶
type Cell interface { FieldDefinition() *Field IsMetricable(m measurer) bool MeasurableCell() MeasurableCell }
Cell represents data and configuration for each of our *Table.Fields.
type Dataset ¶
Dataset holds our *Table representation of *Fields and its matching Cell data.
type DatetimeBucketOptions ¶
type DatetimeBucketOptions struct { // Start will, if provided, ensure buckets start at this date. Start *time.Time // End will, if provided, ensure buckets continue to this date. End *time.Time // What interval period are the results to be bucketed at. Period DatetimePeriod // Datetimes should be bucketed based on the date in this location. Location *time.Location }
DatetimeBucketOptions provides additional configuration for datetime bucketing.
type DatetimeCell ¶
type DatetimeCell struct {
// contains filtered or unexported fields
}
DatetimeCell implements the Cell interface.
func (*DatetimeCell) FieldDefinition ¶
func (cell *DatetimeCell) FieldDefinition() *Field
FieldDefinition returns the field definition (name) representing the cell.
func (*DatetimeCell) IsMetricable ¶
func (cell *DatetimeCell) IsMetricable(m measurer) bool
IsMetricable determines whether the measurer{} provided can be run by the cell.
func (*DatetimeCell) MeasurableCell ¶
func (cell *DatetimeCell) MeasurableCell() MeasurableCell
MeasurableCell returns the cells MeasurableCell{}.
func (*DatetimeCell) Value ¶
func (cell *DatetimeCell) Value() interface{}
Value returns the cell value.
func (*DatetimeCell) ValueForPeriod ¶
func (cell *DatetimeCell) ValueForPeriod(period DatetimePeriod, location *time.Location) (string, error)
ValueForPeriod returns the start of a given period.
type DatetimePeriod ¶
type DatetimePeriod string
DatetimePeriod provides a string type to represent a date bucketing period.
const ( Year DatetimePeriod = "year" Quarter DatetimePeriod = "quarter" Month DatetimePeriod = "month" Week DatetimePeriod = "week" Day DatetimePeriod = "hour" )
Helper constants representing acceptable DatetimePeriods.
type MeasurableCell ¶
type MeasurableCell interface {
Value() interface{}
}
MeasurableCell returns the cells MeasurableCell{}.
type NumberCell ¶
type NumberCell struct {
// contains filtered or unexported fields
}
NumberCell implements the Cell interface.
func (*NumberCell) FieldDefinition ¶
func (cell *NumberCell) FieldDefinition() *Field
FieldDefinition returns the field definition (name) representing the cell.
func (*NumberCell) IsMetricable ¶
func (cell *NumberCell) IsMetricable(m measurer) bool
IsMetricable determines whether the measurer{} provided can be run by the cell.
func (*NumberCell) MeasurableCell ¶
func (cell *NumberCell) MeasurableCell() MeasurableCell
MeasurableCell returns the cells MeasurableCell{}.
func (*NumberCell) Value ¶
func (cell *NumberCell) Value() interface{}
Value returns the cell value.
func (*NumberCell) ValueForPeriod ¶
func (cell *NumberCell) ValueForPeriod(period []interface{}) (string, error)
ValueForPeriod returns the start of a given period.
type NumericalSortable ¶
type NumericalSortable bool
NumericalSortable is a simple sorter that sorts numerically in the direction of the boolean, true meaning ascending and false being descending.
func (*NumericalSortable) Less ¶
func (sortable *NumericalSortable) Less(a, b *ResultBucket) bool
Less implements Sortable by comparing the value field of each result.
type RangeBucketOptions ¶
type RangeBucketOptions struct {
Period []interface{}
}
RangeBucketOptions provides additional configuration for custom range bucketing.
type ResultBucket ¶
type ResultBucket struct { Value string `json:"value"` Metrics map[string]interface{} `json:"metrics"` Buckets []*ResultBucket `json:"buckets"` // contains filtered or unexported fields }
ResultBucket represents recursively built metrics for our tablular data.
type ResultTable ¶
type ResultTable struct { Rows [][]map[string]interface{} `json:"rows"` RowTitles [][]string `json:"row_titles"` ColumnTitles [][]string `json:"column_titles"` }
ResultTable represents a Resultset split into row / columns at a depth.
type Resultset ¶
type Resultset struct { Errors []error `json:"errors"` Buckets []*ResultBucket `json:"buckets"` Composition []interface{} `json:"-"` }
Resultset represents a complete set of result buckets and any associated errors.
type SortOptions ¶
SortOptions represent how this Bucket should be sorted.
type Sortable ¶
type Sortable interface {
Less(a, b *ResultBucket) bool
}
Sortable provides an interface that various sorters can implement to compare two result buckets. This enables access to both the value and any metrics that the query may have contained.
type StringCell ¶
type StringCell struct {
// contains filtered or unexported fields
}
StringCell implements the Cell{} interface.
func (*StringCell) FieldDefinition ¶
func (cell *StringCell) FieldDefinition() *Field
FieldDefinition returns the field definition (name) representing the cell.
func (*StringCell) IsMetricable ¶
func (cell *StringCell) IsMetricable(m measurer) bool
IsMetricable determines whether the measurer{} provided can be run by the cell.
func (*StringCell) MeasurableCell ¶
func (cell *StringCell) MeasurableCell() MeasurableCell
MeasurableCell returns the cells MeasurableCell{}.
func (*StringCell) Value ¶
func (cell *StringCell) Value() interface{}
Value returns the cell value.