Use query-storage for storage access in other crates

This commit is contained in:
Hassan Abedi 2026-06-04 12:16:30 +02:00
parent ed8c438135
commit b572161142
19 changed files with 43 additions and 34 deletions

4
Cargo.lock generated
View File

@ -976,6 +976,9 @@ dependencies = [
[[package]]
name = "query-ops"
version = "0.1.0"
dependencies = [
"query-storage",
]
[[package]]
name = "query-storage"
@ -984,7 +987,6 @@ dependencies = [
"fjall",
"geomerge",
"heed",
"query-ops",
"redb",
"sled",
"tempfile",

View File

@ -9,3 +9,4 @@ rust-version.workspace = true
workspace = true
[dependencies]
query-storage = { path = "../query-storage" }

View File

@ -9,7 +9,10 @@
use std::collections::HashMap;
use crate::{relation::Relation, table::Table, value::Value};
use query_storage::table::Table;
use query_storage::value::Value;
use crate::relation::Relation;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Term {

View File

@ -11,7 +11,9 @@
use std::collections::{HashMap, HashSet};
use crate::{relation::Relation, value::Value};
use query_storage::value::Value;
use crate::relation::Relation;
fn shared_columns(left: &Relation, right: &Relation) -> Vec<(usize, usize)> {
left.columns

View File

@ -2,8 +2,8 @@
//!
//! Three operators are in scope:
//!
//! - [`atom::scan_atom`] scans a [`table::Table`] under an
//! [`atom::AtomPattern`], filtering for repeated-variable equality and
//! - [`atom::scan_atom`] scans a [`Table`](query_storage::table::Table) under
//! an [`atom::AtomPattern`], filtering for repeated-variable equality and
//! literal equality, and outputs a binding [`relation::Relation`].
//! - [`join::semijoin`] keeps rows of one relation whose shared-column values
//! appear in another.
@ -14,10 +14,11 @@
//! is just an expression like
//! `natural_join(&semijoin(&a, &b), &scan_atom(&t, &p))`.
//!
//! Integration with an external query-plan IR is out of scope.
//! Foundational types [`Value`](query_storage::value::Value) and
//! [`Table`](query_storage::table::Table) live in `query-storage`, the
//! storage-layer crate this crate is built on; storage backends produce
//! `Table`s that operators here consume.
pub mod atom;
pub mod join;
pub mod relation;
pub mod table;
pub mod value;

View File

@ -10,7 +10,7 @@
use std::collections::HashSet;
use crate::value::Value;
use query_storage::value::Value;
#[derive(Debug, Clone)]
pub struct Relation {

View File

@ -15,8 +15,8 @@
use query_ops::atom::{AtomPattern, Term, scan_atom};
use query_ops::join::{natural_join, semijoin};
use query_ops::table::Table;
use query_ops::value::Value;
use query_storage::table::Table;
use query_storage::value::Value;
fn s(x: &str) -> Value {
Value::Str(x.to_string())

View File

@ -5,8 +5,8 @@
//! through the [`scan_as_table`] bridge, with no changes to `query-ops` itself.
use query_ops::atom::{AtomPattern, Term, scan_atom};
use query_ops::table::Table;
use query_ops::value::Value;
use query_storage::table::Table;
use query_storage::value::Value;
use query_storage::{MemoryStorage, Storage, StorageError, scan_as_table};
fn i(x: i64) -> Value {

View File

@ -20,7 +20,6 @@ sled = ["dep:sled"]
geomerge = ["dep:geomerge"]
[dependencies]
query-ops = { path = "../query-ops" }
heed = { version = "0.20", optional = true }
redb = { version = "2", optional = true }
fjall = { version = "2", optional = true }

View File

@ -28,7 +28,7 @@
//!
//! Per-relation metadata is `[arity: u32 LE] [next_id: u64 LE]` = 12 bytes.
use query_ops::value::Value;
use crate::value::Value;
/// Errors raised by [`decode_row`] and [`decode_meta`].
#[derive(Debug)]

View File

@ -6,7 +6,7 @@
use fjall::{Keyspace, PartitionCreateOptions, PartitionHandle};
use query_ops::value::Value;
use crate::value::Value;
use crate::codec::{decode_meta, decode_row, encode_meta, encode_row, row_key};
use crate::{Storage, StorageError};

View File

@ -25,7 +25,7 @@ use geomerge::store::Store;
use geomerge::table::CellValue;
use geomerge::txn::ops::TxnCellValue;
use query_ops::value::Value;
use crate::value::Value;
use crate::{Storage, StorageError};

View File

@ -1,15 +1,14 @@
//! Storage backend abstraction for the query-plan playground.
//! Storage layer for the query-plan playground.
//!
//! Operators in [`query_ops`] work over in-memory [`Table`](query_ops::table::Table)
//! and [`Relation`](query_ops::relation::Relation) values. This crate adds a
//! [`Storage`] trait so the input tables can come from a backend (an
//! in-memory [`MemoryStorage`], an LMDB environment, a `geomerge` store, and
//! so on) instead of being built by hand in every test.
//! This is the foundational crate of the workspace. It owns the [`Value`] cell
//! type and the [`Table`] container, defines the [`Storage`] trait, and ships
//! adapters for several backends behind Cargo features. Higher-level crates
//! such as `query-ops` depend on this crate for both the types and the trait.
//!
//! The v1 surface is deliberately narrow: create a relation, scan all rows,
//! insert a row, ask for arity. Transactions, range scans, deletes, and delta
//! streams are not modeled yet, and will be added when a specific experiment
//! demands them.
//! The v1 trait surface is deliberately narrow: create a relation, scan all
//! rows, insert a row, ask for arity. Transactions, range scans, deletes, and
//! delta streams are not modeled yet, and will be added when a specific
//! experiment demands them.
//!
//! ## Backends
//!
@ -22,11 +21,13 @@
//! - `sled` — pure-Rust LSM-tree
//! - `geomerge` — the workspace's `geomerge` crate
use query_ops::table::Table;
use query_ops::value::Value;
use crate::table::Table;
use crate::value::Value;
pub mod codec;
pub mod memory;
pub mod table;
pub mod value;
#[cfg(feature = "sled")]
pub mod sled;
@ -133,7 +134,7 @@ pub trait Storage {
}
/// Materialize a relation from a [`Storage`] backend as a [`Table`] that
/// [`scan_atom`](query_ops::atom::scan_atom) can consume.
/// query-language operators can consume.
///
/// # Errors
/// Returns any error produced by [`Storage::arity`] or [`Storage::scan`].

View File

@ -11,7 +11,7 @@
use heed::types::Bytes;
use heed::{Database, Env, EnvOpenOptions};
use query_ops::value::Value;
use crate::value::Value;
use crate::codec::{decode_meta, decode_row, encode_meta, encode_row, row_key};
use crate::{Storage, StorageError};

View File

@ -2,7 +2,7 @@
use std::collections::HashMap;
use query_ops::value::Value;
use crate::value::Value;
use crate::{Storage, StorageError};

View File

@ -6,7 +6,7 @@
use redb::{Database, ReadableTable, TableDefinition};
use query_ops::value::Value;
use crate::value::Value;
use crate::codec::{decode_meta, decode_row, encode_meta, encode_row};
use crate::{Storage, StorageError};

View File

@ -4,7 +4,7 @@
//! reserved tree named `__meta` carries per-relation metadata (arity and the
//! next synthetic row ID).
use query_ops::value::Value;
use crate::value::Value;
use crate::codec::{decode_meta, decode_row, encode_meta, encode_row, row_key};
use crate::{Storage, StorageError};