コード例 #1
0
ファイル: database.go プロジェクト: pcn/influxdb
// tagSets returns the unique tag sets that exist for the given tag keys. This is used to determine
// what composite series will be created by a group by. i.e. "group by region" should return:
// {"region":"uswest"}, {"region":"useast"}
// or region, service returns
// {"region": "uswest", "service": "redis"}, {"region": "uswest", "service": "mysql"}, etc...
func (m *Measurement) tagSets(stmt *influxql.SelectStatement, dimensions []string) map[string]map[uint32]influxql.Expr {
	// get the unique set of series ids and the filters that should be applied to each
	seriesIDs, filters := m.seriesIDsAndFilters(stmt)

	// build the tag sets
	tagSets := make(map[string]map[uint32]influxql.Expr)
	for _, id := range seriesIDs {
		// get the series and set the tag values for the dimensions we care about
		s := m.seriesByID[id]
		tags := make([]string, len(dimensions))
		for i, dim := range dimensions {
			tags[i] = s.Tags[dim]
		}

		// marshal it into a string and put this series and its expr into the tagSets map
		t := string(influxql.MarshalStrings(tags))
		set, ok := tagSets[t]
		if !ok {
			set = make(map[uint32]influxql.Expr)
		}
		set[id] = filters[id]
		tagSets[t] = set
	}

	return tagSets
}
コード例 #2
0
ファイル: engine_test.go プロジェクト: pcn/influxdb
// NewIterator returns a new iterator.
func NewIterator(tags []string, points []Point) *Iterator {
	return &Iterator{tags: string(influxql.MarshalStrings(tags)), points: points}
}