use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class ERJoinChooser method makeERJoin.
// generate er join node ,remove jk of rKeyIndexs in selListIndex,replace the other selList's tn
private JoinNode makeERJoin(List<JoinKeyInfo> erKeys) {
PlanNode t0 = erKeys.get(0).tn;
PlanNode t1 = erKeys.get(1).tn;
JoinNode joinNode = new JoinNode(t0, t1);
List<ItemFuncEqual> joinFilter = makeJoinFilter(joinNode, t0, t1, true);
joinNode.setJoinFilter(joinFilter);
for (int index = 2; index < erKeys.size(); index++) {
t0 = joinNode;
t1 = erKeys.get(index).tn;
joinNode = new JoinNode(t0, t1);
joinFilter = makeJoinFilter(joinNode, t0, t1, true);
joinNode.setJoinFilter(joinFilter);
}
for (JoinKeyInfo jki : erKeys) {
// remove join units
for (int index = joinUnits.size() - 1; index > -1; index--) {
PlanNode tn = joinUnits.get(index);
if (tn == jki.tn)
joinUnits.remove(index);
}
}
return joinNode;
}
use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class ERJoinChooser method visitJoinOns.
/**
* visitJoinOns
*
* @param joinNode
*/
private void visitJoinOns(JoinNode joinNode) {
for (PlanNode unit : joinUnits) {
// is unit
if (unit == joinNode) {
return;
}
}
for (ItemFuncEqual filter : joinNode.getJoinFilter()) {
addJoinFilter(filter);
}
for (PlanNode child : joinNode.getChildren()) {
if ((!isUnit(child)) && (child.type().equals(PlanNode.PlanNodeType.JOIN))) {
// a join b on a.id=b.id and a.id+b.id=10 join c on
// a.id=c.id,push up a.id+b.id
JoinNode jnChild = (JoinNode) child;
if (jnChild.getOtherJoinOnFilter() != null)
otherJoinOns.add(jnChild.getOtherJoinOnFilter());
visitJoinOns((JoinNode) child);
}
}
}
use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class FilterJoinColumnPusher method pushJoinNodeFilter.
private static PlanNode pushJoinNodeFilter(PlanNode qtn, List<Item> dnfNodeToPush) {
JoinNode jn = (JoinNode) qtn;
PlanUtil.findJoinKeysAndRemoveIt(dnfNodeToPush, jn);
if (dnfNodeToPush.isEmpty()) {
return qtn;
}
// filters which can not push down
List<Item> dnfNodeToCurrent = new LinkedList<>();
List<Item> dnfNodetoPushToLeft = new LinkedList<>();
List<Item> dnfNodetoPushToRight = new LinkedList<>();
for (Item filter : dnfNodeToPush) {
if (PlanUtil.canPush(filter, jn.getLeftNode(), jn)) {
dnfNodetoPushToLeft.add(filter);
} else if (PlanUtil.canPush(filter, jn.getRightNode(), jn)) {
dnfNodetoPushToRight.add(filter);
} else {
dnfNodeToCurrent.add(filter);
}
}
// if can not push down,merge to current where
Item node = FilterUtils.and(dnfNodeToCurrent);
if (node != null) {
qtn.query(FilterUtils.and(qtn.getWhereFilter(), node));
}
if (jn.isInnerJoin()) {
refreshPdFilters(jn, dnfNodetoPushToLeft);
refreshPdFilters(jn, dnfNodetoPushToRight);
pushFilter(jn.getLeftNode(), dnfNodetoPushToLeft);
pushFilter(((JoinNode) qtn).getRightNode(), dnfNodetoPushToRight);
} else if (jn.isLeftOuterJoin()) {
refreshPdFilters(jn, dnfNodetoPushToLeft);
pushFilter(jn.getLeftNode(), dnfNodetoPushToLeft);
if (!dnfNodeToPush.isEmpty()) {
// the parent's filter,don't push down
jn.query(FilterUtils.and(dnfNodetoPushToRight));
}
} else if (jn.isRightOuterJoin()) {
refreshPdFilters(jn, dnfNodetoPushToRight);
pushFilter(((JoinNode) qtn).getRightNode(), dnfNodetoPushToRight);
if (!dnfNodeToPush.isEmpty()) {
// the parent's filter,don't push down
jn.query(FilterUtils.and(dnfNodetoPushToLeft));
}
} else {
if (!dnfNodeToPush.isEmpty()) {
jn.query(FilterUtils.and(dnfNodeToPush));
}
}
return qtn;
}
use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class FilterPreProcessor method preProcess.
private static PlanNode preProcess(PlanNode qtn) {
qtn.having(processFilter(qtn.getHavingFilter()));
qtn.query(processFilter(qtn.getWhereFilter()));
if (qtn instanceof JoinNode) {
JoinNode jn = (JoinNode) qtn;
for (int i = 0; i < ((JoinNode) qtn).getJoinFilter().size(); i++) {
processFilter(jn.getJoinFilter().get(i));
}
jn.setOtherJoinOnFilter(processFilter(jn.getOtherJoinOnFilter()));
}
for (PlanNode child : qtn.getChildren()) {
preProcess(child);
}
return qtn;
}
use of com.actiontech.dble.plan.node.JoinNode in project dble by actiontech.
the class FilterPusher method mergeJoinOnFilter.
/**
* merge inner joi's otheron to where if we can
*
* @param qtn
* @return
*/
private static void mergeJoinOnFilter(PlanNode qtn) {
if (PlanUtil.isGlobalOrER(qtn))
return;
if (qtn.type().equals(PlanNodeType.JOIN) && ((JoinNode) qtn).isInnerJoin()) {
JoinNode jn = (JoinNode) qtn;
Item otherJoinOn = jn.getOtherJoinOnFilter();
jn.setOtherJoinOnFilter(null);
jn.query(FilterUtils.and(otherJoinOn, jn.getWhereFilter()));
}
for (PlanNode child : qtn.getChildren()) {
mergeJoinOnFilter(child);
}
}
Aggregations