pub enum FindSpec {
FindRel(Vec<Element>),
FindColl(Element),
FindTuple(Vec<Element>),
FindScalar(Element),
}Expand description
A definition of the first part of a find query: the
[:find ?foo ?bar…] bit.
There are four different kinds of find specs, allowing you to query for a single value, a collection of values from different entities, a single tuple (relation), or a collection of tuples.
Examples:
let elements = vec![
Element::Variable("?foo".to_var()),
Element::Variable("?bar".to_var()),
];
let rel = FindSpec::FindRel(elements);
if let FindSpec::FindRel(elements) = rel {
assert_eq!(2, elements.len());
}
Variants§
FindRel(Vec<Element>)
Returns an array of arrays, represented as a single array with length a multiple of width.
FindColl(Element)
Returns an array of scalars, usually homogeneous.
This is equivalent to mapping over the results of a FindRel,
returning the first value of each.
FindTuple(Vec<Element>)
Returns a single tuple: a heterogeneous array of scalars. Equivalent to
taking the first result from a FindRel.
FindScalar(Element)
Returns a single scalar value. Equivalent to taking the first result
from a FindColl.
Implementations§
Source§impl FindSpec
Returns true if the provided FindSpec returns at most one result.
impl FindSpec
Returns true if the provided FindSpec returns at most one result.
pub fn is_unit_limited(&self) -> bool
pub fn expected_column_count(&self) -> usize
Sourcepub fn requires_distinct(&self) -> bool
pub fn requires_distinct(&self) -> bool
Returns true if the provided FindSpec cares about distinct results.
I use the words “cares about” because find is generally defined in terms of producing distinct results at the Datalog level.
Two of the find specs (scalar and tuple) produce only a single result. Those don’t need to be
run with SELECT DISTINCT, because we’re only consuming a single result. Those queries will be
run with LIMIT 1.
Additionally, some projections cannot produce duplicate results: [:find (max ?x) …], for
example.
This function gives us the hook to add that logic when we’re ready.
Beyond this, DISTINCT is not always needed. For example, in some kinds of accumulation or
sampling projections we might not need to do it at the SQL level because we’re consuming into
a dupe-eliminating data structure like a Set, or we know that a particular query cannot produce
duplicate results.
pub fn columns<'s>(&'s self) -> Box<dyn Iterator<Item = &'s Element> + 's>
Trait Implementations§
impl Eq for FindSpec
impl StructuralPartialEq for FindSpec
Auto Trait Implementations§
impl Freeze for FindSpec
impl RefUnwindSafe for FindSpec
impl Send for FindSpec
impl Sync for FindSpec
impl Unpin for FindSpec
impl UnsafeUnpin for FindSpec
impl UnwindSafe for FindSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more