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