godruid

package module
v0.0.0-...-ce75cdf Latest Latest
Warning

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

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

README

godruid

Forked from shunfei/grodruid to enable virtual column definitions and lookup filters in ump-operate-stats. Partial implementation - needs to be refined.

Documentation

Index

Constants

View Source
const (
	DirectionASC  = "ASCENDING"
	DirectionDESC = "DESCENDING"
)
View Source
const (
	DefaultEndPoint = "/druid/v2"
)

Variables

View Source
var (
	ToIncludeAll  = &ToInclude{Type: "All"}
	ToIncludeNone = &ToInclude{Type: "None"}
)
View Source
var (
	SearchSortLexicographic = &SearchSort{Type: "lexicographic"}
	SearchSortStrlen        = &SearchSort{Type: "strlen"}
)

Functions

This section is empty.

Types

type AggRefer

type AggRefer struct {
	Name  string
	Refer string // The refer of Name, empty means Name has no refer.
}

The agg reference.

type Aggregation

type Aggregation struct {
	Type        string   `json:"type"`
	Name        string   `json:"name,omitempty"`
	FieldName   string   `json:"fieldName,omitempty"`
	FieldNames  []string `json:"fieldNames,omitempty"`
	FnAggregate string   `json:"fnAggregate,omitempty"`
	FnCombine   string   `json:"fnCombine,omitempty"`
	FnReset     string   `json:"fnReset,omitempty"`
	ByRow       bool     `json:"byRow,omitempty"`
}

func AggCardinality

func AggCardinality(name string, fieldNames []string, byRow ...bool) Aggregation

func AggCount

func AggCount(name string) Aggregation

func AggDoubleSum

func AggDoubleSum(name, fieldName string) Aggregation

func AggJavaScript

func AggJavaScript(name, fnAggregate, fnCombine, fnReset string, fieldNames []string) Aggregation

func AggLongSum

func AggLongSum(name, fieldName string) Aggregation

func AggMax

func AggMax(name, fieldName string) Aggregation

func AggMin

func AggMin(name, fieldName string) Aggregation

func AggRawJson

func AggRawJson(rawJson string) Aggregation

type Client

type Client struct {
	Url      string
	EndPoint string
	Timeout  time.Duration

	Debug        bool
	LastRequest  string
	LastResponse string
}

func (*Client) Query

func (c *Client) Query(query Query) (err error)

func (*Client) QueryRaw

func (c *Client) QueryRaw(req []byte) (result []byte, err error)

type Column

type Column struct {
	AsNumber  bool   `json:"asNumber"`
	Dimension string `json:"dimension"`
	Direction string `json:"direction"`
}

type ColumnItem

type ColumnItem struct {
	Type        string      `json:"type"`
	Size        int         `json:"size"`
	Cardinality interface{} `json:"cardinality"`
}

type DimExtractionFn

type DimExtractionFn struct {
	Type         string       `json:"type"`
	Expr         string       `json:"expr,omitempty"`
	Query        *SearchQuery `json:"query,omitempty"`
	TimeFormat   string       `json:"timeFormat,omitempty"`
	ResultFormat string       `json:"resultFormat,omitempty"`
	Function     string       `json:"function,omitempty"`
}

func DimExFnJavascript

func DimExFnJavascript(function string) *DimExtractionFn

func DimExFnPartial

func DimExFnPartial(expr string) *DimExtractionFn

func DimExFnRegex

func DimExFnRegex(expr string) *DimExtractionFn

func DimExFnSearchQuerySpec

func DimExFnSearchQuerySpec(query *SearchQuery) *DimExtractionFn

func DimExFnTime

func DimExFnTime(timeFormat, resultFormat string) *DimExtractionFn

type DimSpec

type DimSpec interface{}

func DimDefault

func DimDefault(dimension, outputName string) DimSpec

func DimExtraction

func DimExtraction(dimension, outputName string, fn *DimExtractionFn) DimSpec

type DimValue

type DimValue struct {
	Dimension string `json:"dimension"`
	Value     string `json:"value"`
}

type Dimension

type Dimension struct {
	Type            string           `json:"type"`
	Dimension       string           `json:"dimension"`
	OutputName      string           `json:"outputName"`
	DimExtractionFn *DimExtractionFn `json:"dimExtractionFn,omitempty"`
}

type Filter

type Filter struct {
	Type         string              `json:"type"`
	Dimension    string              `json:"dimension,omitempty"`
	Value        interface{}         `json:"value,omitempty"`
	Pattern      string              `json:"pattern,omitempty"`
	Function     string              `json:"function,omitempty"`
	Field        *Filter             `json:"field,omitempty"`
	Fields       []*Filter           `json:"fields,omitempty"`
	ExtractionFn *FilterExtractionFn `json:"extractionFn,omitempty"`
	QueryFilter  *QueryFilter        `json:"query,omitempty"`
	Values       []string            `json:"values,omitempty"`
}

func FilterAnd

func FilterAnd(filters ...*Filter) *Filter

func FilterJavaScript

func FilterJavaScript(dimension, function string) *Filter

func FilterNot

func FilterNot(filter *Filter) *Filter

func FilterOr

func FilterOr(filters ...*Filter) *Filter

func FilterRegex

func FilterRegex(dimension, pattern string) *Filter

func FilterSelector

func FilterSelector(dimension string, value interface{}) *Filter

type FilterExtractionFn

type FilterExtractionFn struct {
	Type   string `json:"type"`
	Lookup Lookup `json:"lookup,omitempty"`
}

type GranDuration

type GranDuration struct {
	Type string `json:"type"`

	Duration string `json:"duration"`
	Origin   string `json:"origin,omitempty"`
}

type GranPeriod

type GranPeriod struct {
	Type string `json:"type"`

	Period   string `json:"period"`
	TimeZone string `json:"timeZone,omitempty"`
	Origin   string `json:"origin,omitempty"`
}

type Granlarity

type Granlarity interface{}

type GroupbyItem

type GroupbyItem struct {
	Version   string                 `json:"version"`
	Timestamp string                 `json:"timestamp"`
	Event     map[string]interface{} `json:"event"`
}

type Having

type Having struct {
	Type        string      `json:"type"`
	Aggregation string      `json:"aggregation,omitempty"`
	Value       interface{} `json:"value,omitempty"`
	HavingSpec  *Having     `json:"havingSpec,omitempty"`
	HavingSpecs []*Having   `json:"havingSpecs,omitempty"`
}

func HavingAnd

func HavingAnd(havings ...*Having) *Having

func HavingEqualTo

func HavingEqualTo(agg string, value interface{}) *Having

func HavingGreaterThan

func HavingGreaterThan(agg string, value interface{}) *Having

func HavingLessThan

func HavingLessThan(agg string, value interface{}) *Having

func HavingNot

func HavingNot(having *Having) *Having

func HavingOr

func HavingOr(havings ...*Having) *Having

type Limit

type Limit struct {
	Type    string   `json:"type"`
	Limit   int      `json:"limit"`
	Columns []Column `json:"columns,omitempty"`
}

func LimitDefault

func LimitDefault(limit int, columns ...[]Column) *Limit

type Lookup

type Lookup struct {
	Type string            `json:"type"`
	Map  map[string]string `json:"map"`
}

type PostAggregation

type PostAggregation struct {
	Type       string            `json:"type"`
	Name       string            `json:"name,omitempty"`
	Value      interface{}       `json:"value,omitempty"`
	Fn         string            `json:"fn,omitempty"`
	Fields     []PostAggregation `json:"fields,omitempty"`
	FieldName  string            `json:"fieldName,omitempty"`
	FieldNames []string          `json:"fieldNames,omitempty"`
	Function   string            `json:"function,omitempty"`
}

func PostAggArithmetic

func PostAggArithmetic(name, fn string, fields []PostAggregation) PostAggregation

func PostAggConstant

func PostAggConstant(name string, value interface{}) PostAggregation

func PostAggFieldAccessor

func PostAggFieldAccessor(fieldName string) PostAggregation

func PostAggFieldHyperUnique

func PostAggFieldHyperUnique(fieldName string) PostAggregation

func PostAggJavaScript

func PostAggJavaScript(name, function string, fieldNames []string) PostAggregation

func PostAggRawJson

func PostAggRawJson(rawJson string) PostAggregation

func (PostAggregation) GetReferAggs

func (pa PostAggregation) GetReferAggs(parentName ...string) (refers []AggRefer)

