From 6a8d7b94c74d17245a3de3c2f0acd26e6a44949f Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Mon, 22 May 2023 17:52:20 +0200 Subject: [PATCH] feat(cognitarium): define query engine structure --- contracts/okp4-cognitarium/src/lib.rs | 1 + .../okp4-cognitarium/src/querier/engine.rs | 32 +++++++++++++++++++ contracts/okp4-cognitarium/src/querier/mod.rs | 3 ++ 3 files changed, 36 insertions(+) create mode 100644 contracts/okp4-cognitarium/src/querier/engine.rs create mode 100644 contracts/okp4-cognitarium/src/querier/mod.rs diff --git a/contracts/okp4-cognitarium/src/lib.rs b/contracts/okp4-cognitarium/src/lib.rs index 7728f722..365515f9 100644 --- a/contracts/okp4-cognitarium/src/lib.rs +++ b/contracts/okp4-cognitarium/src/lib.rs @@ -1,6 +1,7 @@ pub mod contract; mod error; pub mod msg; +mod querier; mod rdf; pub mod state; mod storer; diff --git a/contracts/okp4-cognitarium/src/querier/engine.rs b/contracts/okp4-cognitarium/src/querier/engine.rs new file mode 100644 index 00000000..c7c491a1 --- /dev/null +++ b/contracts/okp4-cognitarium/src/querier/engine.rs @@ -0,0 +1,32 @@ +use crate::querier::plan::{PatternValue, QueryNode, QueryPlan}; +use crate::state::{triples, Object, Predicate, Subject, Triple}; +use cosmwasm_std::{Order, StdError, StdResult, Storage}; +use cw_storage_plus::IndexList; +use std::collections::VecDeque; +use std::iter; + +pub struct QueryEngine<'a> { + storage: &'a dyn Storage, +} + +impl<'a> QueryEngine<'a> { + pub fn new(storage: &'a dyn Storage) -> Self { + Self { storage } + } + + pub fn eval_plan(&self, plan: QueryPlan) -> ResolvedVariablesIterator { + Box::new(iter::empty()) + } +} + +type ResolvedVariablesIterator = Box>>; + +pub enum ResolvedVariable { + Subject(Subject), + Predicate(Predicate), + Object(Object), +} + +pub struct ResolvedVariables { + pub variables: Vec>, +} diff --git a/contracts/okp4-cognitarium/src/querier/mod.rs b/contracts/okp4-cognitarium/src/querier/mod.rs new file mode 100644 index 00000000..ec122506 --- /dev/null +++ b/contracts/okp4-cognitarium/src/querier/mod.rs @@ -0,0 +1,3 @@ +mod engine; +mod plan; +mod plan_builder;