Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Commit

Permalink
Search rollups backwards
Browse files Browse the repository at this point in the history
  • Loading branch information
Chao Wang committed Apr 6, 2017
1 parent 8b00189 commit 23a1244
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions rules/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,10 @@ func (rc *rollupRule) ActiveRule(timeNs int64) *rollupRule {
}

func (rc *rollupRule) activeIndex(timeNs int64) int {
idx := 0
for idx < len(rc.snapshots) && rc.snapshots[idx].cutoverNs <= timeNs {
idx++
idx := len(rc.snapshots) - 1
for idx >= 0 && rc.snapshots[idx].cutoverNs > timeNs {
idx--
}
idx--
return idx
}

Expand Down

0 comments on commit 23a1244

Please sign in to comment.