Refactor some greediness computations.
This commit is contained in:
parent
978acd4e96
commit
b00ca7e422
|
@ -334,10 +334,6 @@ func collectIntervals(o ops) (intervals map[time.Duration]ops) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, operations := range intervals {
|
|
||||||
sort.Sort(greedinessSort{operations})
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +383,7 @@ func optimizeForward(pending ops) (out ops) {
|
||||||
// If the type is not a range request, we can't do anything.
|
// If the type is not a range request, we can't do anything.
|
||||||
switch next := peekOperation.(type) {
|
switch next := peekOperation.(type) {
|
||||||
case *getValuesAlongRangeOp:
|
case *getValuesAlongRangeOp:
|
||||||
if !next.Through().After(t.Through()) {
|
if !next.GreedierThan(t) {
|
||||||
var (
|
var (
|
||||||
before = getValuesAtIntervalOp(*t)
|
before = getValuesAtIntervalOp(*t)
|
||||||
after = getValuesAtIntervalOp(*t)
|
after = getValuesAtIntervalOp(*t)
|
||||||
|
@ -433,7 +429,7 @@ func optimizeForward(pending ops) (out ops) {
|
||||||
// Range queries should be concatenated if they overlap.
|
// Range queries should be concatenated if they overlap.
|
||||||
pending = pending[1:len(pending)]
|
pending = pending[1:len(pending)]
|
||||||
|
|
||||||
if next.Through().After(t.Through()) {
|
if next.GreedierThan(t) {
|
||||||
t.through = next.through
|
t.through = next.through
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -448,7 +444,7 @@ func optimizeForward(pending ops) (out ops) {
|
||||||
case *getValuesAtIntervalOp:
|
case *getValuesAtIntervalOp:
|
||||||
pending = pending[1:len(pending)]
|
pending = pending[1:len(pending)]
|
||||||
|
|
||||||
if next.through.After(t.Through()) {
|
if next.GreedierThan(t) {
|
||||||
var (
|
var (
|
||||||
t = next.from
|
t = next.from
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue