Search in sources :

Example 11 with ItemFuncEqual

use of com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual in project dble by actiontech.

the class JoinNode method genJoinFilter.

private ItemFuncEqual genJoinFilter(String using, String leftJoinNode, String rightJoinNode) {
    ItemField column1 = new ItemField(null, leftJoinNode, using);
    ItemField column2 = new ItemField(null, rightJoinNode, using);
    return new ItemFuncEqual(column1, column2);
}
Also used : ItemFuncEqual(com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual) ItemField(com.actiontech.dble.plan.common.item.ItemField)

Example 12 with ItemFuncEqual

use of com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual 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;
}
Also used : PlanNode(com.actiontech.dble.plan.node.PlanNode) JoinNode(com.actiontech.dble.plan.node.JoinNode) ItemFuncEqual(com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual)

Example 13 with ItemFuncEqual

use of com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual in project dble by actiontech.

the class ERJoinChooser method leftJoinOptimizer.

/* ------------------- left join optimizer start -------------------- */
/**
 * left join's ER is different from inner join's
 * ex:t1,t2 ,if t1 left join t2 on
 * t1.id=t2.id can be pushed
 * < we cna't change left join's structure>
 *
 * @return
 */
private JoinNode leftJoinOptimizer() {
    PlanNode left = jn.getLeftNode();
    PlanNode right = jn.getRightNode();
    if (left.type() == PlanNode.PlanNodeType.JOIN) {
        left = JoinERProcessor.optimize(left);
        jn.setLeftNode(left);
    }
    if (right.type() == PlanNode.PlanNodeType.JOIN) {
        right = JoinERProcessor.optimize(right);
        jn.setRightNode(right);
    }
    for (ItemFuncEqual filter : jn.getJoinFilter()) {
        ERTable leftER = getLeftOutJoinChildER(jn, left, filter.arguments().get(0));
        ERTable rightER = getLeftOutJoinChildER(jn, right, filter.arguments().get(1));
        if (isErRelation(leftER, rightER)) {
            jn.getERkeys().add(leftER);
        }
    }
    return jn;
}
Also used : PlanNode(com.actiontech.dble.plan.node.PlanNode) ItemFuncEqual(com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual) ERTable(com.actiontech.dble.config.model.ERTable)

Example 14 with ItemFuncEqual

use of com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual in project dble by actiontech.

the class ERJoinChooser method makeRestFilter.

/**
 * the origin filter is  join on filter
 * ,now join is changed ,and the filter is not join filter any more ,add it to other join on
 *
 * @return
 */
private Item makeRestFilter() {
    Item filter = null;
    for (List<JoinKeyInfo> selList : selLists) {
        if (selList.size() > 2) {
            Item sel0 = selList.get(0).key;
            for (int index = 1; index < selList.size(); index++) {
                ItemFuncEqual bf = FilterUtils.equal(sel0, selList.get(index).key);
                filter = FilterUtils.and(filter, bf);
            }
        }
    }
    return filter;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) ItemFuncEqual(com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual)

Aggregations

ItemFuncEqual (com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual)14 Item (com.actiontech.dble.plan.common.item.Item)6 PlanNode (com.actiontech.dble.plan.node.PlanNode)6 JoinNode (com.actiontech.dble.plan.node.JoinNode)5 ItemField (com.actiontech.dble.plan.common.item.ItemField)4 ArrayList (java.util.ArrayList)4 Order (com.actiontech.dble.plan.Order)2 MySQLOutPutException (com.actiontech.dble.plan.common.exception.MySQLOutPutException)2 ERTable (com.actiontech.dble.config.model.ERTable)1 ItemCondAnd (com.actiontech.dble.plan.common.item.function.operator.logic.ItemCondAnd)1 QueryNode (com.actiontech.dble.plan.node.QueryNode)1 TableNode (com.actiontech.dble.plan.node.TableNode)1 SQLOrderingSpecification (com.alibaba.druid.sql.ast.SQLOrderingSpecification)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1