Skip to main content

concept_store/
tables.rs

1//! The table set of one artifact.
2//!
3//! Every value is a byte string decoded by `record`, so a damaged artifact is
4//! a typed error at read time rather than a panic inside the database. Keys
5//! are dense ordinals; the vocabulary tables give each property key,
6//! designation use, and language reference set its ordinal and name.
7
8use redb::TableDefinition;
9
10/// Artifact-level facts: system URI, version, edition, layout version.
11pub const META: TableDefinition<&str, &str> = TableDefinition::new("meta");
12/// Native code to concept ordinal.
13pub const CODES: TableDefinition<&str, u32> = TableDefinition::new("codes");
14/// Concept ordinal to its encoded [`crate::record::Concept`].
15pub const CONCEPTS: TableDefinition<u32, &[u8]> = TableDefinition::new("concepts");
16/// `(concept ordinal, designation index)` to an encoded [`crate::record::Designation`].
17pub const DESIGNATIONS: TableDefinition<(u32, u32), &[u8]> = TableDefinition::new("designations");
18/// `(concept ordinal, designation index, language refset ordinal)` to an acceptability ordinal.
19pub const ACCEPTABILITY: TableDefinition<(u32, u32, u32), u32> =
20    TableDefinition::new("acceptability");
21/// `(concept ordinal, language refset ordinal, designation use ordinal)` to the
22/// preferred designation index, precomputed by the build.
23pub const PREFERRED: TableDefinition<(u32, u32, u32), u32> = TableDefinition::new("preferred");
24/// `(concept ordinal, property key ordinal)` to an encoded list of [`crate::record::PropertyValue`].
25pub const PROPERTIES: TableDefinition<(u32, u32), &[u8]> = TableDefinition::new("properties");
26/// Property key ordinal to its name.
27pub const PROPERTY_KEYS: TableDefinition<u32, &str> = TableDefinition::new("property_keys");
28/// Designation use ordinal to its code (for SNOMED, the description type SCTID).
29pub const DESIGNATION_USES: TableDefinition<u32, &str> = TableDefinition::new("designation_uses");
30/// Language reference set ordinal to its code.
31pub const LANGUAGE_REFSETS: TableDefinition<u32, &str> = TableDefinition::new("language_refsets");
32/// Acceptability ordinal to its code.
33pub const ACCEPTABILITIES: TableDefinition<u32, &str> = TableDefinition::new("acceptabilities");
34
35/// The `META` key of the layout version.
36pub const META_LAYOUT: &str = "layout";
37/// The layout version this build writes and reads.
38pub const LAYOUT_VERSION: &str = "2";
39/// The `META` key of the code system URI.
40pub const META_SYSTEM: &str = "system";
41/// The `META` key of the code system version string.
42pub const META_VERSION: &str = "version";
43/// The `META` key of the number of concepts.
44pub const META_CONCEPTS: &str = "concepts";