generated from okp4/template-rust
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cognitarium): add plan builder structure
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) | ||
} | ||
} |