author | Florian Forster <octo@noris.net> | |
Wed, 22 Jul 2009 07:55:21 +0000 (09:55 +0200) | ||
committer | Florian Forster <octo@noris.net> | |
Wed, 22 Jul 2009 08:22:52 +0000 (10:22 +0200) | ||
commit | 5472038917e3fbf19e4706e488c1522018c51749 | |
tree | d23afba807b7a5501792a615e97958af8933166c | tree | snapshot |
parent | 35f98b6e5c4c30bd7aeb52c7894c5f6e276638da | commit | diff |
src/utils_cache.[ch]: Add uc_get_history[_by_name].
These two new functions can be used to get historical data of values in
the cache. This can be used to calculate floating averages, hysteresis
and a shipload of other aggregation and consolidation functions.
The current implementation is probably not yet perfect:
- If not enough values are available to satisfy the request, the buffer
will be enlarged and NaNs will be returned in the newly allocated
cells. The caller has no way to recognize this case.
- If a value is missing, no NaNs will be added to the cache. It's
unclear if this was desirable.
- The returned values are reversed, i. e. val[0] will be the newest
value, val[n-1] will be the oldest. Here, too, I'm unsure which way
is easier to comprehend / use. I went for this implementation because
it was easier to write.
These two new functions can be used to get historical data of values in
the cache. This can be used to calculate floating averages, hysteresis
and a shipload of other aggregation and consolidation functions.
The current implementation is probably not yet perfect:
- If not enough values are available to satisfy the request, the buffer
will be enlarged and NaNs will be returned in the newly allocated
cells. The caller has no way to recognize this case.
- If a value is missing, no NaNs will be added to the cache. It's
unclear if this was desirable.
- The returned values are reversed, i. e. val[0] will be the newest
value, val[n-1] will be the oldest. Here, too, I'm unsure which way
is easier to comprehend / use. I went for this implementation because
it was easier to write.
src/utils_cache.c | diff | blob | history | |
src/utils_cache.h | diff | blob | history |