Skip to content

Commit

Permalink
feat(cognitarium): add plan builder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Jun 5, 2023
1 parent 4563ae0 commit 9d374eb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions contracts/okp4-cognitarium/src/querier/plan_builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use crate::msg::{
Literal, Node, Prefix, SimpleWhereCondition, TriplePattern, VarOrNode, VarOrNodeOrLiteral,
WhereClause, WhereCondition, IRI,
};
use crate::querier::plan::{PatternValue, QueryNode, QueryPlan};
use crate::state::{namespaces, Object, Predicate, Subject};
use crate::{rdf, state};
use cosmwasm_std::{StdError, StdResult, Storage};
use std::collections::HashMap;

pub struct PlanBuilder<'a> {
storage: &'a dyn Storage,
prefixes: HashMap<String, String>,
variables: Vec<String>,
}

impl<'a> PlanBuilder<'a> {
pub fn new(storage: &'a dyn Storage, prefixes: Vec<Prefix>) -> Self {
Self {
storage,
prefixes: Self::make_prefixes(prefixes),
variables: Vec::new(),
}
}

pub fn build_plan(&mut self, where_clause: WhereClause) -> StdResult<QueryPlan> {
Err(StdError::generic_err("not implemented"))
}

fn make_prefixes(as_list: Vec<Prefix>) -> HashMap<String, String> {
as_list.iter().fold(HashMap::new(), |mut map, prefix| {
map.insert(prefix.prefix.clone(), prefix.namespace.clone());
map
})
}
}

0 comments on commit 9d374eb

Please sign in to comment.