Skip to main content

Module storage_bridge

Module storage_bridge 

Source
Expand description

§Phase 0: Storage Bridge — Wiring SQL Execution to Real Storage

This module provides concrete implementations of the query layer’s StorageBackend and SqlConnection traits, backed by the actual sochdb_storage::Database kernel.

§Architecture

┌─────────────────────────────────────────────────┐
│           Query Layer (sochdb-query)             │
│                                                  │
│  ┌──────────────┐    ┌───────────────────────┐  │
│  │ OptimizedExec │    │ SQL AST (SqlBridge)  │  │
│  └──────┬───────┘    └───────────┬───────────┘  │
│         │                        │               │
│  ┌──────▼────────────────────────▼───────────┐  │
│  │        StorageBackend trait                │  │
│  │        SqlConnection trait                 │  │
│  └──────────────────┬────────────────────────┘  │
├─────────────────────┼────────────────────────────┤
│         ┌───────────▼───────────────┐            │
│         │  DatabaseStorageBackend   │            │
│         │  DatabaseSqlConnection    │            │
│         └───────────┬───────────────┘            │
├─────────────────────┼────────────────────────────┤
│           Storage Layer (sochdb-storage)         │
│         ┌───────────▼───────────┐                │
│         │   Database kernel     │                │
│         │  (DurableStorage +    │                │
│         │   MVCC + WAL)         │                │
│         └───────────────────────┘                │
└─────────────────────────────────────────────────┘

§SochValue Bridging

The storage layer uses sochdb_core::SochValue (10 variants including Object and Ref), while the query optimizer uses sochdb_query::soch_ql::SochValue (8 variants, missing Object/Ref).

This module provides convert_core_to_query() to bridge the gap:

  • Object(map) → serialized as Text(json_string)
  • Ref { table, id }Text("table/id")

Structs§

DatabaseSqlConnection
Concrete implementation of SqlConnection backed by sochdb_storage::Database.
DatabaseStorageBackend
Concrete implementation of StorageBackend backed by sochdb_storage::Database.
NamespacedSqlConnection
A wrapper around any SqlConnection that prefixes table names with namespace:database: to provide storage-level isolation between tenants.

Functions§

convert_core_to_query
Convert sochdb_core::SochValue to sochdb_query::soch_ql::SochValue.
convert_query_to_core
Convert sochdb_query::soch_ql::SochValue to sochdb_core::SochValue.