Skip to content

Commit

Permalink
Change cardinalityMu to expressionsByGroupMu
Browse files Browse the repository at this point in the history
  • Loading branch information
desa committed Mar 2, 2017
1 parent 381955d commit b6a7a5e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions combine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type CombineNode struct {
expressionsByGroup map[models.GroupID][]stateful.Expression
scopePools []stateful.ScopePool

cardinalityMu sync.RWMutex
expressionsByGroupMu sync.RWMutex

combination combination
}
Expand Down Expand Up @@ -66,9 +66,9 @@ func (t timeList) Swap(i, j int) { t[i], t[j] = t[j], t[i] }

func (n *CombineNode) runCombine([]byte) error {
valueF := func() int64 {
n.cardinalityMu.RLock()
n.expressionsByGroupMu.RLock()
l := len(n.expressionsByGroup)
n.cardinalityMu.RUnlock()
n.expressionsByGroupMu.RUnlock()
return int64(l)
}
n.statMap.Set(statCardinalityGauge, expvar.NewIntFuncGauge(valueF))
Expand Down Expand Up @@ -175,17 +175,17 @@ func (n *CombineNode) combineBuffer(buf *buffer) error {
return nil
}
l := len(n.expressions)
n.cardinalityMu.RLock()
n.expressionsByGroupMu.RLock()
expressions, ok := n.expressionsByGroup[buf.Group]
n.cardinalityMu.RUnlock()
n.expressionsByGroupMu.RUnlock()
if !ok {
expressions = make([]stateful.Expression, l)
for i, expr := range n.expressions {
expressions[i] = expr.CopyReset()
}
n.cardinalityMu.Lock()
n.expressionsByGroupMu.Lock()
n.expressionsByGroup[buf.Group] = expressions
n.cardinalityMu.Unlock()
n.expressionsByGroupMu.Unlock()
}

// Compute matching result for all points
Expand Down

0 comments on commit b6a7a5e

Please sign in to comment.