Velox--编译执行
2023-07-20 19:02:39 0 举报
Velox 的代码编译逻辑
作者其他创作
大纲/内容
AstNode
CompiledExpressionAnalysisResult
font color=\"#a23735\
arg
className
col_colName
usingDeclName
typeCol(colName)
inputMap
generatedStructCode
struct col_colName
outputIndex
表示由generateCode生成的中间部分代码的结构。
CodegenCompiledExpressionTransform
shared_ptr<PlanNode> transform( PlanNode& planNode)
FieldAccessTypedExpr
std::string name_;bool isInputColumn_;
//Represents one of two things://- a leaf in an expression tree specifying input column by name;//- a dereference expression which selects a subfield in a struct by name.
ITypedExpr
vector<std::shared_ptr<const ITypedExpr>> inputs_
Compiler(LLVM)
把字符串代码存成文件,然后编译
ProjectNode
vector<PlanNodePtr> sources_;vector<string> names_;vector<TypedExprPtr> projections_;RowTypePtr outputType_;
CompiledExpressionTransformVisitor
LambdaTypedExpr
RowTypePtr signature_;TypedExprPtr body_;
ExprCodeGenerator
GeneratedExpressionStruct codegenExpressionspan style=\"font-weight: normal;\
CastTypedExpr
bool nullOnFailure_;
Task::Start
subprocess.h
执行编译命令
ICompiledCall
std::string& name()
DriverFactory
GenerateCompiledExpressionVisitor
CompiledExpressionAnalysisResult& result_
VeloxInteractiveQueryPlanConverter
CODEGEN_ENABLED
std::string name_;bool isInputColumn_;
//Represents one of two things://- a leaf in an expression tree specifying input column by name;//- a dereference expression which selects a subfield in a struct by name.
optional<NewInstanceSignature> newInstanceFunction_
!newInstanceFunction_.has_value()
ExprSet
generateAstVisitor
std::optional<CodegenASTNode> generateAst( const std::shared_ptr<const core::font color=\"#569230\
font color=\"#000000\
TaskResource
给定它的行类型,计算给定列的输入映射。(inputMap)例如:columnType = [{\"c\
optional<T> value_
FilterNode
vector<PlanNodePtr> sources_;TypedExprPtr filter_;
velox\\velox\\expression\\ExprCompiler.cpp
NativeLibraryLoader
dlopen--> 动态库加载
void* loadLibrary(font color=\"#569230\
FilterProject
ConstantExpression
optional<T> value_
shared_ptr<const Type> type_; vector<shared_ptr<const ITypedExpr>> inputs_;
链接程序
LocalPlanner
添加 Drivers
velox\\velox\\expression\\Expr.cpp
CallTypedExpr
std::string name_(func name)
Compiler
编译源文件
optional<string> name_;
!name_.has_value()
Codegen
\\velox\\experimental\\codegen\\Codegen.cpp
unique_ptr<ExprSet> exprs_
CodegenASTAnalysis
font color=\"#569230\
void run(const core::PlanNode& rootNode)
ConcatTypedExpr
Evaluates a list of expressions to produce a row.
void visit(const core::PlanNode& planNode)
TaskManager
UDFCallExpr
// Information about the called udf are stored in this structure const UDFInformation udfInformation_; // Function call input arguments std::vector<ASTNodePtr> children_;
AST node represent a general function call with no code-gen specificoptimizations and handling.
State state
Expr
Ast Node
Base Class
row_constructor
MakeRowExpression
ASTNode
if
IfExpression
switch
SwitchExpression
coalesce
CoalesceExpr
plus
AddExpr
BinaryExpr
minus
SubtractExpr
multiply
MultiplyExpr
gt
GreaterThan
gte
GreaterThanEquel
lt
LessThan
lte
LessThanEqual
neq
NotEqual
and
LogicalAnd
or
LogicalOr
is_null
IsNullExpr
UnaryExpr
not
NotExpr
ConstantTypedExpr
variant value_;VectorPtr valueVector_;
filesystem::path dynamicLibPath_;
string registerFunction()
filesystem::path dynamicLibPath_;optional<string> name_;
动态链接库地址
Task
shared_ptr<PlanNode> compile( PlanNode& planNode)
InputTypedExpr
\"ROW\"
velox\\velox\\core\\Expressions.h
col_colName(struct)
PlanNode
string id_;
进入 Presto
State
codegen::TempsAllocator allocator
CodeSnippet
// The name of the output variable that holds the expression result value std::string outputVarName_; (\"outputTuple\") // The code that need to be executed std::string code_;
// Convert velox::ITypedExpr to codegen AST
CodegenASTNode convertVeloxExpressionToCodegenAST( const std::shared_ptr<const core::font color=\"#569230\
构建一个执行编译给定的文件的命令对象
GeneratedExpressionStruct
RowType inputRowType_;RowType outputRowType_;/// Library headers required for compilation const std::unordered_set<std::string> headers_;/// Body of the expression invoke member method const std::string invokeFunctionBody_; (code) /// Members declarations to be added to the struct std::vector<std::string> declarations_;
CompiledExpressionAnalysis
void run(PlanNode& plan)
PrestoTask
shared_ptr<velox::exec::Task> task
PlanNode-->Expr
CodeSnippet generateCodespan style=\"font-weight: normal;\
variant
TypeKind kind_;void* ptr_;
CompiledExpressionAnalysisResult result_
string& toStruct( const std::string& name)
0 条评论
下一页