use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class FilterPusher method replaceFunctionArg.
/**
* replaceFunctionArg
*
* @param f
* @param sels1
* @param sels2
* @return if f also contains selectable which is not sels1 ,return null
*/
public static ItemFunc replaceFunctionArg(ItemFunc f, List<Item> sels1, List<Item> sels2) {
ItemFunc ret = (ItemFunc) f.cloneStruct();
for (int index = 0; index < ret.getArgCount(); index++) {
Item arg = ret.arguments().get(index);
if (arg instanceof ItemFunc) {
ItemFunc newfArg = replaceFunctionArg((ItemFunc) arg, sels1, sels2);
if (newfArg == null)
return null;
else
ret.arguments().set(index, newfArg);
} else if (arg instanceof ItemField) {
int tmpIndex = sels1.indexOf(arg);
if (tmpIndex < 0) {
return null;
} else {
Item newArg = sels2.get(tmpIndex);
ret.arguments().set(index, newArg.cloneStruct());
}
} else {
// do nothing;
}
}
ret.setPushDownName(null);
PlanUtil.refreshReferTables(ret);
return ret;
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class MergeHavingFilter method optimize.
/**
* merge having to where if it can be merged
*
* @param qtn
*/
public static void optimize(PlanNode qtn) {
if (qtn.getHavingFilter() != null) {
List<Item> subFilters = FilterUtils.splitFilter(qtn.getHavingFilter());
List<Item> canMergeSubs = new ArrayList<>();
for (Item subFilter : subFilters) {
if (!subFilter.isWithSumFunc()) {
canMergeSubs.add(subFilter);
}
}
subFilters.removeAll(canMergeSubs);
qtn.having(FilterUtils.and(subFilters));
qtn.setWhereFilter(FilterUtils.and(qtn.getWhereFilter(), FilterUtils.and(canMergeSubs)));
}
for (PlanNode child : qtn.getChildren()) optimize(child);
}
use of com.actiontech.dble.plan.common.item.Item 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.Item in project dble by actiontech.
the class PlanNode method setUpGroupBy.
private void setUpGroupBy() {
nameContext.setFindInSelect(true);
nameContext.setSelectFirst(false);
for (Order order : groups) {
Item item = order.getItem();
if (item.type() == Item.ItemType.INT_ITEM) {
int index = item.valInt().intValue();
if (index >= 1 && index <= getColumnsSelected().size())
order.setItem(getColumnsSelected().get(index - 1));
else
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "Unknown column '" + index + "' in group statement");
} else {
order.setItem(setUpItem(item));
}
}
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class PlanNode method setUpOrderBy.
private void setUpOrderBy() {
nameContext.setFindInSelect(true);
nameContext.setSelectFirst(true);
for (Order order : orderBys) {
Item item = order.getItem();
if (item.type() == Item.ItemType.INT_ITEM) {
int index = item.valInt().intValue();
if (index >= 1 && index <= getColumnsSelected().size())
order.setItem(getColumnsSelected().get(index - 1));
else
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "Unknown column '" + index + "' in order statement");
} else {
order.setItem(setUpItem(item));
}
}
}
Aggregations