use of io.mycat.TableHandler in project Mycat2 by MyCATApache.
the class AnalyzeHanlder method onExecute.
@Override
protected Future<Void> onExecute(SQLRequest<MySqlAnalyzeStatement> request, MycatDataContext dataContext, Response response) {
MySqlAnalyzeStatement ast = request.getAst();
List<SQLExprTableSource> tableSources = Optional.ofNullable(ast.getTableSources()).orElse(Collections.emptyList());
if (tableSources.isEmpty()) {
return response.sendError(new MycatException("need tables"));
} else {
ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
resultSetBuilder.addColumnInfo("Table", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Op", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Msg_type", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Msg_Text", JDBCType.VARCHAR);
for (SQLExprTableSource tableSource : tableSources) {
String schemaName = SQLUtils.normalize(tableSource.getSchema());
String tableName = SQLUtils.normalize(tableSource.getTableName());
resultSetBuilder.addObjectRowPayload(Arrays.asList(schemaName + "." + tableName, "analyze", "status", "OK"));
MetadataManager metadataManager = MetaClusterCurrent.wrapper(MetadataManager.class);
TableHandler tableHandler = metadataManager.getTable(schemaName, tableName);
if (tableHandler == null) {
return response.sendError(new MycatException(tableSource + "不存在"));
}
StatisticCenter statisticCenter = MetaClusterCurrent.wrapper(StatisticCenter.class);
statisticCenter.fetchTableRowCount(tableHandler);
}
return response.sendResultSet(resultSetBuilder.build());
}
}
use of io.mycat.TableHandler in project Mycat2 by MyCATApache.
the class MycatRouteUpdateCore method explain.
public ExplainWriter explain(ExplainWriter writer) {
TableHandler table = MetaClusterCurrent.wrapper(MetadataManager.class).getTable(schemaName, tableName);
writer.name("MycatUpdateRel").into();
writer.item("sql", sqlStatement);
writer.item("dataNodes", getDataNodes(table));
return writer.ret();
}
use of io.mycat.TableHandler in project Mycat2 by MyCATApache.
the class MycatRouteInsertCore method logicTable.
public ShardingTableHandler logicTable() {
MetadataManager metadataManager = MetaClusterCurrent.wrapper(MetadataManager.class);
TableHandler tableHandler = metadataManager.getTable(schemaName, tableName);
return (ShardingTableHandler) tableHandler;
}
Aggregations