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
87
88
89
90
91
92
93
|
#pragma once
#include <yql/essentials/core/services/yql_transform_pipeline.h>
#include <yql/essentials/core/services/yql_plan.h>
#include <yql/essentials/utils/log/log.h>
#include <yql/essentials/core/yql_type_annotation.h>
#include <yql/essentials/core/yql_graph_transformer.h>
#include <library/cpp/yson/public.h>
#include <util/stream/output.h>
#include <util/generic/ptr.h>
namespace NYql {
class TExprOutputTransformer {
public:
TExprOutputTransformer(const TExprNode::TPtr& exprRoot, IOutputStream* directOut, bool withTypes)
: ExprRoot_(exprRoot), DirectOut_(directOut), WithTypes_(withTypes)
{
}
IGraphTransformer::TStatus operator()(const TExprNode::TPtr& input, TExprNode::TPtr& output, TExprContext& ctx);
static TAutoPtr<IGraphTransformer> Sync(
const TExprNode::TPtr& exprRoot,
IOutputStream* directOut,
bool withTypes = false)
{
return directOut ? CreateFunctorTransformer(TExprOutputTransformer(exprRoot, directOut, withTypes)) : nullptr;
}
private:
const TExprNode::TPtr &ExprRoot_;
IOutputStream *DirectOut_;
bool WithTypes_;
};
class TPlanOutputTransformer {
public:
TPlanOutputTransformer(
IOutputStream* directOut,
IPlanBuilder& builder,
NYson::EYsonFormat outputFormat,
TPlanSettings&& settings = {})
: DirectOut_(directOut)
, Builder_(builder)
, OutputFormat_(outputFormat)
, PlanSettings_(std::move(settings))
{
}
IGraphTransformer::TStatus operator()(const TExprNode::TPtr& input, TExprNode::TPtr& output, TExprContext& ctx);
static TAutoPtr <IGraphTransformer> Sync(
IOutputStream* directOut,
IPlanBuilder& builder,
NYson::EYsonFormat outputFormat)
{
return CreateFunctorTransformer(TPlanOutputTransformer(directOut, builder, outputFormat));
}
private:
IOutputStream* DirectOut_;
IPlanBuilder& Builder_;
NYson::EYsonFormat OutputFormat_;
TPlanSettings PlanSettings_;
};
class TExprLogTransformer {
public:
TExprLogTransformer(const TString& description, NYql::NLog::EComponent component, NYql::NLog::ELevel level)
: Description(description)
, Component(component)
, Level(level) {}
NYql::IGraphTransformer::TStatus operator()(const NYql::TExprNode::TPtr& input, NYql::TExprNode::TPtr& output,
NYql::TExprContext& ctx);
static TAutoPtr<NYql::IGraphTransformer> Sync(const TString& description,
NYql::NLog::EComponent component = NYql::NLog::EComponent::Core,
NYql::NLog::ELevel level = NYql::NLog::ELevel::TRACE)
{
return CreateFunctorTransformer(TExprLogTransformer(description, component, level));
}
private:
TString Description;
NYql::NLog::EComponent Component;
NYql::NLog::ELevel Level;
};
} // namespace NYql
|