keepLastValue behaviour

Asked by Fabien LD

Hi,

Let consider this series stored in DB: 10, 20, None, 40, 50, None, None, None, None, None, 110

When Calling keepLastValue(3), then I would expect the following series as a result:
    10, 20, 20, 40, 50, 50, 50, None, None, None, 110
or:
   10, 20, 20, 40, 50, 50, 50, 50, None, None, 110
(depending on if the "last value" is included in the count).

But current behaviour is to return:
   10, 20, 20, 40, 50, None, None, None, None, None, 110
i.e. no value is repeated after 50 since the number of consecutiveNones between value 50 and value 110 is greater than the provided limit (5>3).

So, from the documentation, I would expect the keepLastValue function to behave like this:
----
def keepLastValue(requestContext, seriesList, limit = INF):
  for series in seriesList:
    series.name = "keepLastValue(%s)" % (series.name)
    series.pathExpression = series.name
    consecutiveNones = 0
    last = None
    for i,value in enumerate(series):
      #series[i] = value

      if value is None:
        if last is None:
          continue
        consecutiveNones += 1
        if 0 < consecutiveNones < limit:
          series[i] = last
      else:
        last = value
        consecutiveNones = 0

  return seriesList
----

If it is not the expected behaviour, then this is a behaviour I am looking for from Graphite so it would be nice to add a function for this (something like "repeatLastValueIfNone(requestContext, seriesList, lim)")

Cheers,
Fabien

Question information

Language:
English Edit question
Status:
Expired
For:
Graphite Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.