Package org.apache.calcite.interpreter
Class Interpreter.CompilerImpl
- java.lang.Object
-
- org.apache.calcite.rel.RelVisitor
-
- org.apache.calcite.interpreter.Interpreter.CompilerImpl
-
- All Implemented Interfaces:
Compiler
,ReflectiveVisitor
- Direct Known Subclasses:
Nodes.CoreCompiler
- Enclosing class:
- Interpreter
static class Interpreter.CompilerImpl extends RelVisitor implements Compiler, ReflectiveVisitor
Walks over a tree ofRelNode
and, for each, creates aNode
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 thenode
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.
-
-
Field Summary
Fields Modifier and Type Field Description private ReflectiveVisitDispatcher<Interpreter.CompilerImpl,RelNode>
dispatcher
protected Interpreter
interpreter
protected Node
node
(package private) java.util.Map<RelNode,Interpreter.NodeInfo>
nodes
(package private) com.google.common.collect.Multimap<RelNode,Interpreter.Edge>
outEdges
protected RelNode
rel
(package private) java.util.Map<RelNode,java.util.List<RelNode>>
relInputs
private static java.lang.String
REWRITE_METHOD_NAME
protected RelNode
rootRel
(package private) Interpreter.ScalarCompiler
scalarCompiler
private static java.lang.String
VISIT_METHOD_NAME
-
Constructor Summary
Constructors Constructor Description CompilerImpl(Interpreter interpreter, RelOptCluster cluster)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RelDataType
combinedRowType(java.util.List<RelNode> inputs)
Scalar
compile(java.util.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,java.util.Map<RelNode,Interpreter.NodeInfo>>
visitRoot(RelNode p)
Visits the tree, starting from the rootp
.-
Methods inherited from class org.apache.calcite.rel.RelVisitor
go, replaceRoot
-
-
-
-
Field Detail
-
scalarCompiler
final Interpreter.ScalarCompiler scalarCompiler
-
dispatcher
private final ReflectiveVisitDispatcher<Interpreter.CompilerImpl,RelNode> dispatcher
-
interpreter
protected final Interpreter interpreter
-
rootRel
protected RelNode rootRel
-
rel
protected RelNode rel
-
node
protected Node node
-
nodes
final java.util.Map<RelNode,Interpreter.NodeInfo> nodes
-
outEdges
final com.google.common.collect.Multimap<RelNode,Interpreter.Edge> outEdges
-
REWRITE_METHOD_NAME
private static final java.lang.String REWRITE_METHOD_NAME
- See Also:
- Constant Field Values
-
VISIT_METHOD_NAME
private static final java.lang.String VISIT_METHOD_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CompilerImpl
CompilerImpl(Interpreter interpreter, RelOptCluster cluster)
-
-
Method Detail
-
visitRoot
Pair<RelNode,java.util.Map<RelNode,Interpreter.NodeInfo>> visitRoot(RelNode p)
Visits the tree, starting from the rootp
.
-
visit
public void visit(RelNode p, int ordinal, RelNode parent)
Description copied from class:RelVisitor
Visits a node during a traversal.- Overrides:
visit
in classRelVisitor
- Parameters:
p
- Node to visitordinal
- Ordinal of node within its parentparent
- Parent of the node, or null if it is the root of the traversal
-
rewrite
public void rewrite(RelNode r)
-
compile
public Scalar compile(java.util.List<RexNode> nodes, RelDataType inputRowType)
Description copied from interface:Compiler
Compiles an expression to an executable form.
-
combinedRowType
public RelDataType combinedRowType(java.util.List<RelNode> inputs)
- Specified by:
combinedRowType
in interfaceCompiler
-
sink
public Sink sink(RelNode rel)
Description copied from interface:Compiler
Creates a Sink for a relational expression to write into.This method is generally called from the constructor of a
Node
. But a constructor could instead callCompiler.enumerable(RelNode, Enumerable)
.
-
enumerable
public void enumerable(RelNode rel, Enumerable<Row> rowEnumerable)
Description copied from interface:Compiler
Tells the interpreter that a given relational expression wishes to give its output as an enumerable.This is as opposed to the norm, where a relational expression calls
Compiler.sink(RelNode)
, then itsNode.run()
method writes into that sink.- Specified by:
enumerable
in interfaceCompiler
- Parameters:
rel
- Relational expressionrowEnumerable
- Contents of relational expression
-
createContext
public Context createContext()
- Specified by:
createContext
in interfaceCompiler
-
getDataContext
public DataContext getDataContext()
- Specified by:
getDataContext
in interfaceCompiler
-
-