1
use std::fmt::Display;
2

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

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

            
12
    pub reduced_value: Bytes,
13
}
14

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

            
21
pub mod integrity_scanner;
22
pub mod mapper;
23

            
24
899460
pub fn view_entries_tree_name(view_name: &impl Display) -> String {
25
899460
    format!("view.{:#}", view_name)
26
899460
}
27

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

            
33
1793022
pub fn view_invalidated_docs_tree_name(view_name: &impl Display) -> String {
34
1793022
    format!("view.{:#}.invalidated", view_name)
35
1793022
}
36

            
37
275760
pub fn view_omitted_docs_tree_name(view_name: &impl Display) -> String {
38
275760
    format!("view.{:#}.omitted", view_name)
39
275760
}
40

            
41
8457
pub fn view_versions_tree_name(collection: &CollectionName) -> String {
42
8457
    format!("view-versions.{:#}", collection)
43
8457
}