internal package
Foswiki::Query::Node is a
Foswiki::Infix::Node A Node object is a single node in a query (either a tree node or a leaf node). A tree of node objects represents a query over the Foswiki database.
Fields are given by name, and values by strings or numbers.
A query object implements theevaluate
method as its general
contract with the rest of the world. This method is a "reference implementation" -
it does a brute force evaluation of the expression represented by the node in a given
data domain. It is expected that smarter store implementations will analyse the parse tree
and derive as many optimisations as possible, minimising fallback to this brute force
evaluation.
The reference implementation of evaluation uses the getField
method in the
{Store}{QueryAlgorithm} to get data from the store. This further decouples the query
object from the detail of the store implementation.
See Foswiki::Store::QueryAlgorithms for a full spec of the interface to
query algorithms.
ObjectMethod
evaluate(...) → $result evaluate
method of the attached operator.
The return result is either an array ref (for many results) or a scalar (for a
single result)
This is the reference evaluator for queries. However it may not be the only engine that evaluates them; external engines, such as SQL, might be delegated the responsibility of evaluating queries in a search context.
Name resolution depends on the context in which the name is used. A name on the LHS of the dot and where operators may only be a form name, or a META: name, referred to as a "restricted name". A name anywhere else can be a META: name, a field name, or one of the shortcuts (such as "web", "name" etc). Fields and forms are looked up by calling thegetField
and
getForm
methods in the query engine respectively.
ObjectMethod
evaluatesToConstant(%opts) Support for expression optimisation/hoisting.
Determine if this node evaluates to a constant or not. "Constant" is defined as "anything that doesn't involve actually looking in searched topics". This function takes the same parameters (%domain) as evaluate(). Note that no reference to the tom or data web or topic will be made, so you can simply pass an arbitrary Foswiki::Meta.ObjectMethod
simplify(%opts) ObjectMethod
tokens() → [] ObjectMethod
isEmpty() → $boolean