queries

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

README

runtime/queries/

This package implements pre-defined analytical queries. Each query should adhere to the runtime.Query interface to enable efficient caching and cache invalidation of query results.

Adding a new query

Each query should be defined in a separate file and have its own test file containing at least one unit test and exactly one benchmark. The benchmark should be implemented against the ad_bids test project. See column_topk.go and column_topk_test.go for an example.

Running benchmarks

From the repo root, you can benchmark all queries by running:

go test -bench=. -benchmem ./runtime/queries/...

Documentation

Index

Constants

View Source
const IsoFormat string = "2006-01-02T15:04:05.000Z"

Variables

This section is empty.

Functions

func NiceAndStep added in v0.22.0

func NiceAndStep(start, stop, count float64) (float64, float64, float64)

Returns a new interval with nicer looking bounds covering the given interval and the step relative to the number of ticks (`count` parameter). The new bounds are guaranteed to align with the human-friendly gap between ticks. The gap is a rounded value that is a power of 10 multiplied by 1, 2 or 5. This approach is inspired by d3.js, see d3.nice() function.

Types

type ColumnCardinality added in v0.17.0

type ColumnCardinality struct {
	TableName  string
	ColumnName string
	Result     float64
}

func (*ColumnCardinality) Deps added in v0.17.0

func (q *ColumnCardinality) Deps() []string

func (*ColumnCardinality) Key added in v0.17.0

func (q *ColumnCardinality) Key() string

func (*ColumnCardinality) MarshalResult added in v0.17.0

func (q *ColumnCardinality) MarshalResult() any

func (*ColumnCardinality) Resolve added in v0.17.0

func (q *ColumnCardinality) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*ColumnCardinality) UnmarshalResult added in v0.17.0

func (q *ColumnCardinality) UnmarshalResult(v any) error

type ColumnDescriptiveStatistics added in v0.17.0

type ColumnDescriptiveStatistics struct {
	TableName  string
	ColumnName string
	Result     *runtimev1.NumericStatistics
}

func (*ColumnDescriptiveStatistics) Deps added in v0.17.0

func (q *ColumnDescriptiveStatistics) Deps() []string

func (*ColumnDescriptiveStatistics) Key added in v0.17.0

func (*ColumnDescriptiveStatistics) MarshalResult added in v0.17.0

func (q *ColumnDescriptiveStatistics) MarshalResult() any

func (*ColumnDescriptiveStatistics) Resolve added in v0.17.0

func (q *ColumnDescriptiveStatistics) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*ColumnDescriptiveStatistics) UnmarshalResult added in v0.17.0

func (q *ColumnDescriptiveStatistics) UnmarshalResult(v any) error

type ColumnNullCount added in v0.17.0

type ColumnNullCount struct {
	TableName  string
	ColumnName string
	Result     float64
}

func (*ColumnNullCount) Deps added in v0.17.0

func (q *ColumnNullCount) Deps() []string

func (*ColumnNullCount) Key added in v0.17.0

func (q *ColumnNullCount) Key() string

func (*ColumnNullCount) MarshalResult added in v0.17.0

func (q *ColumnNullCount) MarshalResult() any

func (*ColumnNullCount) Resolve added in v0.17.0

func (q *ColumnNullCount) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*ColumnNullCount) UnmarshalResult added in v0.17.0

func (q *ColumnNullCount) UnmarshalResult(v any) error

type ColumnNumericHistogram added in v0.17.0

type ColumnNumericHistogram struct {
	TableName  string
	ColumnName string
	Method     runtimev1.HistogramMethod
	Threshold  int
	Result     []*runtimev1.NumericHistogramBins_Bin
}

func (*ColumnNumericHistogram) Deps added in v0.17.0

func (q *ColumnNumericHistogram) Deps() []string

func (*ColumnNumericHistogram) Key added in v0.17.0

func (q *ColumnNumericHistogram) Key() string

func (*ColumnNumericHistogram) MarshalResult added in v0.17.0

