use nusy_arrow_core::ArrowGraphStore;
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct GitConfig {
pub snapshot_dir: PathBuf,
}
impl GitConfig {
pub fn new(snapshot_dir: impl Into<PathBuf>) -> Self {
GitConfig {
snapshot_dir: snapshot_dir.into(),
}
}
}
impl Default for GitConfig {
fn default() -> Self {
GitConfig {
snapshot_dir: PathBuf::from(".nusy-arrow/snapshots"),
}
}
}
pub struct GitObjectStore {
pub store: ArrowGraphStore,
pub config: GitConfig,
}
impl GitObjectStore {
pub fn new() -> Self {
GitObjectStore {
store: ArrowGraphStore::new(),
config: GitConfig::default(),
}
}
pub fn with_snapshot_dir(dir: impl Into<PathBuf>) -> Self {
GitObjectStore {
store: ArrowGraphStore::new(),
config: GitConfig::new(dir),
}
}
pub fn commit_snapshot_dir(&self, commit_id: &str) -> PathBuf {
self.config.snapshot_dir.join(commit_id)
}
pub fn namespace_parquet_path(&self, commit_id: &str, namespace: &str) -> PathBuf {
self.commit_snapshot_dir(commit_id)
.join(format!("{namespace}.parquet"))
}
}
impl Default for GitObjectStore {
fn default() -> Self {
Self::new()
}
}