From 16250c5976fca4dabcb6e6ed135f9aa0df389257 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Thu, 16 Jul 2015 12:19:46 -0700 Subject: [PATCH] More replacement of "now" to outside loop --- tsdb/query_executor.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tsdb/query_executor.go b/tsdb/query_executor.go index ec8d5d9806..e24767b3c9 100644 --- a/tsdb/query_executor.go +++ b/tsdb/query_executor.go @@ -208,22 +208,22 @@ func (q *QueryExecutor) ExecuteQuery(query *influxql.Query, database string, chu func (q *QueryExecutor) plan(stmt *influxql.SelectStatement, chunkSize int) (Executor, error) { shards := map[uint64]meta.ShardInfo{} // Shards requiring mappers. + // Replace instances of "now()" with the current time, and check the resultant times. + stmt.Condition = influxql.Reduce(stmt.Condition, &influxql.NowValuer{Now: time.Now().UTC()}) + tmin, tmax := influxql.TimeRange(stmt.Condition) + if tmax.IsZero() { + tmax = time.Now() + } + if tmin.IsZero() { + tmin = time.Unix(0, 0) + } + for _, src := range stmt.Sources { mm, ok := src.(*influxql.Measurement) if !ok { return nil, fmt.Errorf("invalid source type: %#v", src) } - // Replace instances of "now()" with the current time, and check the resultant times. - stmt.Condition = influxql.Reduce(stmt.Condition, &influxql.NowValuer{Now: time.Now().UTC()}) - tmin, tmax := influxql.TimeRange(stmt.Condition) - if tmax.IsZero() { - tmax = time.Now() - } - if tmin.IsZero() { - tmin = time.Unix(0, 0) - } - // Build the set of target shards. Using shard IDs as keys ensures each shard ID // occurs only once. shardGroups, err := q.MetaStore.ShardGroupsByTimeRange(mm.Database, mm.RetentionPolicy, tmin, tmax)