use of com.actiontech.dble.backend.mysql.nio.handler.query.DMLResponseHandler in project dble by actiontech.
the class BaseHandlerBuilder method build.
/**
* generate a handler chain
*/
public final void build() {
List<DMLResponseHandler> preHandlers = null;
// is use the nest loop join
boolean isNestLoopJoin = isNestLoopStrategy(node);
if (isNestLoopJoin) {
nestLoopBuild();
} else if (!node.isExistView() && PlanUtil.isGlobal(node) && !node.isSubQuery()) {
// the query can be send to a certain node
noShardBuild();
} else if (canDoAsMerge()) {
// the query can be send to some certain nodes .eg: ER tables, GLOBAL*NORMAL GLOBAL*ER
mergeBuild();
} else {
handleSubQueries();
// need to split to simple query
preHandlers = buildPre();
buildOwn();
}
if (needCommon) {
buildCommon();
}
// view sub alias
String tbAlias = node.getAlias();
String schema = null;
String table = null;
if (node.type() == PlanNodeType.TABLE) {
TableNode tbNode = (TableNode) node;
schema = tbNode.getSchema();
table = tbNode.getTableName();
}
if (node.type() != PlanNodeType.NONAME) {
SendMakeHandler sh = new SendMakeHandler(getSequenceId(), session, node.getColumnsSelected(), schema, table, tbAlias);
addHandler(sh);
}
if (preHandlers != null) {
for (DMLResponseHandler preHandler : preHandlers) {
preHandler.setNextHandler(start);
}
}
}
use of com.actiontech.dble.backend.mysql.nio.handler.query.DMLResponseHandler in project dble by actiontech.
the class QueryNodeHandlerBuilder method buildPre.
@Override
public List<DMLResponseHandler> buildPre() {
List<DMLResponseHandler> pres = new ArrayList<>();
PlanNode subNode = node.getChild();
BaseHandlerBuilder builder = hBuilder.getBuilder(session, subNode, isExplain);
if (builder.getSubQueryBuilderList().size() > 0) {
this.getSubQueryBuilderList().addAll(builder.getSubQueryBuilderList());
}
DMLResponseHandler subHandler = builder.getEndHandler();
pres.add(subHandler);
return pres;
}
use of com.actiontech.dble.backend.mysql.nio.handler.query.DMLResponseHandler in project dble by actiontech.
the class MultiNodeMergeHandler method terminatePreHandler.
/**
* terminatePreHandler
* @param handler handler
*/
private void terminatePreHandler(DMLResponseHandler handler) {
DMLResponseHandler current = handler;
while (current != null) {
if (current == this)
break;
current.terminate();
current = current.getNextHandler();
}
}
use of com.actiontech.dble.backend.mysql.nio.handler.query.DMLResponseHandler in project dble by actiontech.
the class HandlerTool method terminateHandlerTree.
// private static Pattern pat = Pattern.compile("^\'([^\']*?)\'$");
/**
* @param node
*/
public static void terminateHandlerTree(final DMLResponseHandler node) {
try {
if (node == null)
return;
List<DMLResponseHandler> merges = node.getMerges();
for (DMLResponseHandler merge : merges) {
DMLResponseHandler currentHandler = merge;
while (currentHandler != node) {
currentHandler.terminate();
currentHandler = currentHandler.getNextHandler();
}
}
node.terminate();
} catch (Exception e) {
Logger.getLogger(HandlerTool.class).error("terminate node exception:", e);
}
}
use of com.actiontech.dble.backend.mysql.nio.handler.query.DMLResponseHandler in project dble by actiontech.
the class ExplainHandler method getAllNodesFromLeaf.
private static String getAllNodesFromLeaf(DMLResponseHandler handler, Map<String, RefHandlerInfo> refMap, Map<DMLResponseHandler, RefHandlerInfo> handlerMap, Map<String, Integer> nameMap) {
DMLResponseHandler nextHandler = skipSendMake(handler.getNextHandler());
String rootName = null;
while (nextHandler != null) {
RefHandlerInfo child = handlerMap.get(handler);
String childName = child.name;
String handlerType = getTypeName(nextHandler);
if (!handlerMap.containsKey(nextHandler)) {
String handlerName = genHandlerName(handlerType, nameMap);
RefHandlerInfo handlerInfo = new RefHandlerInfo(handlerName, handlerType);
handlerMap.put(nextHandler, handlerInfo);
refMap.put(handlerName, handlerInfo);
handlerInfo.addChild(childName);
rootName = handlerName;
} else {
handlerMap.get(nextHandler).addChild(childName);
}
if (handler instanceof TempTableHandler) {
TempTableHandler tmp = (TempTableHandler) handler;
DMLResponseHandler endHandler = tmp.getCreatedHandler();
endHandler.setNextHandler(nextHandler);
buildHandlerTree(endHandler, refMap, handlerMap, nameMap, Collections.singleton(childName + "'s RESULTS"));
}
handler = nextHandler;
nextHandler = skipSendMake(nextHandler.getNextHandler());
}
return rootName;
}
Aggregations