本文整理汇总了Java中org.voltdb.types.ExpressionType.get方法的典型用法代码示例。如果您正苦于以下问题:Java ExpressionType.get方法的具体用法?Java ExpressionType.get怎么用?Java ExpressionType.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.types.ExpressionType
的用法示例。
在下文中一共展示了ExpressionType.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseOperationExpression
import org.voltdb.types.ExpressionType; //导入方法依赖的package包/类
/**
*
* @param exprNode
* @param attrs
* @param db
* @return
*/
AbstractExpression parseOperationExpression(Node exprNode, NamedNodeMap attrs, Database db) {
String type = attrs.getNamedItem("type").getNodeValue();
ExpressionType exprType = ExpressionType.get(type);
AbstractExpression expr = null;
if (exprType == ExpressionType.INVALID) {
throw new PlanningErrorException("Unsupported operation type '" + type + "'");
}
try {
expr = exprType.getExpressionClass().newInstance();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
expr.setExpressionType(exprType);
// Allow expressions to read expression-specific data from exprNode.
// Looks like the design fully abstracts other volt classes from
// the XML serialization? Putting this here instead of in derived
// Expression implementations.
if (expr instanceof AggregateExpression) {
Node node;
if ((node = attrs.getNamedItem("distinct")) != null) {
AggregateExpression ae = (AggregateExpression)expr;
ae.m_distinct = Boolean.parseBoolean(node.getNodeValue());
}
}
// setup for children access
NodeList children = exprNode.getChildNodes();
int i = 0;
// get the first (left) node that is an element
Node leftExprNode = children.item(i++);
while ((leftExprNode != null) && (leftExprNode.getNodeType() != Node.ELEMENT_NODE))
leftExprNode = children.item(i++);
assert(leftExprNode != null);
// get the second (right) node that is an element (might be null)
Node rightExprNode = children.item(i++);
while ((rightExprNode != null) && (rightExprNode.getNodeType() != Node.ELEMENT_NODE))
rightExprNode = children.item(i++);
// recursively parse the left subtree (could be another operator or
// a constant/tuple/param value operand).
AbstractExpression leftExpr = parseExpressionTree(leftExprNode, db);
assert((leftExpr != null) || (exprType == ExpressionType.AGGREGATE_COUNT));
expr.setLeft(leftExpr);
if (ExpressionUtil.needsRightExpression(expr)) {
assert(rightExprNode != null);
// recursively parse the right subtree
AbstractExpression rightExpr = parseExpressionTree(rightExprNode, db);
assert(rightExpr != null);
expr.setRight(rightExpr);
}
return expr;
}