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

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

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

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