nusy_arrow_git/
object_store.rs1use nusy_arrow_core::ArrowGraphStore;
7use std::path::PathBuf;
8
9#[derive(Debug, Clone)]
11pub struct GitConfig {
12 pub snapshot_dir: PathBuf,
14}
15
16impl GitConfig {
17 pub fn new(snapshot_dir: impl Into<PathBuf>) -> Self {
18 GitConfig {
19 snapshot_dir: snapshot_dir.into(),
20 }
21 }
22}
23
24impl Default for GitConfig {
25 fn default() -> Self {
26 GitConfig {
27 snapshot_dir: PathBuf::from(".nusy-arrow/snapshots"),
28 }
29 }
30}
31
32pub struct GitObjectStore {
34 pub store: ArrowGraphStore,
36 pub config: GitConfig,
38}
39
40impl GitObjectStore {
41 pub fn new() -> Self {
43 GitObjectStore {
44 store: ArrowGraphStore::new(),
45 config: GitConfig::default(),
46 }
47 }
48
49 pub fn with_snapshot_dir(dir: impl Into<PathBuf>) -> Self {
51 GitObjectStore {
52 store: ArrowGraphStore::new(),
53 config: GitConfig::new(dir),
54 }
55 }
56
57 pub fn commit_snapshot_dir(&self, commit_id: &str) -> PathBuf {
59 self.config.snapshot_dir.join(commit_id)
60 }
61
62 pub fn namespace_parquet_path(&self, commit_id: &str, namespace: &str) -> PathBuf {
64 self.commit_snapshot_dir(commit_id)
65 .join(format!("{namespace}.parquet"))
66 }
67}
68
69impl Default for GitObjectStore {
70 fn default() -> Self {
71 Self::new()
72 }
73}