本文整理匯總了Golang中parser.Query.GetColumnNames方法的典型用法代碼示例。如果您正苦於以下問題:Golang Query.GetColumnNames方法的具體用法?Golang Query.GetColumnNames怎麽用?Golang Query.GetColumnNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類parser.Query
的用法示例。
在下文中一共展示了Query.GetColumnNames方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: isAggregateQuery
func isAggregateQuery(query *parser.Query) bool {
for _, column := range query.GetColumnNames() {
if column.IsFunctionCall() {
return true
}
}
return false
}
示例2: Filter
func Filter(query *parser.Query, series *protocol.Series) (*protocol.Series, error) {
if query.GetWhereCondition() == nil {
return series, nil
}
columns := map[string]bool{}
getColumns(query.GetColumnNames(), columns)
points := series.Points
series.Points = nil
for _, point := range points {
ok, err := matches(query.GetWhereCondition(), series.Fields, point)
if err != nil {
return nil, err
}
if ok {
filterColumns(columns, series.Fields, point)
series.Points = append(series.Points, point)
}
}
if !columns["*"] {
newFields := []string{}
for _, f := range series.Fields {
if _, ok := columns[f]; !ok {
continue
}
newFields = append(newFields, f)
}
series.Fields = newFields
}
return series, nil
}
示例3: executeCountQueryWithGroupBy
func (self *QueryEngine) executeCountQueryWithGroupBy(user common.User, database string, query *parser.Query,
yield func(*protocol.Series) error) error {
duration, err := query.GetGroupByClause().GetGroupByTime()
if err != nil {
return err
}
aggregators := []Aggregator{}
for _, value := range query.GetColumnNames() {
if value.IsFunctionCall() {
lowerCaseName := strings.ToLower(value.Name)
initializer := registeredAggregators[lowerCaseName]
if initializer == nil {
return common.NewQueryError(common.InvalidArgument, fmt.Sprintf("Unknown function %s", value.Name))
}
aggregator, err := initializer(query, value)
if err != nil {
return err
}
aggregators = append(aggregators, aggregator)
}
}
timestampAggregator, err := NewTimestampAggregator(query, nil)
if err != nil {
return err
}
groups := make(map[string]map[interface{}]bool)
groupBy := query.GetGroupByClause()
var inverse InverseMapper
err = self.distributeQuery(user, database, query, func(series *protocol.Series) error {
var mapper Mapper
mapper, inverse, err = createValuesToInterface(groupBy, series.Fields)
if err != nil {
return err
}
for _, aggregator := range aggregators {
if err := aggregator.InitializeFieldsMetadata(series); err != nil {
return err
}
}
for _, point := range series.Points {
value := mapper(point)
for _, aggregator := range aggregators {
aggregator.AggregatePoint(*series.Name, value, point)
}
timestampAggregator.AggregatePoint(*series.Name, value, point)
seriesGroups := groups[*series.Name]
if seriesGroups == nil {
seriesGroups = make(map[interface{}]bool)
groups[*series.Name] = seriesGroups
}
seriesGroups[value] = true
}
return nil
})
if err != nil {
return err
}
var sequenceNumber uint32 = 1
fields := []string{}
for _, aggregator := range aggregators {
columnName := aggregator.ColumnName()
fields = append(fields, columnName)
}
for _, value := range groupBy {
if value.IsFunctionCall() {
continue
}
tempName := value.Name
fields = append(fields, tempName)
}
for table, tableGroups := range groups {
tempTable := table
points := []*protocol.Point{}
for groupId, _ := range tableGroups {
timestamp := *timestampAggregator.GetValue(table, groupId)[0].Int64Value
values := [][]*protocol.FieldValue{}
for _, aggregator := range aggregators {
values = append(values, aggregator.GetValue(table, groupId))
}
// do cross product of all the values
values = crossProduct(values)
for _, v := range values {
/* groupPoints := []*protocol.Point{} */
//.........這裏部分代碼省略.........