use of com.alibaba.cobar.parser.ast.ASTNode in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(DMLInsertStatement node) {
insertReplace(node);
List<Pair<Identifier, Expression>> dup = node.getDuplicateUpdate();
if (dup != null) {
ASTNode[] duplist = new ASTNode[dup.size() * 2];
int i = 0;
for (Pair<Identifier, Expression> p : dup) {
Identifier key = null;
Expression value = null;
if (p != null) {
key = p.getKey();
value = p.getValue();
}
duplist[i++] = key;
duplist[i++] = value;
}
visitChild(2, false, false, duplist);
}
}
use of com.alibaba.cobar.parser.ast.ASTNode in project cobar by alibaba.
the class PartitionKeyVisitor method visitChild.
private void visitChild(int idLevel, boolean verdictColumn, boolean verdictGroupFunc, ASTNode... nodes) {
if (nodes == null || nodes.length <= 0)
return;
int oldLevel = this.idLevel;
boolean oldVerdict = this.verdictColumn;
boolean oldverdictGroupFunc = this.verdictGroupFunc;
this.idLevel = idLevel;
this.verdictColumn = verdictColumn;
this.verdictGroupFunc = verdictGroupFunc;
try {
for (ASTNode node : nodes) {
if (node != null)
node.accept(this);
}
} finally {
this.verdictColumn = oldVerdict;
this.idLevel = oldLevel;
this.verdictGroupFunc = oldverdictGroupFunc;
}
}
use of com.alibaba.cobar.parser.ast.ASTNode in project cobar by alibaba.
the class PartitionKeyVisitor method visit.
@Override
public void visit(DMLUpdateStatement node) {
TableReference tr = node.getTableRefs();
visitChild(1, false, false, tr);
List<Pair<Identifier, Expression>> assignmentList = node.getValues();
if (assignmentList != null && !assignmentList.isEmpty()) {
List<ASTNode> list = new ArrayList<ASTNode>(assignmentList.size() * 2);
for (Pair<Identifier, Expression> p : assignmentList) {
if (p == null)
continue;
list.add(p.getKey());
list.add(p.getValue());
}
visitChild(2, false, false, list);
}
Expression where = node.getWhere();
visitChild(2, verdictColumn, false, where);
OrderBy order = node.getOrderBy();
visitChild(2, false, false, order);
}
use of com.alibaba.cobar.parser.ast.ASTNode in project cobar by alibaba.
the class PartitionKeyVisitor method visitChild.
private void visitChild(int idLevel, boolean verdictColumn, boolean verdictGroupFunc, List<? extends ASTNode> nodes) {
if (nodes == null || nodes.isEmpty())
return;
int oldLevel = this.idLevel;
boolean oldVerdict = this.verdictColumn;
boolean oldverdictGroupFunc = this.verdictGroupFunc;
this.idLevel = idLevel;
this.verdictColumn = verdictColumn;
this.verdictGroupFunc = verdictGroupFunc;
try {
for (ASTNode node : nodes) {
if (node != null)
node.accept(this);
}
} finally {
this.verdictColumn = oldVerdict;
this.idLevel = oldLevel;
this.verdictGroupFunc = oldverdictGroupFunc;
}
}
Aggregations