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

Function read_segment

nodedb/src/engine/timeseries/reader.rs:294–311  ·  view source on GitHub ↗

Read a segment file, auto-detecting its type.

(
    path: &Path,
    registry: &DictionaryRegistry,
)

Source from the content-addressed store, hash-verified

292
293/// Read a segment file, auto-detecting its type.
294pub fn read_segment(
295 path: &Path,
296 registry: &DictionaryRegistry,
297) -> Result<SegmentData, SegmentReadError> {
298 let data = std::fs::read(path)?;
299
300 let header_end = decode_tseg_header(&data)?;
301 let kind = data
302 .get(header_end)
303 .copied()
304 .ok_or(SegmentReadError::TooSmall { size: data.len() })?;
305
306 match kind {
307 KIND_METRIC => read_metric_segment_from_bytes(&data).map(SegmentData::Metric),
308 KIND_LOG => read_log_segment_from_bytes(&data, registry).map(SegmentData::Log),
309 k => Err(SegmentReadError::UnknownKind { kind: k }),
310 }
311}
312
313// ── Aggregation helpers ───────────────────────────────────────────────────────
314

Callers

nothing calls this directly

Calls 6

decode_tseg_headerFunction · 0.85
readFunction · 0.50
getMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected