uqa_storage/sqlite/
document_store.rs1use std::collections::BTreeMap;
10use std::sync::Arc;
11
12use rusqlite::{params, OptionalExtension};
13use uqa_core::{DecimalValue, DocId, TemporalValue, Value};
14
15use crate::backend::StorageBackendResult;
16use crate::document_store::{Document, DocumentStore};
17use crate::sqlite::connection::{ManagedConnection, Result as SQLiteResult, SQLiteError};
18
19const DOCUMENT_BLOBS_TABLE: &str = "_document_blobs";
20const BLOB_MARKER_TYPE: &str = "$uqa_type";
21const BLOB_MARKER_VALUE: &str = "document_blob";
22const BLOB_MARKER_FIELD: &str = "field";
23const BLOB_MARKER_ENCODING: &str = "encoding";
24const VALUE_BLOB_MARKER_VALUE: &str = "value_blob";
25const VALUE_BLOB_F64_LIST: &str = "f64_list";
26const VALUE_BLOB_F64_TENSOR: &str = "f64_tensor";
27const VALUE_BLOB_TYPED_JSON: &str = "typed_json_v1";
28const MIN_NUMERIC_BLOB_VALUES: usize = 32;
29const DOC_ID_IN_CHUNK: usize = 256;
30
31type EncodedDocument = (Document, Vec<(String, Vec<u8>)>);
32
33mod batching;
34mod blob;
35mod store;
36mod trait_impl;
37mod typed_value;
38
39use batching::{
40 allocation_error, chunk_bind_values, doc_id_in_placeholders, document_id_from_sqlite,
41 read_doc_id, should_probe_doc_ids, sorted_unique_doc_ids, sqlite_doc_id,
42};
43use blob::{
44 blob_marker, blob_marker_info, decode_json_field_value, delete_document_blob,
45 hydrate_document_blobs, load_marked_document_blob, take_requested_field, upsert_document_blob,
46 value_blob_marker,
47};
48use typed_value::{
49 decode_legacy_document_body, decode_legacy_json_value, encode_document_blobs,
50 encode_stored_value, StoredValue,
51};
52
53#[derive(Clone)]
54pub struct SQLiteDocumentStore {
55 conn: ManagedConnection,
56 table: String,
57}
58
59#[cfg(test)]
60mod tests;