use of io.mycat.calcite.MycatRel in project Mycat2 by MyCATApache.
the class QueryView method explain.
@Override
public ExplainWriter explain(ExplainWriter writer) {
writer.name("Query").into();
List<RelNode> inputs = getInputs();
for (RelNode input : inputs) {
MycatRel rel = (MycatRel) input;
rel.explain(writer);
}
return writer.ret();
}
use of io.mycat.calcite.MycatRel in project Mycat2 by MyCATApache.
the class PlanImpl method getMetaData.
@Override
public MycatRowMetaData getMetaData() {
MycatRel mycatRel = (MycatRel) relNode;
List<RelDataTypeField> fieldList = mycatRel.getRowType().getFieldList();
return new CalciteRowMetaData(fieldList, aliasList);
}
use of io.mycat.calcite.MycatRel in project Mycat2 by MyCATApache.
the class MemPlanCache method add.
public synchronized PlanResultSet add(boolean fix, DrdsSql drdsSql) {
Long baselineId = null;
Baseline baseline = this.getBaseline(drdsSql);
DrdsSqlCompiler drdsSqlCompiler = MetaClusterCurrent.wrapper(DrdsSqlCompiler.class);
OptimizationContext optimizationContext = new OptimizationContext();
MycatRel mycatRel = drdsSqlCompiler.dispatch(optimizationContext, drdsSql);
RelJsonWriter relJsonWriter = new RelJsonWriter();
mycatRel.explain(relJsonWriter);
long hash = planIds.nextPlanId();
BaselinePlan newBaselinePlan = new BaselinePlan(drdsSql.getParameterizedSQL(), relJsonWriter.asString(), hash, baselineId = baseline.getBaselineId(), null);
getCodeExecuterContext(baseline, newBaselinePlan, optimizationContext, mycatRel);
return saveBaselinePlan(fix, false, baseline, newBaselinePlan);
}
use of io.mycat.calcite.MycatRel in project Mycat2 by MyCATApache.
the class MemPlanCache method getCodeExecuterContext.
@SneakyThrows
public CodeExecuterContext getCodeExecuterContext(Baseline baseline, BaselinePlan plan) {
boolean forUpdate = DrdsSql.isForUpdate(plan.getSql());
Object attach = plan.attach;
if (attach != null) {
return (CodeExecuterContext) attach;
}
String rel = plan.getRel();
synchronized (plan) {
try {
ImmutableMap<RexNode, RexNode> constantMap = getConstantMap(baseline);
RelJsonReader relJsonReader = new RelJsonReader(DrdsSqlCompiler.newCluster(), MetaClusterCurrent.wrapper(DrdsSqlCompiler.class).newCalciteCatalogReader(), null);
MycatRel mycatRel = (MycatRel) relJsonReader.read(rel);
CodeExecuterContext codeExecuterContext = DrdsExecutorCompiler.getCodeExecuterContext(constantMap, mycatRel, forUpdate);
plan.setAttach(codeExecuterContext);
} catch (Throwable throwable) {
log.error("", throwable);
}
}
return (CodeExecuterContext) plan.attach;
}
use of io.mycat.calcite.MycatRel in project Mycat2 by MyCATApache.
the class MycatTableSpool method explain.
@Override
public ExplainWriter explain(ExplainWriter writer) {
writer.name("MycatTableSpool").into();
for (RelNode relNode : getInputs()) {
MycatRel relNode1 = (MycatRel) relNode;
relNode1.explain(writer);
}
return writer.ret();
}
Aggregations