MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / update

Method update

nodedb/src/engine/timeseries/last_value_cache.rs:49–62  ·  view source on GitHub ↗

Update the cache for a series. Only updates if `ts >= cached_ts`. Returns `true` if the entry was updated (new or newer timestamp).

(&mut self, series_id: SeriesId, ts: i64, value: f64)

Source from the content-addressed store, hash-verified

47 ///
48 /// Returns `true` if the entry was updated (new or newer timestamp).
49 pub fn update(&mut self, series_id: SeriesId, ts: i64, value: f64) -> bool {
50 match self.entries.get_mut(&series_id) {
51 Some(entry) if ts >= entry.ts => {
52 entry.ts = ts;
53 entry.value = value;
54 true
55 }
56 Some(_) => false, // Older timestamp, skip.
57 None => {
58 self.entries.insert(series_id, LastValueEntry { ts, value });
59 true
60 }
61 }
62 }
63
64 /// O(1) lookup of the last value for a series.
65 pub fn get(&self, series_id: SeriesId) -> Option<&LastValueEntry> {

Callers 8

ingest_batch_with_lvcFunction · 0.45
newer_timestamp_updatesFunction · 0.45
older_timestamp_skippedFunction · 0.45
same_timestamp_updatesFunction · 0.45
multiple_seriesFunction · 0.45
all_returns_all_entriesFunction · 0.45
remove_seriesFunction · 0.45
clear_cacheFunction · 0.45

Calls 2

get_mutMethod · 0.45
insertMethod · 0.45

Tested by 7

newer_timestamp_updatesFunction · 0.36
older_timestamp_skippedFunction · 0.36
same_timestamp_updatesFunction · 0.36
multiple_seriesFunction · 0.36
all_returns_all_entriesFunction · 0.36
remove_seriesFunction · 0.36
clear_cacheFunction · 0.36