Minor code cleanups.

Change-Id: Ib3729cf38b107b7f2186ccf410a745e0472e3630
This commit is contained in:
Julius Volz 2014-02-13 15:24:43 +01:00
parent 18d9d00100
commit c4adfc4f25
2 changed files with 7 additions and 17 deletions

View file

@ -62,9 +62,7 @@ func (analyzer *QueryAnalyzer) Visit(node Node) {
} }
n.fingerprints = fingerprints n.fingerprints = fingerprints
for _, fingerprint := range fingerprints { for _, fingerprint := range fingerprints {
if !analyzer.IntervalRanges[*fingerprint] { analyzer.IntervalRanges[*fingerprint] = true
analyzer.IntervalRanges[*fingerprint] = true
}
} }
case *MatrixLiteral: case *MatrixLiteral:
fingerprints, err := analyzer.storage.GetFingerprintsForLabelSet(n.labels) fingerprints, err := analyzer.storage.GetFingerprintsForLabelSet(n.labels)
@ -74,15 +72,9 @@ func (analyzer *QueryAnalyzer) Visit(node Node) {
} }
n.fingerprints = fingerprints n.fingerprints = fingerprints
for _, fingerprint := range fingerprints { for _, fingerprint := range fingerprints {
interval := n.interval if analyzer.FullRanges[*fingerprint] < n.interval {
// If an interval has already been recorded for this fingerprint, merge analyzer.FullRanges[*fingerprint] = n.interval
// it with the current interval.
if oldInterval, ok := analyzer.FullRanges[*fingerprint]; ok {
if oldInterval > interval {
interval = oldInterval
}
} }
analyzer.FullRanges[*fingerprint] = interval
} }
} }
} }
@ -93,9 +85,7 @@ func (analyzer *QueryAnalyzer) AnalyzeQueries(node Node) {
// always contain more points *and* span more time than stepped ranges, so // always contain more points *and* span more time than stepped ranges, so
// throw away stepped ranges for fingerprints which have full ranges. // throw away stepped ranges for fingerprints which have full ranges.
for fingerprint := range analyzer.FullRanges { for fingerprint := range analyzer.FullRanges {
if analyzer.IntervalRanges[fingerprint] { delete(analyzer.IntervalRanges, fingerprint)
delete(analyzer.IntervalRanges, fingerprint)
}
} }
} }
@ -117,7 +107,7 @@ func viewAdapterForInstantQuery(node Node, timestamp clientmodel.Timestamp, stor
buildTimer := queryStats.GetTimer(stats.InnerViewBuildingTime).Start() buildTimer := queryStats.GetTimer(stats.InnerViewBuildingTime).Start()
// BUG(julius): Clear Law of Demeter violation. // BUG(julius): Clear Law of Demeter violation.
view, err := analyzer.storage.MakeView(viewBuilder, time.Duration(60)*time.Second, queryStats) view, err := analyzer.storage.MakeView(viewBuilder, 60*time.Second, queryStats)
buildTimer.Stop() buildTimer.Stop()
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -193,7 +193,7 @@ func (t *TieredStorage) drain(drained chan<- bool) {
t.draining <- (drained) t.draining <- (drained)
} }
// Enqueues a ViewRequestBuilder for materialization, subject to a timeout. // Materializes a View according to a ViewRequestBuilder, subject to a timeout.
func (t *TieredStorage) MakeView(builder ViewRequestBuilder, deadline time.Duration, queryStats *stats.TimerGroup) (View, error) { func (t *TieredStorage) MakeView(builder ViewRequestBuilder, deadline time.Duration, queryStats *stats.TimerGroup) (View, error) {
t.mu.RLock() t.mu.RLock()
defer t.mu.RUnlock() defer t.mu.RUnlock()
@ -264,8 +264,8 @@ func (t *TieredStorage) Serve(started chan<- bool) {
glog.Warning("Backlogging on flush...") glog.Warning("Backlogging on flush...")
} }
case viewRequest := <-t.ViewQueue: case viewRequest := <-t.ViewQueue:
viewRequest.stats.GetTimer(stats.ViewQueueTime).Stop()
<-t.memorySemaphore <-t.memorySemaphore
viewRequest.stats.GetTimer(stats.ViewQueueTime).Stop()
go t.renderView(viewRequest) go t.renderView(viewRequest)
case drainingDone := <-t.draining: case drainingDone := <-t.draining:
t.Flush() t.Flush()