Skip to content

Commit

Permalink
feat(cognitarium): define query engine structure
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Jun 5, 2023
1 parent 9d374eb commit 6a8d7b9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/okp4-cognitarium/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod contract;
mod error;
pub mod msg;
mod querier;
mod rdf;
pub mod state;
mod storer;
Expand Down
32 changes: 32 additions & 0 deletions contracts/okp4-cognitarium/src/querier/engine.rs
Original file line number Diff line number Diff line change
@@ -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<dyn Iterator<Item = StdResult<ResolvedVariables>>>;

pub enum ResolvedVariable {
Subject(Subject),
Predicate(Predicate),
Object(Object),
}

pub struct ResolvedVariables {
pub variables: Vec<Option<ResolvedVariable>>,
}
3 changes: 3 additions & 0 deletions contracts/okp4-cognitarium/src/querier/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod engine;
mod plan;
mod plan_builder;

0 comments on commit 6a8d7b9

Please sign in to comment.