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
532504
#[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
620050
#[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
1185298
pub fn view_entries_tree_name(view_name: &impl Display) -> String {
25
1185298
    format!("view.{:#}", view_name)
26
1185298
}
27

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

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

            
37
11175
pub fn view_versions_tree_name(collection: &CollectionName) -> String {
38
11175
    format!("view-versions.{:#}", collection)
39
11175
}