static class Interpreter.CompilerImpl extends RelVisitor implements Compiler, ReflectiveVisitor
RelNode and, for each,
creates a Node that can be
executed in the interpreter.
The compiler looks for methods of the form "visit(XxxRel)".
A "visit" method must create an appropriate Node and put it into
the node field.
If you wish to handle more kinds of relational expressions, add extra "visit" methods in this or a sub-class, and they will be found and called via reflection.
| Modifier and Type | Field and Description |
|---|---|
private ReflectiveVisitDispatcher<Interpreter.CompilerImpl,RelNode> |
dispatcher |
protected Interpreter |
interpreter |
protected Node |
node |
(package private) Map<RelNode,Interpreter.NodeInfo> |
nodes |
(package private) com.google.common.collect.Multimap<RelNode,Interpreter.Edge> |
outEdges |
protected RelNode |
rel |
(package private) Map<RelNode,List<RelNode>> |
relInputs |
private static String |
REWRITE_METHOD_NAME |
protected RelNode |
rootRel |
(package private) Interpreter.ScalarCompiler |
scalarCompiler |
private static String |
VISIT_METHOD_NAME |
| Constructor and Description |
|---|
CompilerImpl(Interpreter interpreter,
RelOptCluster cluster) |
| Modifier and Type | Method and Description |
|---|---|
RelDataType |
combinedRowType(List<RelNode> inputs) |
Scalar |
compile(List<RexNode> nodes,
RelDataType inputRowType)
Compiles an expression to an executable form.
|
Context |
createContext() |
void |
enumerable(RelNode rel,
Enumerable<Row> rowEnumerable)
Tells the interpreter that a given relational expression wishes to
give its output as an enumerable.
|
DataContext |
getDataContext() |
private RelNode |
getInput(RelNode rel,
int ordinal) |
void |
rewrite(RelNode r)
Fallback rewrite method.
|
Sink |
sink(RelNode rel)
Creates a Sink for a relational expression to write into.
|
Source |
source(RelNode rel,
int ordinal) |
void |
visit(RelNode p,
int ordinal,
RelNode parent)
Visits a node during a traversal.
|
(package private) Pair<RelNode,Map<RelNode,Interpreter.NodeInfo>> |
visitRoot(RelNode p)
Visits the tree, starting from the root
p. |
go, replaceRootfinal Interpreter.ScalarCompiler scalarCompiler
private final ReflectiveVisitDispatcher<Interpreter.CompilerImpl,RelNode> dispatcher
protected final Interpreter interpreter
protected RelNode rootRel
protected RelNode rel
protected Node node
final Map<RelNode,Interpreter.NodeInfo> nodes
final com.google.common.collect.Multimap<RelNode,Interpreter.Edge> outEdges
private static final String REWRITE_METHOD_NAME
private static final String VISIT_METHOD_NAME
CompilerImpl(Interpreter interpreter, RelOptCluster cluster)
Pair<RelNode,Map<RelNode,Interpreter.NodeInfo>> visitRoot(RelNode p)
p.public void visit(RelNode p, int ordinal, RelNode parent)
RelVisitorvisit in class RelVisitorp - Node to visitordinal - Ordinal of node within its parentparent - Parent of the node, or null if it is the root of the
traversalpublic void rewrite(RelNode r)
public Scalar compile(List<RexNode> nodes, RelDataType inputRowType)
Compilerpublic RelDataType combinedRowType(List<RelNode> inputs)
combinedRowType in interface Compilerpublic Sink sink(RelNode rel)
CompilerThis method is generally called from the constructor of a Node.
But a constructor could instead call
Compiler.enumerable(RelNode, Enumerable).
public void enumerable(RelNode rel, Enumerable<Row> rowEnumerable)
CompilerThis is as opposed to the norm, where a relational expression calls
Compiler.sink(RelNode), then its Node.run() method writes into that
sink.
enumerable in interface Compilerrel - Relational expressionrowEnumerable - Contents of relational expressionpublic Context createContext()
createContext in interface Compilerpublic DataContext getDataContext()
getDataContext in interface CompilerCopyright © 2012–2018 The Apache Software Foundation. All rights reserved.