use of io.mycat.ExplainDetail in project Mycat2 by MyCATApache.
the class PlanImpl method explain.
public List<String> explain(MycatDataContext dataContext, DrdsSqlWithParams drdsSql, boolean code) {
ArrayList<String> list = new ArrayList<>();
ExplainWriter explainWriter = new ExplainWriter();
switch(this.type) {
case PHYSICAL:
Optional<ExplainDetail> singleViewOptional = ColocatedPlanner.executeQuery(dataContext, this, drdsSql);
if (singleViewOptional.isPresent()) {
ExplainDetail explainDetail = singleViewOptional.get();
list.add("ColocatedPushDown:");
list.add(explainDetail.toString());
}
list.add("\n");
list.add("Plan:");
String s = dumpPlan();
list.addAll(Arrays.asList(s.split("\n")));
List<SpecificSql> map = specificSql(drdsSql, dataContext);
for (SpecificSql specificSql : map) {
list.addAll(Arrays.asList(specificSql.toString().split("\n")));
}
if (code) {
list.add("Code:");
list.addAll(Arrays.asList(getCodeExecuterContext().getCodeContext().getCode().split("\n")));
}
break;
case UPDATE:
{
Collection<VertxExecuter.EachSQL> eachSQLS = VertxUpdateExecuter.explainUpdate(drdsSql, dataContext);
for (VertxExecuter.EachSQL eachSQL : eachSQLS) {
list.add(eachSQL.toString());
}
break;
}
case INSERT:
{
Iterable<VertxExecuter.EachSQL> eachSQLS = (VertxExecuter.explainInsert((SQLInsertStatement) drdsSql.getParameterizedStatement(), drdsSql.getParams()));
for (VertxExecuter.EachSQL eachSQL : eachSQLS) {
list.add(eachSQL.toString());
}
break;
}
default:
throw new IllegalStateException("Unexpected value: " + this.type);
}
for (String s1 : explainWriter.getText().split("\n")) {
list.add(s1);
}
return list.stream().filter(i -> !i.isEmpty()).collect(Collectors.toList());
}
Aggregations