1
use std::fmt::Display;
2

            
3
use bonsaidb_core::arc_bytes::serde::Bytes;
4
use bonsaidb_core::document::Header;
5
use bonsaidb_core::schema::CollectionName;
6
use serde::{Deserialize, Serialize};
7

            
8
1241794
#[derive(Debug, Serialize, Deserialize)]
9
pub struct ViewEntry {
10
    pub view_version: u64,
11
    pub key: Bytes,
12
    pub mappings: Vec<EntryMapping>,
13

            
14
    pub reduced_value: Bytes,
15
}
16

            
17
153615532
#[derive(Debug, Serialize, Deserialize)]
18
pub struct EntryMapping {
19
    pub source: Header,
20
    pub value: Bytes,
21
}
22

            
23
pub mod integrity_scanner;
24
pub mod mapper;
25

            
26
2219402
pub fn view_entries_tree_name(view_name: &impl Display) -> String {
27
2219402
    format!("view.{view_name:#}")
28
2219402
}
29

            
30
/// Used to store Document ID -> Key mappings, so that when a document is updated, we can remove the old entry.
31
1139675
pub fn view_document_map_tree_name(view_name: &impl Display) -> String {
32
1139675
    format!("view.{view_name:#}.document-map")
33
1139675
}
34

            
35
3702526
pub fn view_invalidated_docs_tree_name(view_name: &impl Display) -> String {
36
3702526
    format!("view.{view_name:#}.invalidated")
37
3702526
}
38

            
39
19707
pub fn view_versions_tree_name(collection: &CollectionName) -> String {
40
19707
    format!("view-versions.{collection:#}")
41
19707
}