Enum mentat::FindSpec [] [src]

pub enum FindSpec {

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.


  let elements = vec![
  let rel = FindSpec::FindRel(elements);

  if let FindSpec::FindRel(elements) = rel {
    assert_eq!(2, elements.len());


Returns an array of arrays, represented as a single array with length a multiple of width.

Returns an array of scalars, usually homogeneous. This is equivalent to mapping over the results of a FindRel, returning the first value of each.

Returns a single tuple: a heterogeneous array of scalars. Equivalent to taking the first result from a FindRel.

Returns a single scalar value. Equivalent to taking the first result from a FindColl.


impl FindSpec

Returns true if the provided FindSpec returns at most one result.

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.

Important traits for Box<R>

Trait Implementations

impl Eq for FindSpec

impl PartialEq<FindSpec> for FindSpec

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Debug for FindSpec

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl !Send for FindSpec

impl !Sync for FindSpec