func (q *ColumnNumericHistogram) MarshalResult() any

func (*ColumnNumericHistogram) Resolve added in v0.17.0

func (q *ColumnNumericHistogram) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*ColumnNumericHistogram) UnmarshalResult added in v0.17.0

func (q *ColumnNumericHistogram) UnmarshalResult(v any) error

type ColumnRugHistogram added in v0.17.0

type ColumnRugHistogram struct {
	TableName  string
	ColumnName string
	Result     []*runtimev1.NumericOutliers_Outlier
}

func (*ColumnRugHistogram) Deps added in v0.17.0

func (q *ColumnRugHistogram) Deps() []string

func (*ColumnRugHistogram) Key added in v0.17.0

func (q *ColumnRugHistogram) Key() string

func (*ColumnRugHistogram) MarshalResult added in v0.17.0

func (q *ColumnRugHistogram) MarshalResult() any

func (*ColumnRugHistogram) Resolve added in v0.17.0

func (q *ColumnRugHistogram) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*ColumnRugHistogram) UnmarshalResult added in v0.17.0

func (q *ColumnRugHistogram) UnmarshalResult(v any) error

type ColumnTimeGrain added in v0.17.0

type ColumnTimeGrain struct {
	TableName  string
	ColumnName string
	Result     runtimev1.TimeGrain
}

func (*ColumnTimeGrain) Deps added in v0.17.0

func (q *ColumnTimeGrain) Deps() []string

func (*ColumnTimeGrain) Key added in v0.17.0

func (q *ColumnTimeGrain) Key() string

func (*ColumnTimeGrain) MarshalResult added in v0.17.0

func (q *ColumnTimeGrain) MarshalResult() any

func (*ColumnTimeGrain) Resolve added in v0.17.0

func (q *ColumnTimeGrain) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*ColumnTimeGrain) UnmarshalResult added in v0.17.0

func (q *ColumnTimeGrain) UnmarshalResult(v any) error

type ColumnTimeRange added in v0.17.0

type ColumnTimeRange struct {
	TableName  string
	ColumnName string
	Result     *runtimev1.TimeRangeSummary
}

func (*ColumnTimeRange) Deps added in v0.17.0

func (q *ColumnTimeRange) Deps() []string

func (*ColumnTimeRange) Key added in v0.17.0

func (q *ColumnTimeRange) Key() string

func (*ColumnTimeRange) MarshalResult added in v0.17.0

func (q *ColumnTimeRange) MarshalResult() any

func (*ColumnTimeRange) Resolve added in v0.17.0

func (q *ColumnTimeRange) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*ColumnTimeRange) UnmarshalResult added in v0.17.0

func (q *ColumnTimeRange) UnmarshalResult(v any) error

type ColumnTimeseries added in v0.17.0

type ColumnTimeseries struct {
	TableName           string                                            `json:"table_name"`
	Measures            []*runtimev1.ColumnTimeSeriesRequest_BasicMeasure `json:"measures"`
	TimestampColumnName string                                            `json:"timestamp_column_name"`
	TimeRange           *runtimev1.TimeSeriesTimeRange                    `json:"time_range"`
	Filters             *runtimev1.MetricsViewFilter                      `json:"filters"`
	Pixels              int32                                             `json:"pixels"`
	SampleSize          int32                                             `json:"sample_size"`
	Result              *ColumnTimeseriesResult                           `json:"-"`
}

func (*ColumnTimeseries) Deps added in v0.17.0

func (q *ColumnTimeseries) Deps() []string

func (*ColumnTimeseries) Key added in v0.17.0

func (q *ColumnTimeseries) Key() string

func (*ColumnTimeseries) MarshalResult added in v0.17.0

func (q *ColumnTimeseries) MarshalResult() any

func (*ColumnTimeseries) Resolve added in v0.17.0

func (q *ColumnTimeseries) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*ColumnTimeseries) UnmarshalResult added in v0.17.0

