Skip to main content

uni_common/core/
snapshot.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2024-2026 Dragonscale Team
3
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6use std::collections::HashMap;
7
8#[derive(Clone, Debug, Serialize, Deserialize)]
9pub struct SnapshotManifest {
10    pub snapshot_id: String,
11    pub name: Option<String>,
12    pub created_at: DateTime<Utc>,
13    pub parent_snapshot: Option<String>,
14    pub schema_version: u32,
15    pub version_high_water_mark: u64,
16    pub wal_high_water_mark: u64,
17
18    pub vertices: HashMap<String, LabelSnapshot>,
19    pub edges: HashMap<String, EdgeSnapshot>,
20}
21
22#[derive(Clone, Debug, Serialize, Deserialize)]
23pub struct LabelSnapshot {
24    pub version: u32,
25    pub count: u64,
26    pub lance_version: u64,
27}
28
29#[derive(Clone, Debug, Serialize, Deserialize)]
30pub struct EdgeSnapshot {
31    pub version: u32,
32    pub count: u64,
33    pub lance_version: u64,
34}
35
36impl SnapshotManifest {
37    pub fn new(snapshot_id: String, schema_version: u32) -> Self {
38        Self {
39            snapshot_id,
40            name: None,
41            created_at: Utc::now(),
42            parent_snapshot: None,
43            schema_version,
44            version_high_water_mark: 0,
45            wal_high_water_mark: 0,
46            vertices: HashMap::new(),
47            edges: HashMap::new(),
48        }
49    }
50}