Read a segment file, auto-detecting its type.
(
path: &Path,
registry: &DictionaryRegistry,
)
| 292 | |
| 293 | /// Read a segment file, auto-detecting its type. |
| 294 | pub 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 |
nothing calls this directly
no test coverage detected