Return the aggregations or post aggregations which this post aggregation used. It could be helpful while automatically filling the aggregations or post aggregations base on this.

type Query

type Query interface {
	// contains filtered or unexported methods
}

The Query interface stands for any kinds of druid query.

type QueryFilter

type QueryFilter struct {
	Type          string `json:"type"`
	Value         string `json:"value"`
	CaseSensitive bool   `json:"caseSensitive,omitempty"`
}

QueryFilter is used for search filter https://druid.apache.org/docs/latest/querying/filters.html

type QueryGroupBy

type QueryGroupBy struct {
	QueryType        string                 `json:"queryType"`
	DataSource       string                 `json:"dataSource"`
	Dimensions       []DimSpec              `json:"dimensions"`
	Granularity      Granlarity             `json:"granularity"`
	LimitSpec        *Limit                 `json:"limitSpec,omitempty"`
	Having           *Having                `json:"having,omitempty"`
	Filter           *Filter                `json:"filter,omitempty"`
	Aggregations     []Aggregation          `json:"aggregations"`
	PostAggregations []PostAggregation      `json:"postAggregations,omitempty"`
	Intervals        []string               `json:"intervals"`
	Context          map[string]interface{} `json:"context,omitempty"`
	// TODO add to other query types if necessary
	VirtualColumns []VirtualColumn `json:"virtualColumns,omitempty"`

	QueryResult []GroupbyItem `json:"-"`
}

type QuerySearch

type QuerySearch struct {
	QueryType        string                 `json:"queryType"`
	DataSource       string                 `json:"dataSource"`
	Granularity      Granlarity             `json:"granularity"`
	Filter           *Filter                `json:"filter,omitempty"`
	Intervals        []string               `json:"intervals"`
	SearchDimensions []string               `json:"searchDimensions,omitempty"`
	Query            *SearchQuery           `json:"query"`
	Sort             *SearchSort            `json:"sort"`
	Context          map[string]interface{} `json:"context,omitempty"`

	QueryResult []SearchItem `json:"-"`
}

type QuerySegmentMetadata

type QuerySegmentMetadata struct {
	QueryType  string                 `json:"queryType"`
	DataSource string                 `json:"dataSource"`
	Intervals  []string               `json:"intervals"`
	ToInclude  *ToInclude             `json:"toInclude,omitempty"`
	Merge      interface{}            `json:"merge,omitempty"`
	Context    map[string]interface{} `json:"context,omitempty"`

	QueryResult []SegmentMetaData `json:"-"`
}

type QuerySelect

type QuerySelect struct {
	QueryType   string                 `json:"queryType"`
	DataSource  string                 `json:"dataSource"`
	Intervals   []string               `json:"intervals"`
	Filter      *Filter                `json:"filter,omitempty"`
	Dimensions  []DimSpec              `json:"dimensions"`
	Metrics     []string               `json:"metrics"`
	Granularity Granlarity             `json:"granularity"`
	PagingSpec  map[string]interface{} `json:"pagingSpec,omitempty"`
	Context     map[string]interface{} `json:"context,omitempty"`

	QueryResult SelectBlob `json:"-"`
}

type QueryTimeBoundary

type QueryTimeBoundary struct {
	QueryType  string                 `json:"queryType"`
	DataSource string                 `json:"dataSource"`
	Bound      string                 `json:"bound,omitempty"`
	Context    map[string]interface{} `json:"context,omitempty"`

	QueryResult []TimeBoundaryItem `json:"-"`
}

type QueryTimeseries

type QueryTimeseries struct {
	QueryType        string                 `json:"queryType"`
	DataSource       string                 `json:"dataSource"`
	Granularity      Granlarity             `json:"granularity"`
	Filter           *Filter                `json:"filter,omitempty"`
	Aggregations     []Aggregation          `json:"aggregations"`
	PostAggregations []PostAggregation      `json:"postAggregations,omitempty"`
	Intervals        []string               `json:"intervals"`
	Context          map[string]interface{} `json:"context,omitempty"`
	// TODO add to other query types if necessary
	VirtualColumns []VirtualColumn `json:"virtualColumns,omitempty"`

	QueryResult []Timeseries `json:"-"`
}

type QueryTopN

