Skip to content

Commit

Permalink
Renamed lastValue of dedup iter and added TODO
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Rabenhorst <[email protected]>
  • Loading branch information
rabenhorst committed Jan 10, 2023
1 parent c9e77b4 commit 911e3bc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/dedup/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ type adjustableSeriesIterator interface {

// adjustAtValue allows to adjust value by implementation if needed knowing the last value. This is used by counter
// implementation which can adjust for obsolete counter value.
adjustAtValue(lastValue float64)
adjustAtValue(lastFloatValue float64)
}

type noopAdjustableSeriesIterator struct {
Expand Down Expand Up @@ -360,11 +360,11 @@ type counterErrAdjustSeriesIterator struct {
errAdjust float64
}

func (it *counterErrAdjustSeriesIterator) adjustAtValue(lastValue float64) {
func (it *counterErrAdjustSeriesIterator) adjustAtValue(lastFloatValue float64) {
_, v := it.At()
if lastValue > v {
if lastFloatValue > v {
// This replica has obsolete value (did not see the correct "end" of counter value before app restart). Adjust.
it.errAdjust += lastValue - v
it.errAdjust += lastFloatValue - v
}
}

Expand Down Expand Up @@ -405,6 +405,7 @@ func (it *dedupSeriesIterator) Next() chunkenc.ValueType {
if it.useA != lastUseA && isFloatVal {
// We switched replicas.
// Ensure values are correct bases on value before At.
// TODO(rabenhorst): Investiagte if we also need to implement adjusting histograms here.
it.adjustAtValue(lastFloatVal)
}
}()
Expand Down Expand Up @@ -487,12 +488,12 @@ func (it *dedupSeriesIterator) lastFloatVal() (float64, bool) {
return 0, false
}

func (it *dedupSeriesIterator) adjustAtValue(lastValue float64) {
func (it *dedupSeriesIterator) adjustAtValue(lastFloatValue float64) {
if it.aval == chunkenc.ValFloat {
it.a.adjustAtValue(lastValue)
it.a.adjustAtValue(lastFloatValue)
}
if it.bval == chunkenc.ValFloat {
it.b.adjustAtValue(lastValue)
it.b.adjustAtValue(lastFloatValue)
}
}

Expand Down

0 comments on commit 911e3bc

Please sign in to comment.