|
|
@ -17,7 +17,7 @@ use crate::runtime::transact::SessionTx;
|
|
|
|
|
|
|
|
|
|
|
|
pub(crate) type PullSpecs = Vec<PullSpec>;
|
|
|
|
pub(crate) type PullSpecs = Vec<PullSpec>;
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
|
|
|
pub(crate) enum PullSpec {
|
|
|
|
pub(crate) enum PullSpec {
|
|
|
|
PullAll,
|
|
|
|
PullAll,
|
|
|
|
PullId(Keyword),
|
|
|
|
PullId(Keyword),
|
|
|
@ -33,40 +33,40 @@ impl PullSpec {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
|
|
|
pub(crate) struct AttrPullSpec {
|
|
|
|
pub(crate) struct AttrPullSpec {
|
|
|
|
|
|
|
|
pub(crate) recursive: bool,
|
|
|
|
|
|
|
|
pub(crate) reverse: bool,
|
|
|
|
pub(crate) attr: Attribute,
|
|
|
|
pub(crate) attr: Attribute,
|
|
|
|
pub(crate) default_val: StaticValue,
|
|
|
|
pub(crate) default_val: StaticValue,
|
|
|
|
pub(crate) reverse: bool,
|
|
|
|
|
|
|
|
pub(crate) name: Keyword,
|
|
|
|
pub(crate) name: Keyword,
|
|
|
|
pub(crate) cardinality: AttributeCardinality,
|
|
|
|
pub(crate) cardinality: AttributeCardinality,
|
|
|
|
pub(crate) take: Option<usize>,
|
|
|
|
pub(crate) take: Option<usize>,
|
|
|
|
pub(crate) nested: PullSpecs,
|
|
|
|
pub(crate) nested: PullSpecs,
|
|
|
|
pub(crate) recursive: bool,
|
|
|
|
|
|
|
|
pub(crate) recursion_limit: Option<usize>,
|
|
|
|
pub(crate) recursion_limit: Option<usize>,
|
|
|
|
pub(crate) recursion_depth: usize,
|
|
|
|
pub(crate) recursion_depth: usize,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
|
|
|
|
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
|
|
|
|
pub(crate) struct CurrentPath(SmallVec<[usize; 8]>);
|
|
|
|
pub(crate) struct CurrentPath(SmallVec<[u16; 8]>);
|
|
|
|
|
|
|
|
|
|
|
|
impl CurrentPath {
|
|
|
|
impl CurrentPath {
|
|
|
|
pub(crate) fn new(idx: usize) -> Self {
|
|
|
|
pub(crate) fn new(idx: usize) -> Result<Self> {
|
|
|
|
Self(smallvec![idx])
|
|
|
|
Ok(Self(smallvec![idx.try_into()?]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn get_from_root<'a>(&self, depth: usize, root: &'a PullSpecs) -> &'a PullSpecs {
|
|
|
|
fn get_from_root<'a>(&self, depth: usize, root: &'a PullSpecs) -> &'a PullSpecs {
|
|
|
|
let mut current = root;
|
|
|
|
let mut current = root;
|
|
|
|
let indices = &self.0[..self.0.len() - depth];
|
|
|
|
let indices = &self.0[..self.0.len() - depth];
|
|
|
|
for i in indices {
|
|
|
|
for i in indices {
|
|
|
|
current = ¤t[*i].as_attr_spec().unwrap().nested;
|
|
|
|
current = ¤t[*i as usize].as_attr_spec().unwrap().nested;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
current
|
|
|
|
current
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn push(&self, idx: usize) -> Self {
|
|
|
|
fn push(&self, idx: usize) -> Result<Self> {
|
|
|
|
let mut ret = CurrentPath(Default::default());
|
|
|
|
let mut ret = CurrentPath(Default::default());
|
|
|
|
ret.0.clone_from(&self.0);
|
|
|
|
ret.0.clone_from(&self.0);
|
|
|
|
ret.0.push(idx);
|
|
|
|
ret.0.push(idx.try_into()?);
|
|
|
|
ret
|
|
|
|
Ok(ret)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn recurse_pop(&self, depth: usize) -> Self {
|
|
|
|
fn recurse_pop(&self, depth: usize) -> Self {
|
|
|
|
Self(self.0[..self.0.len() + 1 - depth].to_smallvec())
|
|
|
|
Self(self.0[..self.0.len() + 1 - depth].to_smallvec())
|
|
|
@ -255,7 +255,7 @@ impl SessionTx {
|
|
|
|
sub_spec,
|
|
|
|
sub_spec,
|
|
|
|
depth,
|
|
|
|
depth,
|
|
|
|
root,
|
|
|
|
root,
|
|
|
|
path.push(idx),
|
|
|
|
path.push(idx)?,
|
|
|
|
&mut sub_collector,
|
|
|
|
&mut sub_collector,
|
|
|
|
recursive_seen,
|
|
|
|
recursive_seen,
|
|
|
|
)?;
|
|
|
|
)?;
|
|
|
@ -334,7 +334,7 @@ impl SessionTx {
|
|
|
|
sub_spec,
|
|
|
|
sub_spec,
|
|
|
|
depth,
|
|
|
|
depth,
|
|
|
|
root,
|
|
|
|
root,
|
|
|
|
path.push(idx),
|
|
|
|
path.push(idx)?,
|
|
|
|
&mut sub_collector,
|
|
|
|
&mut sub_collector,
|
|
|
|
recursive_seen,
|
|
|
|
recursive_seen,
|
|
|
|
)?;
|
|
|
|
)?;
|
|
|
|