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

Method next_sample

nodedb-codec/src/gorilla.rs:213–232  ·  view source on GitHub ↗

Decode the next sample, or None if all samples decoded.

(&mut self)

Source from the content-addressed store, hash-verified

211
212 /// Decode the next sample, or None if all samples decoded.
213 pub fn next_sample(&mut self) -> Option<(i64, f64)> {
214 if self.count >= self.total {
215 return None;
216 }
217
218 if self.first {
219 self.first = false;
220 let ts = self.reader.read_bits(64).ok()? as i64;
221 let val = self.reader.read_bits(64).ok()?;
222 self.prev_ts = ts;
223 self.prev_value = val;
224 self.count = 1;
225 return Some((ts, f64::from_bits(val)));
226 }
227
228 let ts = self.decode_timestamp().ok()?;
229 let val = self.decode_value().ok()?;
230 self.count += 1;
231 Some((ts, f64::from_bits(val)))
232 }
233
234 fn decode_timestamp(&mut self) -> Result<i64, CodecError> {
235 let bit = self.reader.read_bit()?;

Callers 2

decode_allMethod · 0.80
single_sample_roundtripFunction · 0.80

Calls 4

read_bitsMethod · 0.80
decode_timestampMethod · 0.80
decode_valueMethod · 0.80
okMethod · 0.45

Tested by 1

single_sample_roundtripFunction · 0.64