Turi Create
4.0
lazy_eval_operation.hpp
1
/* Copyright © 2017 Apple Inc. All rights reserved.
2
*
3
* Use of this source code is governed by a BSD-3-clause license that can
4
* be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5
*/
6
#ifndef TURI_LAZY_EVAL_OPERATION_HPP
7
#define TURI_LAZY_EVAL_OPERATION_HPP
8
#include <string>
9
#include <vector>
10
11
namespace
turi
{
12
13
/**
14
* \ingroup lazy_eval
15
* The base class for describing lazy operations using the lazy_operation_dag
16
* system.
17
*
18
* \tparam T The object type tracked in the lazy operation DAG
19
*/
20
template
<
typename
T>
21
struct
lazy_eval_operation_base
{
22
typedef
T value_type;
23
/**
24
* Number of arguments in the operation. For instance, a simple
25
* transformation (like "add_row") is a unary transform, and this
26
* function will return 1. A "join" is a binary transform, and will return 2.
27
* Finally, parent-less operations like "load_from_file" will return 0.
28
*
29
* The only valid values at this time are 0, 1 or 2.
30
*/
31
virtual
size_t
num_arguments
() = 0;
32
33
/**
34
* Printable name of the operation
35
*/
36
virtual
std::string
name
()
const
{
return
std::string(
""
);}
37
38
/**
39
* Execute the operation on the object, and the parents provided.
40
* The size of the "parents" list is max(#arguments - 2, 0).
41
*
42
* - For the Nullary function (function of 0 arguments, i.e. o = f() ) the
43
* size of the parents list is empty, and the operation should be
44
* performed on the output object directly.
45
* - For the Unary function (function of 1 argument. i.e. o = f(a1) ) the
46
* output object is the "parent" object , and the operation should be
47
* performed inplace. i.e, it shoud really compute ( o = f(o) )
48
* - For the Binary function (function of 2 arguments) ( o = f(a1, a2) )
49
* the output object is the also the 1st parent, and the ancestor list
50
* contains a pointer to the 2nd parent. i.e. it should really compute
51
* ( o = f(o, a2) )
52
* - Operations of higher order generalize and extend accordingly.
53
*/
54
virtual
void
execute
(T& output,
55
const
std::vector<T*>& parents) = 0;
56
57
virtual
~
lazy_eval_operation_base
() {}
58
};
59
60
}
// namespace turi
61
#endif
turi::lazy_eval_operation_base::execute
virtual void execute(T &output, const std::vector< T *> &parents)=0
turi::lazy_eval_operation_base
Definition:
lazy_eval_operation.hpp:21
turi::lazy_eval_operation_base::name
virtual std::string name() const
Definition:
lazy_eval_operation.hpp:36
turi
SKD.
Definition:
capi_initialization.hpp:11
turi::lazy_eval_operation_base::num_arguments
virtual size_t num_arguments()=0
core
storage
lazy_eval
lazy_eval_operation.hpp
Generated by
1.8.13