use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class JoinERProcessor method optimize.
public static PlanNode optimize(PlanNode qtn) {
if (qtn instanceof JoinNode) {
qtn = new ERJoinChooser((JoinNode) qtn).optimize();
} else {
for (int i = 0; i < qtn.getChildren().size(); i++) {
PlanNode sub = qtn.getChildren().get(i);
qtn.getChildren().set(i, optimize(sub));
}
}
return qtn;
}
use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class JoinStrategyProcessor method optimize.
public static PlanNode optimize(PlanNode qtn) {
if (PlanUtil.isGlobalOrER(qtn))
return qtn;
if (qtn.type() == PlanNode.PlanNodeType.JOIN) {
JoinNode jn = (JoinNode) qtn;
if (jn.getLeftNode().type() == PlanNode.PlanNodeType.TABLE && jn.getRightNode().type() == PlanNode.PlanNodeType.TABLE) {
JoinStrategyChooser chooser = new JoinStrategyChooser((JoinNode) qtn);
chooser.tryNestLoop();
return qtn;
}
}
for (PlanNode child : qtn.getChildren()) optimize(child);
return qtn;
}
use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class ERJoinChooser method makeJoinNode.
/**
* just makeJoinNode according with wishes
*
* @param units
* @return
*/
private PlanNode makeJoinNode(List<PlanNode> units) {
PlanNode ret = units.get(0);
for (int i = 1; i < units.size(); i++) {
PlanNode tni = units.get(i);
JoinNode joinNode = new JoinNode(ret, tni);
List<ItemFuncEqual> joinFilter = makeJoinFilter(joinNode, ret, tni, true);
joinNode.setJoinFilter(joinFilter);
ret = joinNode;
}
return ret;
}
use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class ERJoinChooser method getLeftOutJoinChildER.
private ERTable getLeftOutJoinChildER(JoinNode joinNode, PlanNode child, Item onItem) {
if (PlanUtil.existAggregate(child))
return null;
else if (!PlanUtil.isERNode(child) && child.type() != PlanNode.PlanNodeType.TABLE)
return null;
if (onItem == null || !onItem.type().equals(Item.ItemType.FIELD_ITEM))
return null;
Pair<TableNode, ItemField> joinColumnInfo = PlanUtil.findColumnInTableLeaf((ItemField) onItem, joinNode);
if (joinColumnInfo == null)
return null;
TableNode tn = joinColumnInfo.getKey();
ItemField col = joinColumnInfo.getValue();
ERTable erKey = new ERTable(tn.getSchema(), tn.getPureName(), col.getItemName());
if (child.type() == PlanNode.PlanNodeType.TABLE) {
return erKey;
} else {
// joinnode
List<ERTable> erKeys = ((JoinNode) child).getERkeys();
for (ERTable cerKey : erKeys) {
if (isErRelation(erKey, cerKey))
return erKey;
}
return null;
}
}
use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class ERJoinChooser method getERKey.
private ERTable getERKey(PlanNode tn, Item c) {
if (!(c instanceof ItemField))
return null;
if (tn.type() != PlanNode.PlanNodeType.TABLE && !PlanUtil.isERNode(tn)) {
return null;
}
Pair<TableNode, ItemField> pair = PlanUtil.findColumnInTableLeaf((ItemField) c, tn);
if (pair == null)
return null;
TableNode tableNode = pair.getKey();
ItemField col = pair.getValue();
ERTable cm = new ERTable(tableNode.getSchema(), tableNode.getPureName(), col.getItemName());
if (tn.type() == PlanNode.PlanNodeType.TABLE) {
return cm;
} else {
List<ERTable> erList = ((JoinNode) tn).getERkeys();
for (ERTable cerKey : erList) {
if (isErRelation(cm, cerKey))
return cm;
}
return null;
}
}
Aggregations