Package org.apache.calcite.rel.rules
Class MultiJoin
- java.lang.Object
-
- org.apache.calcite.rel.AbstractRelNode
-
- org.apache.calcite.rel.rules.MultiJoin
-
- All Implemented Interfaces:
java.lang.Cloneable
,RelOptNode
,RelNode
public final class MultiJoin extends AbstractRelNode
A MultiJoin represents a join of N inputs, whereas regular Joins represent strictly binary joins.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<RelNode>
inputs
private boolean
isFullOuterJoin
com.google.common.collect.ImmutableMap<java.lang.Integer,ImmutableIntList>
joinFieldRefCountsMap
private RexNode
joinFilter
private com.google.common.collect.ImmutableList<JoinRelType>
joinTypes
private java.util.List<RexNode>
outerJoinConditions
private RexNode
postJoinFilter
private java.util.List<ImmutableBitSet>
projFields
private RelDataType
rowType
-
Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, traitSet
-
-
Constructor Summary
Constructors Constructor Description MultiJoin(RelOptCluster cluster, java.util.List<RelNode> inputs, RexNode joinFilter, RelDataType rowType, boolean isFullOuterJoin, java.util.List<RexNode> outerJoinConditions, java.util.List<JoinRelType> joinTypes, java.util.List<ImmutableBitSet> projFields, com.google.common.collect.ImmutableMap<java.lang.Integer,ImmutableIntList> joinFieldRefCountsMap, RexNode postJoinFilter)
Constructs a MultiJoin.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RelNode
accept(RexShuttle shuttle)
Accepts a visit from a shuttle.private java.util.Map<java.lang.Integer,int[]>
cloneJoinFieldRefCountsMap()
Returns a deep copy ofjoinFieldRefCountsMap
.(package private) boolean
containsOuter()
RelNode
copy(RelTraitSet traitSet, java.util.List<RelNode> inputs)
Creates a copy of this relational expression, perhaps changing traits and inputs.RelDataType
deriveRowType()
RelWriter
explainTerms(RelWriter pw)
Describes the inputs and attributes of this relational expression.java.util.List<RexNode>
getChildExps()
Returns a list of this relational expression's child expressions.java.util.Map<java.lang.Integer,int[]>
getCopyJoinFieldRefCountsMap()
java.util.List<RelNode>
getInputs()
Returns an array of this relational expression's inputs.com.google.common.collect.ImmutableMap<java.lang.Integer,ImmutableIntList>
getJoinFieldRefCountsMap()
RexNode
getJoinFilter()
java.util.List<JoinRelType>
getJoinTypes()
java.util.List<RexNode>
getOuterJoinConditions()
RexNode
getPostJoinFilter()
java.util.List<ImmutableBitSet>
getProjFields()
boolean
isFullOuterJoin()
void
replaceInput(int ordinalInParent, RelNode p)
Replaces theordinalInParent
th input.-
Methods inherited from class org.apache.calcite.rel.AbstractRelNode
accept, childrenAccept, collectVariablesSet, collectVariablesUsed, computeDigest, computeSelfCost, computeSelfCost, estimateRowCount, explain, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getQuery, getRelTypeName, getRows, getRowType, getTable, getTraitSet, getVariablesSet, getVariablesStopped, isDistinct, isKey, isValid, isValid, metadata, onRegister, recomputeDigest, register, sole, toString
-
-
-
-
Field Detail
-
inputs
private final java.util.List<RelNode> inputs
-
joinFilter
private final RexNode joinFilter
-
rowType
private final RelDataType rowType
-
isFullOuterJoin
private final boolean isFullOuterJoin
-
outerJoinConditions
private final java.util.List<RexNode> outerJoinConditions
-
joinTypes
private final com.google.common.collect.ImmutableList<JoinRelType> joinTypes
-
projFields
private final java.util.List<ImmutableBitSet> projFields
-
joinFieldRefCountsMap
public final com.google.common.collect.ImmutableMap<java.lang.Integer,ImmutableIntList> joinFieldRefCountsMap
-
postJoinFilter
private final RexNode postJoinFilter
-
-
Constructor Detail
-
MultiJoin
public MultiJoin(RelOptCluster cluster, java.util.List<RelNode> inputs, RexNode joinFilter, RelDataType rowType, boolean isFullOuterJoin, java.util.List<RexNode> outerJoinConditions, java.util.List<JoinRelType> joinTypes, java.util.List<ImmutableBitSet> projFields, com.google.common.collect.ImmutableMap<java.lang.Integer,ImmutableIntList> joinFieldRefCountsMap, RexNode postJoinFilter)
Constructs a MultiJoin.- Parameters:
cluster
- cluster that join belongs toinputs
- inputs into this multi-joinjoinFilter
- join filter applicable to this join noderowType
- row type of the join result of this nodeisFullOuterJoin
- true if the join is a full outer joinouterJoinConditions
- outer join condition associated with each join input, if the input is null-generating in a left or right outer join; null otherwisejoinTypes
- the join type corresponding to each input; if an input is null-generating in a left or right outer join, the entry indicates the type of outer join; otherwise, the entry is set to INNERprojFields
- fields that will be projected from each input; if null, projection information is not available yet so it's assumed that all fields from the input are projectedjoinFieldRefCountsMap
- counters of the number of times each field is referenced in join conditions, indexed by the input #postJoinFilter
- filter to be applied after the joins are
-
-
Method Detail
-
replaceInput
public void replaceInput(int ordinalInParent, RelNode p)
Description copied from interface:RelNode
Replaces theordinalInParent
th input. You must override this method if you overrideRelNode.getInputs()
.- Specified by:
replaceInput
in interfaceRelNode
- Overrides:
replaceInput
in classAbstractRelNode
- Parameters:
ordinalInParent
- Position of the child input, 0 is the firstp
- New node that should be put at positionordinalInParent
-
copy
public RelNode copy(RelTraitSet traitSet, java.util.List<RelNode> inputs)
Description copied from interface:RelNode
Creates a copy of this relational expression, perhaps changing traits and inputs.Sub-classes with other important attributes are encouraged to create variants of this method with more parameters.
- Specified by:
copy
in interfaceRelNode
- Overrides:
copy
in classAbstractRelNode
- Parameters:
traitSet
- Trait setinputs
- Inputs- Returns:
- Copy of this relational expression, substituting traits and inputs
-
cloneJoinFieldRefCountsMap
private java.util.Map<java.lang.Integer,int[]> cloneJoinFieldRefCountsMap()
Returns a deep copy ofjoinFieldRefCountsMap
.
-
explainTerms
public RelWriter explainTerms(RelWriter pw)
Description copied from class:AbstractRelNode
Describes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms
, then call theRelWriterImpl.input(String, RelNode)
andRelWriterImpl.item(String, Object)
methods for each input and attribute.- Overrides:
explainTerms
in classAbstractRelNode
- Parameters:
pw
- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-
deriveRowType
public RelDataType deriveRowType()
- Overrides:
deriveRowType
in classAbstractRelNode
-
getInputs
public java.util.List<RelNode> getInputs()
Description copied from interface:RelNode
Returns an array of this relational expression's inputs. If there are no inputs, returns an empty list, notnull
.- Specified by:
getInputs
in interfaceRelNode
- Specified by:
getInputs
in interfaceRelOptNode
- Overrides:
getInputs
in classAbstractRelNode
- Returns:
- Array of this relational expression's inputs
-
getChildExps
public java.util.List<RexNode> getChildExps()
Description copied from interface:RelNode
Returns a list of this relational expression's child expressions. (These are scalar expressions, and so do not include the relational inputs that are returned byRelNode.getInputs()
.The caller should treat the list as unmodifiable; typical implementations will return an immutable list. If there are no child expressions, returns an empty list, not
null
.- Specified by:
getChildExps
in interfaceRelNode
- Overrides:
getChildExps
in classAbstractRelNode
- Returns:
- List of this relational expression's child expressions
- See Also:
RelNode.accept(org.apache.calcite.rex.RexShuttle)
-
accept
public RelNode accept(RexShuttle shuttle)
Description copied from interface:RelNode
Accepts a visit from a shuttle. If the shuttle updates expression, then a copy of the relation should be created.- Specified by:
accept
in interfaceRelNode
- Overrides:
accept
in classAbstractRelNode
- Parameters:
shuttle
- Shuttle- Returns:
- A copy of this node incorporating changes made by the shuttle to this node's children
-
getJoinFilter
public RexNode getJoinFilter()
- Returns:
- join filters associated with this MultiJoin
-
isFullOuterJoin
public boolean isFullOuterJoin()
- Returns:
- true if the MultiJoin corresponds to a full outer join.
-
getOuterJoinConditions
public java.util.List<RexNode> getOuterJoinConditions()
- Returns:
- outer join conditions for null-generating inputs
-
getJoinTypes
public java.util.List<JoinRelType> getJoinTypes()
- Returns:
- join types of each input
-
getProjFields
public java.util.List<ImmutableBitSet> getProjFields()
- Returns:
- bitmaps representing the fields projected from each input; if an entry is null, all fields are projected
-
getJoinFieldRefCountsMap
public com.google.common.collect.ImmutableMap<java.lang.Integer,ImmutableIntList> getJoinFieldRefCountsMap()
- Returns:
- the map of reference counts for each input, representing the fields accessed in join conditions
-
getCopyJoinFieldRefCountsMap
public java.util.Map<java.lang.Integer,int[]> getCopyJoinFieldRefCountsMap()
- Returns:
- a copy of the map of reference counts for each input, representing the fields accessed in join conditions
-
getPostJoinFilter
public RexNode getPostJoinFilter()
- Returns:
- post-join filter associated with this MultiJoin
-
containsOuter
boolean containsOuter()
-
-