use of com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual 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.common.item.function.operator.cmpfunc.ItemFuncEqual in project dble by actiontech.
the class FilterJoinColumnPusher method isPossibleERJoinColumnFilter.
/**
* is ER Filter: 1.Filter must be equal(=) 2.Filter must be Column = Column
* 3.Filter's key and value must be belong different table ex:a.id=b.id true a.id=b.id+1 false
*/
private static boolean isPossibleERJoinColumnFilter(PlanNode node, Item ifilter) {
if (!(ifilter instanceof ItemFuncEqual))
return false;
ItemFuncEqual filter = (ItemFuncEqual) ifilter;
Item column = filter.arguments().get(0);
Item value = filter.arguments().get(1);
if (column != null && column instanceof ItemField && value != null && value instanceof ItemField) {
Pair<TableNode, ItemField> foundColumn = PlanUtil.findColumnInTableLeaf((ItemField) column, node);
Pair<TableNode, ItemField> foundValue = PlanUtil.findColumnInTableLeaf((ItemField) value, node);
if (foundColumn != null && foundValue != null) {
String columnTable = foundColumn.getValue().getTableName();
String valueTable = foundValue.getValue().getTableName();
// the table must be different
return !StringUtils.equals(columnTable, valueTable);
} else {
return false;
}
} else {
return false;
}
}
use of com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual in project dble by actiontech.
the class MySQLPlanNodeVisitor method addJoinOnColumns.
private void addJoinOnColumns(Item ifilter, JoinNode joinNode) {
if (ifilter instanceof ItemFuncEqual) {
ItemFuncEqual filter = (ItemFuncEqual) ifilter;
Item column = filter.arguments().get(0);
Item value = filter.arguments().get(1);
if (column != null && column instanceof ItemField && value != null && value instanceof ItemField) {
joinNode.addJoinFilter(filter);
} else {
joinNode.setOtherJoinOnFilter(filter);
}
} else if (ifilter instanceof ItemCondAnd) {
ItemCondAnd ilfand = (ItemCondAnd) ifilter;
List<Item> subFilter = ilfand.arguments();
if (subFilter != null) {
for (Item arg : subFilter) {
Item orgOtherJoin = joinNode.getOtherJoinOnFilter();
addJoinOnColumns(arg, joinNode);
joinNode.setOtherJoinOnFilter(FilterUtils.and(orgOtherJoin, joinNode.getOtherJoinOnFilter()));
}
} else {
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "and has no other columns , " + ifilter);
}
} else {
joinNode.setOtherJoinOnFilter(ifilter);
}
}
use of com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual in project dble by actiontech.
the class JoinNode method copy.
@Override
public JoinNode copy() {
JoinNode newJoinNode = new JoinNode();
this.copySelfTo(newJoinNode);
newJoinNode.setJoinFilter(new ArrayList<ItemFuncEqual>());
for (Item bf : joinFilter) {
newJoinNode.addJoinFilter((ItemFuncEqual) bf.cloneStruct());
}
newJoinNode.setLeftNode(this.getLeftNode().copy());
newJoinNode.setRightNode(this.getRightNode().copy());
newJoinNode.setNeedOptimizeJoinOrder(this.isNeedOptimizeJoinOrder());
newJoinNode.leftOuter = this.leftOuter;
newJoinNode.rightOuter = this.rightOuter;
newJoinNode.isNotIn = this.isNotIn;
newJoinNode.otherJoinOnFilter = this.otherJoinOnFilter == null ? null : this.otherJoinOnFilter.cloneItem();
return newJoinNode;
}
use of com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual in project dble by actiontech.
the class JoinNode method buildJoinKeys.
/**
* setupJoinfilters
*
* @param clearName if true:clear filter's itemname,else keep
*/
private void buildJoinKeys(boolean clearName) {
Iterator<ItemFuncEqual> iterator = joinFilter.iterator();
while (iterator.hasNext()) {
ItemFuncEqual bf = iterator.next();
if (clearName)
bf.setItemName(null);
boolean isJoinKey = PlanUtil.isJoinKey(bf, this);
if (!isJoinKey) {
otherJoinOnFilter = FilterUtils.and(otherJoinOnFilter, bf);
iterator.remove();
}
}
}
Aggregations