use of com.actiontech.dble.backend.mysql.nio.handler.builder.sqlvisitor.PushDownVisitor in project dble by actiontech.
the class JoinNodeHandlerBuilder method mergeBuild.
@Override
public void mergeBuild() {
try {
this.needWhereHandler = false;
this.canPushDown = !node.existUnPushDownGroup();
PushDownVisitor pdVisitor = new PushDownVisitor(node, true);
MergeBuilder mergeBuilder = new MergeBuilder(session, node, needCommon, pdVisitor);
String sql = null;
if (node.getAst() != null && node.getParent() == null) {
// it's root
pdVisitor.visit();
sql = pdVisitor.getSql().toString();
}
RouteResultsetNode[] rrssArray;
// maybe some node is view
if (sql == null) {
rrssArray = mergeBuilder.construct().getNodes();
} else {
rrssArray = mergeBuilder.constructByStatement(sql, node.getAst()).getNodes();
}
this.needCommon = mergeBuilder.getNeedCommonFlag();
buildMergeHandler(node, rrssArray);
} catch (Exception e) {
throw new MySQLOutPutException(ErrorCode.ER_QUERYHANDLER, "", "join node mergebuild exception!", e);
}
}
use of com.actiontech.dble.backend.mysql.nio.handler.builder.sqlvisitor.PushDownVisitor in project dble by actiontech.
the class NoNameNodeHandlerBuilder method buildOwn.
@Override
public void buildOwn() {
PushDownVisitor visitor = new PushDownVisitor(node, true);
visitor.visit();
this.canPushDown = true;
String sql = visitor.getSql().toString();
String schema = session.getSource().getSchema();
SchemaConfig schemaConfig = schemaConfigMap.get(schema);
RouteResultsetNode[] rrss = getTableSources(schemaConfig.getAllDataNodes(), sql);
hBuilder.checkRRSs(rrss);
MultiNodeMergeHandler mh = new MultiNodeMergeHandler(getSequenceId(), rrss, session.getSource().isAutocommit() && !session.getSource().isTxStart(), session, null);
addHandler(mh);
}
use of com.actiontech.dble.backend.mysql.nio.handler.builder.sqlvisitor.PushDownVisitor in project dble by actiontech.
the class TableNodeHandlerBuilder method nestLoopBuild.
@Override
protected void nestLoopBuild() {
try {
List<Item> filters = node.getNestLoopFilters();
PushDownVisitor pdVisitor = new PushDownVisitor(node, true);
if (filters == null || filters.isEmpty())
throw new MySQLOutPutException(ErrorCode.ER_QUERYHANDLER, "", "unexpected exception!");
List<RouteResultsetNode> rrssList = new ArrayList<>();
MergeBuilder mergeBuilder = new MergeBuilder(session, node, needCommon, pdVisitor);
if (tableConfig == null || tableConfig.getTableType() == TableTypeEnum.TYPE_GLOBAL_TABLE) {
for (Item filter : filters) {
node.setWhereFilter(filter);
RouteResultsetNode[] rrssArray = mergeBuilder.construct().getNodes();
rrssList.addAll(Arrays.asList(rrssArray));
}
if (filters.size() == 1) {
this.needCommon = false;
}
} else {
boolean tryGlobal = filters.size() == 1;
for (Item filter : filters) {
node.setWhereFilter(filter);
pdVisitor.visit();
RouteResultsetNode[] rrssArray = mergeBuilder.construct().getNodes();
rrssList.addAll(Arrays.asList(rrssArray));
}
if (tryGlobal) {
this.needCommon = mergeBuilder.getNeedCommonFlag();
}
}
RouteResultsetNode[] rrssArray = new RouteResultsetNode[rrssList.size()];
rrssArray = rrssList.toArray(rrssArray);
buildMergeHandler(node, rrssArray);
} catch (Exception e) {
throw new MySQLOutPutException(ErrorCode.ER_QUERYHANDLER, "", "", e);
}
}
use of com.actiontech.dble.backend.mysql.nio.handler.builder.sqlvisitor.PushDownVisitor in project dble by actiontech.
the class TableNodeHandlerBuilder method buildOwn.
@Override
public void buildOwn() {
try {
PushDownVisitor pdVisitor = new PushDownVisitor(node, true);
MergeBuilder mergeBuilder = new MergeBuilder(session, node, needCommon, pdVisitor);
String sql = null;
if (node.getAst() != null && node.getParent() == null) {
// it's root
pdVisitor.visit();
sql = pdVisitor.getSql().toString();
}
RouteResultsetNode[] rrssArray;
// maybe some node is view
if (sql == null) {
rrssArray = mergeBuilder.construct().getNodes();
} else {
rrssArray = mergeBuilder.constructByStatement(sql, node.getAst()).getNodes();
}
this.needCommon = mergeBuilder.getNeedCommonFlag();
buildMergeHandler(node, rrssArray);
} catch (Exception e) {
throw new MySQLOutPutException(ErrorCode.ER_QUERYHANDLER, "", "table node buildOwn exception!", e);
}
}
Aggregations