use of com.alibaba.druid.stat.TableStat.Mode 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.Mode in project druid by alibaba.
the class SchemaStatVisitor method setMode.
protected Mode setMode(SQLObject x, Mode mode) {
Mode oldMode = this.mode;
x.putAttribute("_original_use_mode", oldMode);
this.mode = mode;
return oldMode;
}
use of com.alibaba.druid.stat.TableStat.Mode in project druid by alibaba.
the class SchemaStatVisitor method visit.
public boolean visit(SQLExprTableSource x) {
if (isSimpleExprTableSource(x)) {
String ident = x.getExpr().toString();
if (variants.containsKey(ident)) {
return false;
}
if (containsSubQuery(ident)) {
return false;
}
Map<String, String> aliasMap = getAliasMap();
TableStat stat = getTableStat(ident);
Mode mode = getMode();
if (mode != null) {
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;
case Drop:
stat.incrementDropCount();
break;
default:
break;
}
}
if (aliasMap != null) {
String alias = x.getAlias();
if (alias != null && !aliasMap.containsKey(alias)) {
putAliasMap(aliasMap, alias, ident);
}
if (!aliasMap.containsKey(ident)) {
putAliasMap(aliasMap, ident, ident);
}
}
} else {
accept(x.getExpr());
}
return false;
}
use of com.alibaba.druid.stat.TableStat.Mode in project druid by alibaba.
the class SchemaStatVisitor method setModeOrigin.
protected void setModeOrigin(SQLObject x) {
Mode originalMode = (Mode) x.getAttribute("_original_use_mode");
mode = originalMode;
}
Aggregations