use super::format::{COLUMNAR_CKPT_FORMAT_VERSION, ColumnarCheckpointManifest};
use super::paths::COLUMNAR_CKPT_MANIFEST;
use crate::data::executor::checkpoint_decode_error::CheckpointDecodeError;
use crate::data::executor::core_loop::CoreLoop;
impl CoreLoop {
pub(super) fn read_columnar_manifest(
&self,
ckpt_dir: &std::path::Path,
) -> Result<Option<ColumnarCheckpointManifest>, CheckpointDecodeError> {
let path = ckpt_dir.join(COLUMNAR_CKPT_MANIFEST);
if !path.exists() {
return Ok(None);
}
let bytes = nodedb_wal::segment::read_checkpoint_framed(&path).map_err(|source| {
CheckpointDecodeError::ReadFile {
path: path.clone(),
source,
}
})?;
let manifest =
zerompk::from_msgpack::<ColumnarCheckpointManifest>(&bytes).map_err(|source| {
CheckpointDecodeError::MsgpackDecode {
path: path.clone(),
source,
}
})?;
if manifest.format_version != COLUMNAR_CKPT_FORMAT_VERSION {
return Err(CheckpointDecodeError::FormatVersion {
path: path.clone(),
found: manifest.format_version,
expected: COLUMNAR_CKPT_FORMAT_VERSION,
});
}
Ok(Some(manifest))
}
}
pub(super) fn storage_err(
path: &std::path::Path,
action: &str,
e: &dyn std::fmt::Display,
) -> crate::Error {
crate::Error::Storage {
engine: "columnar".to_string(),
detail: format!(
"columnar checkpoint: failed to {action} at {}: {e}",
path.display()
),
}
}