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

Function write_test_metric_segment

nodedb/src/engine/timeseries/reader.rs:435–450  ·  view source on GitHub ↗
(dir: &Path, samples: &[(i64, f64)])

Source from the content-addressed store, hash-verified

433 }
434
435 fn write_test_metric_segment(dir: &Path, samples: &[(i64, f64)]) -> std::path::PathBuf {
436 let mut encoder = GorillaEncoder::new();
437 for &(ts, val) in samples {
438 encoder.encode(ts, val);
439 }
440 let gorilla_block = encoder.finish();
441
442 let path = dir.join("test-metric.seg");
443 let mut buf = make_tseg_header();
444 buf.push(KIND_METRIC);
445 buf.extend_from_slice(&(samples.len() as u64).to_le_bytes());
446 buf.extend_from_slice(&(gorilla_block.len() as u32).to_le_bytes());
447 buf.extend_from_slice(&gorilla_block);
448 std::fs::write(&path, &buf).unwrap();
449 path
450 }
451
452 #[test]
453 fn read_metric_segment_roundtrip() {

Callers 1

Calls 7

make_tseg_headerFunction · 0.85
joinMethod · 0.80
writeFunction · 0.50
encodeMethod · 0.45
finishMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by 1