Turi Create
4.0
|
Typedefs | |
typedef std::shared_ptr< planner_node > | turi::query_eval::pnode_ptr |
A handy typedef. | |
Functions | |
turi::query_eval::operator_impl< planner_node_type::SARRAY_SOURCE_NODE >::DECL_CORO_STATE (execute) | |
static size_t | turi::query_eval::operator_impl< planner_node_type::SARRAY_SOURCE_NODE >::unique_sarray_tag (const std::shared_ptr< sarray< flexible_type > > &sa) |
All the available query plan operators are defined in here.
There are 2 parts to an operator. 1: How to execute the operator (a specialization of operator_impl) 2: The logical node in the graph (planner_node)
First, to define a new operator, add to the enum in operator_properties
and define your new new operator as a class operator_impl<enum>
(the operator itself is just a specialization of the operator_impl
class around the enum)
There are no constraints on the constructor or destructor of the class, or what members the class should have. The class should contain enough information to perform the execute() method.
The functions which must be implemented are
A couple of routines to convert back of forth between planner_node and the operator implementation:
operator_impl<enum>::make_planner_node(...) operator_impl<enum>::plan_to_operator(...)
Additionally the following static methods must be provided
operator_impl<enum>::infer_type(...)
A length inference routine:
operator_impl<enum>::infer_length(...)
To give an example, to implement a transform operator (see the source in transform.hpp). The example here defines a simplified version that only transforms a single column of flexible_type.
The class is:
To define a transform, we define constructor to accept a generic function. We need to know the actual output type of the function ahead of time.
We next define the name of the operator, as well as the attributes. Since transform takes 1 input and returns 1 output, we just return LINEAR.
Execute is a little subtle. It takes a query_context, reads from it writing to an output buffer (also provided by the query_context) and calls emit() to write the output buffer out.
We need converters between planner_node and this operator. The planner_node really just stores a bunch of information in a generic map->any and we have to figure out our own schema in it. A bunch of assertions checks are removed for readability.
To guide the graph verification and planning process of the logical graph, a couple of methods around type or length inference has to be provided.
Finally, for convenience, we might typedef the whole class to something easier to read
turi::query_eval::operator_impl< planner_node_type::SARRAY_SOURCE_NODE >::DECL_CORO_STATE | ( | execute | ) |
A "sarray_source" operator generates values from a physical sarray.
|
inlinestatic |
Given an sarray, returns a small number uniquely associated with that sarray. This number is unique over the course of the program run.
Definition at line 148 of file sarray_source.hpp.