int es_mba_prepare( struct es_mba *agg, struct es_mbd *resultdef, const char *resultcls, char *queryplan, int queryplansize );
Prepare a query plan for the aggregator to execute. Requires that all key, result, filter and formula fields have already been specified.
The aggregator generates a program (known as a query plan) using the iterator (struct es_mbi ) API to traverse an input database and populate a root node in a result database.
For each key and result field, es_mba_prepare() adds a field definition to
es_mba_prepare() attempts to find a single iteration path through the database that will allow it to pick-up all required database fields.
The query plan involves the traversal of a single root node, plus all required child and descendant nodes, using es_mbi_beginfetch() and es_mbi_incfetch(). Any field that cannot be found in this path is acquired by calling es_mbi_findfetch() against other root and associated descendent nodes. Relevent foreign keys required by es_mbi_findfetch() must be available in the initial iteration path.
es_mba_prepare() attempts to pick the most optimal route through the database by minimizing the set of additional es_mbi_findfetch() calls and redundant fetches. If such a route is not possible, es_mba_prepare() fails with a
A textual summary of the query plan is assigned to the
Implementation of any specified formulae is included in the query plan. If any one formula requires the use of too many temporary variables, es_mba_prepare() will fail with a
Once es_mba_prepare() successfully completes it can be executed against input and result databases instances via es_mba_exec().
|Copyright © 2012 by Richard Brooks|