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
1163742
#[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
149571666
#[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
2174757
pub fn view_entries_tree_name(view_name: &impl Display) -> String {
27
2174757
    format!("view.{view_name:#}")
28
2174757
}
29

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

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

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