func (q *ColumnTimeseries) UnmarshalResult(v any) error

type ColumnTimeseriesResult added in v0.21.0

type ColumnTimeseriesResult struct {
	Meta       []*runtimev1.MetricsViewColumn
	Results    []*runtimev1.TimeSeriesValue
	Spark      []*runtimev1.TimeSeriesValue
	TimeRange  *runtimev1.TimeSeriesTimeRange
	SampleSize int32
}

type ColumnTopK

type ColumnTopK struct {
	TableName  string
	ColumnName string
	Agg        string
	K          int
	Result     *runtimev1.TopK
}

func (*ColumnTopK) Deps

func (q *ColumnTopK) Deps() []string

func (*ColumnTopK) Key

func (q *ColumnTopK) Key() string

func (*ColumnTopK) MarshalResult

func (q *ColumnTopK) MarshalResult() any

func (*ColumnTopK) Resolve

func (q *ColumnTopK) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*ColumnTopK) UnmarshalResult

func (q *ColumnTopK) UnmarshalResult(v any) error

type MetricsViewTimeSeries added in v0.17.0

type MetricsViewTimeSeries struct {
	MetricsViewName string                       `json:"metrics_view_name,omitempty"`
	MeasureNames    []string                     `json:"measure_names,omitempty"`
	TimeStart       *timestamppb.Timestamp       `json:"time_start,omitempty"`
	TimeEnd         *timestamppb.Timestamp       `json:"time_end,omitempty"`
	Limit           int64                        `json:"limit,omitempty"`
	Offset          int64                        `json:"offset,omitempty"`
	Sort            []*runtimev1.MetricsViewSort `json:"sort,omitempty"`
	Filter          *runtimev1.MetricsViewFilter `json:"filter,omitempty"`
	TimeGranularity runtimev1.TimeGrain          `json:"time_granularity,omitempty"`

	Result *runtimev1.MetricsViewTimeSeriesResponse `json:"-"`
}

func (*MetricsViewTimeSeries) Deps added in v0.17.0

func (q *MetricsViewTimeSeries) Deps() []string

func (*MetricsViewTimeSeries) Key added in v0.17.0

func (q *MetricsViewTimeSeries) Key() string

func (*MetricsViewTimeSeries) MarshalResult added in v0.17.0

func (q *MetricsViewTimeSeries) MarshalResult() any

func (*MetricsViewTimeSeries) Resolve added in v0.17.0

func (q *MetricsViewTimeSeries) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*MetricsViewTimeSeries) UnmarshalResult added in v0.17.0

func (q *MetricsViewTimeSeries) UnmarshalResult(v any) error

type MetricsViewToplist added in v0.17.0

type MetricsViewToplist struct {
	MetricsViewName string                       `json:"metrics_view_name,omitempty"`
	DimensionName   string                       `json:"dimension_name,omitempty"`
	MeasureNames    []string                     `json:"measure_names,omitempty"`
	TimeStart       *timestamppb.Timestamp       `json:"time_start,omitempty"`
	TimeEnd         *timestamppb.Timestamp       `json:"time_end,omitempty"`
	Limit           int64                        `json:"limit,omitempty"`
	Offset          int64                        `json:"offset,omitempty"`
	Sort            []*runtimev1.MetricsViewSort `json:"sort,omitempty"`
	Filter          *runtimev1.MetricsViewFilter `json:"filter,omitempty"`

	Result *runtimev1.MetricsViewToplistResponse `json:"-"`
}

func (*MetricsViewToplist) Deps added in v0.17.0

func (q *MetricsViewToplist) Deps() []string

func (*MetricsViewToplist) Key added in v0.17.0

func (q *MetricsViewToplist) Key() string

func (*MetricsViewToplist) MarshalResult added in v0.17.0

func (q *MetricsViewToplist) MarshalResult() any

func (*MetricsViewToplist) Resolve added in v0.17.0

func (q *MetricsViewToplist) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*MetricsViewToplist) UnmarshalResult added in v0.17.0

