1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#pragma once
#include <yql/essentials/ast/yql_expr.h>
namespace NYql {
class IDqOptimization {
public:
virtual ~IDqOptimization() {}
/**
Rewrite DqReadWrap's underlying provider specific read callable
Args:
* read - provider specific read callable
* ctx - expr context
Returns one of:
* empty TPtr on error
* original `read`, if no changes
* new read, if any optimizations
*/
virtual TExprNode::TPtr RewriteRead(const TExprNode::TPtr& read, TExprContext& ctx) = 0;
/**
Rewrite DqReadWrap's underlying provider specific read callable for lookup
Args:
* read - provider specific read callable
* ctx - expr context
Returns of of:
* empty TPtr, if lookup read is not supported
* DqLookupSourceWrap callable
*/
virtual TExprNode::TPtr RewriteLookupRead(const TExprNode::TPtr& read, TExprContext& ctx) = 0;
/**
Apply new members subset for DqReadWrap's underlying provider specific read callable
Args:
* read - provider specific read callable
* members - expr list of atoms with new members
* ctx - expr context
Returns one of:
* empty TPtr on error
* original `read`, if no changes
* new read with applyed new members
*/
virtual TExprNode::TPtr ApplyExtractMembers(const TExprNode::TPtr& read, const TExprNode::TPtr& members, TExprContext& ctx) = 0;
/**
Apply `take` or `skip` setting for DqReadWrap's underlying provider specific read callable
Args:
* read - provider specific read callable
* countBase - `Take`, `Skip` or `Limit` callable
* ctx - expr context
Returns one of:
* empty TPtr on error
* original `read`, if no changes
* new read with applyed setting
*/
virtual TExprNode::TPtr ApplyTakeOrSkip(const TExprNode::TPtr& read, const TExprNode::TPtr& countBase, TExprContext& ctx) = 0;
/**
Apply `unordered` setting for DqReadWrap's underlying provider specific read callable
Args:
* read - provider specific read callable
* ctx - expr context
Returns one of:
* empty TPtr on error
* original `read`, if no changes
* new read with applyed setting
*/
virtual TExprNode::TPtr ApplyUnordered(const TExprNode::TPtr& read, TExprContext& ctx) = 0;
/**
Optimize list/stream extend for set of DqReadWrap's underlying provider specific read callable
Args:
* listOfRead - expr list of provider specific read callables
* ordered - `true` for ordered extend (must keep original order of reads); `false`, if reads may be reordred due the optimization
* ctx - expr context
Returns one of:
* empty list on error
* original `listOfRead`, if no changes
* new optimized list of reads. Returned list length must not be greater than original `listOfRead` length
*/
virtual TExprNode::TListType ApplyExtend(const TExprNode::TListType& listOfRead, bool ordered, TExprContext& ctx) = 0;
};
} // namespace NYql
|