use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class ParameterizationInfo method parameterizeItself.
static void parameterizeItself(VoltXMLElement parameterizedXmlSQL, Map<String, Integer> idToParamIndexMap, List<String> paramValues) {
// find the parameters xml node
VoltXMLElement paramsNode = null;
for (VoltXMLElement child : parameterizedXmlSQL.children) {
if (child.name.equals("parameters")) {
paramsNode = child;
break;
}
}
// Some plans, like for SWAP TABLE can't use parameters
if (paramsNode == null) {
return;
}
// don't optimize plans that have user-supplied params.
if (paramsNode.children.size() > 0) {
return;
}
parameterizeRecursively(parameterizedXmlSQL, paramsNode, idToParamIndexMap, paramValues);
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class ParameterizationInfo method parameterize.
public static ParameterizationInfo parameterize(VoltXMLElement xmlSQL) {
assert (xmlSQL != null);
VoltXMLElement parameterizedXmlSQL = xmlSQL.duplicate();
Map<String, Integer> idToParamIndexMap = new HashMap<String, Integer>();
List<String> paramValues = new ArrayList<String>();
parameterizeRecursively(parameterizedXmlSQL, idToParamIndexMap, paramValues);
ParameterizationInfo info = null;
if (idToParamIndexMap.size() > 0) {
info = new ParameterizationInfo(xmlSQL, parameterizedXmlSQL, paramValues.toArray(new String[paramValues.size()]));
}
return info;
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class ParsedUnionStmt method parseTablesAndParams.
/**Parse tables and parameters
*
* @param root
* @param db
*/
@Override
void parseTablesAndParams(VoltXMLElement stmtNode) {
m_tableList.clear();
// Parse parameters first to satisfy a dependency of expression parsing
// which happens during table scan parsing.
parseParameters(stmtNode);
assert (stmtNode.children.size() > 1);
AbstractParsedStmt childStmt = null;
for (VoltXMLElement childSQL : stmtNode.children) {
if (childSQL.name.equals(SELECT_NODE_NAME)) {
childStmt = new ParsedSelectStmt(m_paramValues, m_db);
// Assign every child a unique ID
childStmt.m_stmtId = AbstractParsedStmt.NEXT_STMT_ID++;
childStmt.m_parentStmt = m_parentStmt;
childStmt.setParentAsUnionClause();
} else if (childSQL.name.equals(UNION_NODE_NAME)) {
childStmt = new ParsedUnionStmt(m_paramValues, m_db);
// Set the parent before recursing to children.
childStmt.m_parentStmt = m_parentStmt;
} else {
// by the 'parse' method
continue;
}
childStmt.m_paramsById.putAll(m_paramsById);
childStmt.parseTablesAndParams(childSQL);
promoteUnionParametersFromChild(childStmt);
m_children.add(childStmt);
// Add statement's tables to the consolidated list
m_tableList.addAll(childStmt.m_tableList);
// m_tableAliasListAsJoinOrder is not interesting for UNION
// m_tableAliasMap may have same alias table from different children
addStmtTablesFromChildren(childStmt.m_tableAliasMap);
}
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class ParsedSelectStmt method parseLimitAndOffset.
static void parseLimitAndOffset(VoltXMLElement limitNode, VoltXMLElement offsetNode, LimitOffset limitOffset) {
String node;
if (limitNode != null) {
// Parse limit
if ((node = limitNode.attributes.get("limit_paramid")) != null)
limitOffset.m_limitParameterId = Long.parseLong(node);
else {
assert (limitNode.children.size() == 1);
VoltXMLElement valueNode = limitNode.children.get(0);
String isParam = valueNode.attributes.get("isparam");
if ((isParam != null) && (isParam.equalsIgnoreCase("true"))) {
limitOffset.m_limitParameterId = Long.parseLong(valueNode.attributes.get("id"));
} else {
node = limitNode.attributes.get("limit");
assert (node != null);
limitOffset.m_limit = Long.parseLong(node);
}
}
}
if (offsetNode != null) {
// Parse offset
if ((node = offsetNode.attributes.get("offset_paramid")) != null)
limitOffset.m_offsetParameterId = Long.parseLong(node);
else {
if (offsetNode.children.size() == 1) {
VoltXMLElement valueNode = offsetNode.children.get(0);
String isParam = valueNode.attributes.get("isparam");
if ((isParam != null) && (isParam.equalsIgnoreCase("true"))) {
limitOffset.m_offsetParameterId = Long.parseLong(valueNode.attributes.get("id"));
} else {
node = offsetNode.attributes.get("offset");
assert (node != null);
limitOffset.m_offset = Long.parseLong(node);
}
}
}
}
// limit and offset can't have both value and parameter
if (limitOffset.m_limit != -1) {
assert limitOffset.m_limitParameterId == -1 : "Parsed value and param. limit.";
}
if (limitOffset.m_offset != 0) {
assert limitOffset.m_offsetParameterId == -1 : "Parsed value and param. offset.";
}
}
use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.
the class ParsedDeleteStmt method parse.
@Override
void parse(VoltXMLElement stmtNode) {
assert (m_tableList.size() == 1);
VoltXMLElement limitXml = null;
VoltXMLElement offsetXml = null;
for (VoltXMLElement elem : stmtNode.children) {
if (elem.name.equalsIgnoreCase("ordercolumns")) {
parseOrderColumns(elem);
} else if (elem.name.equalsIgnoreCase("limit")) {
limitXml = elem;
} else if (elem.name.equalsIgnoreCase("offset")) {
offsetXml = elem;
}
}
m_limitPlanNode = limitPlanNodeFromXml(limitXml, offsetXml);
}
Aggregations