use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class OdpsSchemaStatVisitor method visit.
@Override
public boolean visit(OdpsInsert x) {
setMode(x, TableStat.Mode.Insert);
setAliasMap();
SQLExprTableSource tableSource = x.getTableSource();
SQLExpr tableName = tableSource.getExpr();
if (tableName instanceof SQLName) {
String ident = ((SQLName) tableName).toString();
setCurrentTable(ident);
TableStat stat = getTableStat(ident);
stat.incrementInsertCount();
Map<String, String> aliasMap = getAliasMap();
putAliasMap(aliasMap, tableSource.getAlias(), ident);
putAliasMap(aliasMap, ident, ident);
}
for (SQLAssignItem partition : x.getPartitions()) {
partition.accept(this);
}
accept(x.getQuery());
return false;
}
use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class MySqlSchemaStatVisitor method visit.
// DUAL
public boolean visit(MySqlDeleteStatement x) {
setAliasMap();
setMode(x, Mode.Delete);
accept(x.getFrom());
accept(x.getUsing());
x.getTableSource().accept(this);
if (x.getTableSource() instanceof SQLExprTableSource) {
SQLName tableName = (SQLName) ((SQLExprTableSource) x.getTableSource()).getExpr();
String ident = tableName.toString();
setCurrentTable(x, ident);
TableStat stat = this.getTableStat(ident);
stat.incrementDeleteCount();
}
accept(x.getWhere());
accept(x.getOrderBy());
accept(x.getLimit());
return false;
}
use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class OracleSchemaStatVisitor method visit.
public boolean visit(OracleSelectTableReference x) {
SQLExpr expr = x.getExpr();
if (expr instanceof SQLMethodInvokeExpr) {
SQLMethodInvokeExpr methodInvoke = (SQLMethodInvokeExpr) expr;
if ("TABLE".equalsIgnoreCase(methodInvoke.getMethodName()) && methodInvoke.getParameters().size() == 1) {
expr = methodInvoke.getParameters().get(0);
}
}
Map<String, String> aliasMap = getAliasMap();
if (expr instanceof SQLName) {
String ident;
if (expr instanceof SQLPropertyExpr) {
String owner = ((SQLPropertyExpr) expr).getOwner().toString();
String name = ((SQLPropertyExpr) expr).getName();
if (aliasMap.containsKey(owner)) {
owner = aliasMap.get(owner);
}
ident = owner + "." + name;
} else {
ident = expr.toString();
}
if (containsSubQuery(ident)) {
return false;
}
if ("DUAL".equalsIgnoreCase(ident)) {
return false;
}
x.putAttribute(ATTR_TABLE, ident);
TableStat stat = getTableStat(ident);
Mode mode = getMode();
switch(mode) {
case Delete:
stat.incrementDeleteCount();
break;
case Insert:
stat.incrementInsertCount();
break;
case Update:
stat.incrementUpdateCount();
break;
case Select:
stat.incrementSelectCount();
break;
case Merge:
stat.incrementMergeCount();
break;
default:
break;
}
putAliasMap(aliasMap, x.getAlias(), ident);
putAliasMap(aliasMap, ident, ident);
return false;
}
accept(x.getExpr());
return false;
}
use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class OracleSchemaStatVisitor method visit.
@Override
public boolean visit(InsertIntoClause x) {
if (x.getTableName() instanceof SQLName) {
String ident = ((SQLName) x.getTableName()).toString();
setCurrentTable(x, ident);
TableStat stat = getTableStat(ident);
stat.incrementInsertCount();
Map<String, String> aliasMap = getAliasMap();
if (aliasMap != null) {
if (x.getAlias() != null) {
putAliasMap(aliasMap, x.getAlias(), ident);
}
putAliasMap(aliasMap, ident, ident);
}
}
accept(x.getColumns());
accept(x.getQuery());
accept(x.getReturning());
accept(x.getErrorLogging());
return false;
}
use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class OracleSchemaStatVisitor method visit.
public boolean visit(OracleSelectQueryBlock x) {
if (x.getWhere() != null) {
x.getWhere().setParent(x);
}
if (x.getInto() instanceof SQLName) {
String tableName = x.getInto().toString();
TableStat stat = getTableStat(tableName);
if (stat != null) {
stat.incrementInsertCount();
}
}
visit((SQLSelectQueryBlock) x);
return true;
}
Aggregations