use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.
the class NonBlockingSession method executeMultiSelect.
private void executeMultiSelect(RouteResultset rrs) {
SQLSelectStatement ast = (SQLSelectStatement) rrs.getSqlStatement();
MySQLPlanNodeVisitor visitor = new MySQLPlanNodeVisitor(this.getSource().getSchema(), this.getSource().getCharset().getResultsIndex(), DbleServer.getInstance().getTmManager(), false);
visitor.visit(ast);
PlanNode node = visitor.getTableNode();
if (node.isCorrelatedSubQuery()) {
throw new MySQLOutPutException(ErrorCode.ER_UNKNOWN_ERROR, "", "Correlated Sub Queries is not supported ");
}
node.setSql(rrs.getStatement());
node.setUpFields();
PlanUtil.checkTablesPrivilege(source, node, ast);
node = MyOptimizer.optimize(node);
if (PlanUtil.containsSubQuery(node)) {
final PlanNode finalNode = node;
DbleServer.getInstance().getComplexQueryExecutor().execute(new Runnable() {
// sub Query build will be blocked, so use ComplexQueryExecutor
@Override
public void run() {
executeMultiResultSet(finalNode);
}
});
} else {
if (!visitor.isContainSchema()) {
node.setAst(ast);
}
executeMultiResultSet(node);
}
}
use of com.actiontech.dble.plan.node.PlanNode in project dble by actiontech.
the class ERJoinChooser method joinWithGlobal.
private PlanNode joinWithGlobal(PlanNode t, List<PlanNode> globalList) {
PlanNode newT = t;
while (globalList.size() > 0) {
boolean foundJoin = false;
for (int i = 0; i < globalList.size(); i++) {
PlanNode global = globalList.get(i);
// try join
JoinNode joinNode = new JoinNode(newT, global);
List<ItemFuncEqual> jnFilter = makeJoinFilter(joinNode, newT, global, false);
// @if no join column, then the other is cross join
if (jnFilter.size() > 0 || selLists.size() == 0) {
// join
replaceSelListReferedTn(newT, global, joinNode);
foundJoin = true;
joinNode.setJoinFilter(jnFilter);
globalList.remove(i);
newT = joinNode;
break;
}
}
if (// no join can do from t and globals
!foundJoin)
break;
}
return newT;
}
use of com.actiontech.dble.plan.node.PlanNode 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.PlanNode in project dble by actiontech.
the class ERJoinChooser method initJoinKeyInfo.
/**
* init sellis's JoinKeyInfo,JoinKeyInfo only has key selList when just build ,
* set values for them
*/
private void initJoinKeyInfo() {
for (List<JoinKeyInfo> selList : selLists) {
for (JoinKeyInfo jki : selList) {
for (PlanNode tn : joinUnits) {
Item tmpSel = nodeHasSelectable(tn, jki.key);
if (tmpSel != null) {
jki.tn = tn;
jki.cm = getERKey(tn, tmpSel);
break;
}
}
}
}
}
use of com.actiontech.dble.plan.node.PlanNode 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);
}
}
}
Aggregations