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/// Packed columns by name, each a [`crate::column::Column`] addressed by
15/// ordinal. `concepts` holds the encoded [`crate::record::Concept`] of every
16/// ordinal.
17pub const COLUMNS: TableDefinition<&str, &[u8]> = TableDefinition::new("columns");
18/// The `COLUMNS` key of the concept column.
19pub const COLUMN_CONCEPTS: &str = "concepts";
20/// The `COLUMNS` key of the preferred-designation column, the displays the
21/// build chose per concept.
22pub const COLUMN_DISPLAYS: &str = "displays";
23/// The `COLUMNS` key of the property column, one encoded
24/// [`crate::record::Properties`] per concept.
25pub const COLUMN_PROPERTIES: &str = "properties";
26/// The `COLUMNS` key of the acceptability column, one encoded
27/// [`crate::record::Acceptability`] per concept.
28pub const COLUMN_ACCEPTABILITY: &str = "acceptability";
29/// Concept ordinal to its encoded [`crate::record::Designations`].
30///
31/// The designation text is the largest thing an artifact holds, so it stays in
32/// the database and is point-read per concept; the columns the store reads
33/// into memory carry only what a request path walks (#338).
34pub const DESIGNATIONS: TableDefinition<u32, &[u8]> = TableDefinition::new("designations");
35/// Property key ordinal to its name.
36pub const PROPERTY_KEYS: TableDefinition<u32, &str> = TableDefinition::new("property_keys");
37/// Designation use ordinal to its code (for SNOMED, the description type SCTID).
38pub const DESIGNATION_USES: TableDefinition<u32, &str> = TableDefinition::new("designation_uses");
39/// Language reference set ordinal to its code.
40pub const LANGUAGE_REFSETS: TableDefinition<u32, &str> = TableDefinition::new("language_refsets");
41/// Acceptability ordinal to its code.
42pub const ACCEPTABILITIES: TableDefinition<u32, &str> = TableDefinition::new("acceptabilities");
43
44/// The `META` key of the layout version.
45pub const META_LAYOUT: &str = "layout";
46/// The layout version this build writes and reads.
47pub const LAYOUT_VERSION: &str = "6";
48/// The `META` key of the code system URI.
49pub const META_SYSTEM: &str = "system";
50/// The `META` key of the code system version string.
51pub const META_VERSION: &str = "version";
52/// The `META` key of the number of concepts.
53pub const META_CONCEPTS: &str = "concepts";
54/// The `META` key of the acceptability ordinal that marks a designation
55/// preferred in its language reference set.
56pub const META_PREFERRED: &str = "preferred";