func (q *MetricsViewToplist) UnmarshalResult(v any) error

type MetricsViewTotals added in v0.17.0

type MetricsViewTotals struct {
	MetricsViewName string                       `json:"metrics_view_name,omitempty"`
	MeasureNames    []string                     `json:"measure_names,omitempty"`
	TimeStart       *timestamppb.Timestamp       `json:"time_start,omitempty"`
	TimeEnd         *timestamppb.Timestamp       `json:"time_end,omitempty"`
	Filter          *runtimev1.MetricsViewFilter `json:"filter,omitempty"`

	Result *runtimev1.MetricsViewTotalsResponse `json:"-"`
}

func (*MetricsViewTotals) Deps added in v0.17.0

func (q *MetricsViewTotals) Deps() []string

func (*MetricsViewTotals) Key added in v0.17.0

func (q *MetricsViewTotals) Key() string

func (*MetricsViewTotals) MarshalResult added in v0.17.0

func (q *MetricsViewTotals) MarshalResult() any

func (*MetricsViewTotals) Resolve added in v0.17.0

func (q *MetricsViewTotals) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*MetricsViewTotals) UnmarshalResult added in v0.17.0

func (q *MetricsViewTotals) UnmarshalResult(v any) error

type RollupInterval added in v0.17.0

type RollupInterval struct {
	TableName  string
	ColumnName string
	Result     *runtimev1.ColumnRollupIntervalResponse
}

func (*RollupInterval) Deps added in v0.17.0

func (q *RollupInterval) Deps() []string

func (*RollupInterval) Key added in v0.17.0

func (q *RollupInterval) Key() string

func (*RollupInterval) MarshalResult added in v0.17.0

func (q *RollupInterval) MarshalResult() any

func (*RollupInterval) Resolve added in v0.17.0

func (q *RollupInterval) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*RollupInterval) UnmarshalResult added in v0.17.0

func (q *RollupInterval) UnmarshalResult(v any) error

type TableCardinality added in v0.17.0

type TableCardinality struct {
	TableName string
	Result    int64
}

func (*TableCardinality) Deps added in v0.17.0

func (q *TableCardinality) Deps() []string

func (*TableCardinality) Key added in v0.17.0

func (q *TableCardinality) Key() string

func (*TableCardinality) MarshalResult added in v0.17.0

func (q *TableCardinality) MarshalResult() any

func (*TableCardinality) Resolve added in v0.17.0

func (q *TableCardinality) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*TableCardinality) UnmarshalResult added in v0.17.0

func (q *TableCardinality) UnmarshalResult(v any) error

type TableColumns added in v0.17.0

type TableColumns struct {
	TableName string
	Result    []*runtimev1.ProfileColumn
}

func (*TableColumns) Deps added in v0.17.0

func (q *TableColumns) Deps() []string

func (*TableColumns) Key added in v0.17.0

func (q *TableColumns) Key() string

func (*TableColumns) MarshalResult added in v0.17.0

func (q *TableColumns) MarshalResult() any

func (*TableColumns) Resolve added in v0.17.0

func (q *TableColumns) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*TableColumns) UnmarshalResult added in v0.17.0

func (q *TableColumns) UnmarshalResult(v any) error

type TableHead added in v0.21.1

type TableHead struct {
	TableName string
	Limit     int
	Result    []*structpb.Struct
}

func (*TableHead) Deps added in v0.21.1

func (q *TableHead) Deps() []string

func (*TableHead) Key added in v0.21.1

func (q *TableHead) Key() string

func (*TableHead) MarshalResult added in v0.21.1

func (q *TableHead) MarshalResult() any

func (*TableHead) Resolve added in v0.21.1

func (q *TableHead) Resolve(ctx context.Context, rt *runtime.Runtime, instanceID string, priority int) error

func (*TableHead) UnmarshalResult added in v0.21.1

func (q *TableHead) UnmarshalResult(v any) error

Jump to

Keyboard shortcuts

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