type QueryTopN struct {
	QueryType        string                 `json:"queryType"`
	DataSource       string                 `json:"dataSource"`
	Granularity      Granlarity             `json:"granularity"`
	Dimension        DimSpec                `json:"dimension"`
	Threshold        int                    `json:"threshold"`
	Metric           *TopNMetric            `json:"metric"`
	Filter           *Filter                `json:"filter,omitempty"`
	Aggregations     []Aggregation          `json:"aggregations"`
	PostAggregations []PostAggregation      `json:"postAggregations,omitempty"`
	Intervals        []string               `json:"intervals"`
	Context          map[string]interface{} `json:"context,omitempty"`

	QueryResult []TopNItem `json:"-"`
}

type SearchItem

type SearchItem struct {
	Timestamp string     `json:"timestamp"`
	Result    []DimValue `json:"result"`
}

type SearchQuery

type SearchQuery struct {
	Type   string        `json:"type"`
	Value  interface{}   `json:"value,omitempty"`
	Values []interface{} `json:"values,omitempty"`
}

func SearchQueryFragmentSearch

func SearchQueryFragmentSearch(values []interface{}) *SearchQuery

func SearchQueryInsensitiveContains

func SearchQueryInsensitiveContains(value interface{}) *SearchQuery

type SearchSort

type SearchSort struct {
	Type string `json:"type"`
}

type SegmentMetaData

type SegmentMetaData struct {
	Id        string                `json:"id"`
	Intervals []string              `json:"intervals"`
	Columns   map[string]ColumnItem `json:"columns"`
}

type SelectBlob

type SelectBlob struct {
	Timestamp string       `json:"timestamp"`
	Result    SelectResult `json:"result"`
}

Select json blob from druid comes back as following: http://druid.io/docs/latest/querying/select-query.html the interesting results are in events blob which we call as 'SelectEvent'.

type SelectEvent

type SelectEvent struct {
	SegmentId string                 `json:"segmentId"`
	Offset    int64                  `json:"offset"`
	Event     map[string]interface{} `json:"event"`
}

type SelectResult

type SelectResult struct {
	PagingIdentifiers map[string]interface{} `json:"pagingIdentifiers"`
	Events            []SelectEvent          `json:"events"`
}

type SimpleGran

type SimpleGran string
const (
	GranAll        SimpleGran = "all"
	GranNone       SimpleGran = "none"
	GranMinute     SimpleGran = "minute"
	GranFifteenMin SimpleGran = "fifteen_minute"
	GranThirtyMin  SimpleGran = "thirty_minute"
	GranHour       SimpleGran = "hour"
	GranDay        SimpleGran = "day"
	GranWeek       SimpleGran = "week"
	GranMonth      SimpleGran = "month"
)

type TimeBoundary

type TimeBoundary struct {
	MinTime string `json:"minTime"`
	MaxTime string `json:"minTime"`
}

type TimeBoundaryItem

type TimeBoundaryItem struct {
	Timestamp string       `json:"timestamp"`
	Result    TimeBoundary `json:"result"`
}

type Timeseries

type Timeseries struct {
	Timestamp string                 `json:"timestamp"`
	Result    map[string]interface{} `json:"result"`
}

type ToInclude

type ToInclude struct {
	Type    string   `json:"type"`
	Columns []string `json:"columns,omitempty"`
}

func ToIncludeList

func ToIncludeList(columns []string) *ToInclude

type TopNItem

type TopNItem struct {
	Timestamp string                   `json:"timestamp"`
	Result    []map[string]interface{} `json:"result"`
}

type TopNMetric

type TopNMetric struct {
	Type         string      `json:"type"`
	Metric       interface{} `json:"metric,omitempty"`
	PreviousStop string      `json:"previousStop"`
}

func TopNMetricAlphaNumeric

func TopNMetricAlphaNumeric(previousStop string) *TopNMetric

func TopNMetricInverted

func TopNMetricInverted(metric *TopNMetric) *TopNMetric

func TopNMetricLexicographic

func TopNMetricLexicographic(previousStop string) *TopNMetric

func TopNMetricNumeric

func TopNMetricNumeric(metric string) *TopNMetric

type VirtualColumn

type VirtualColumn struct {
	Type       string `json:"type"`
	Name       string `json:"name"`
	Expression string `json:"expression"`
	OutputType string `json:"outputType"`
}

Jump to

Keyboard shortcuts

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