📄 nodefactoryimpl.java
字号:
/* Derby - Class org.apache.derby.impl.sql.compile.NodeFactoryImpl Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */package org.apache.derby.impl.sql.compile;import java.util.Properties;import org.apache.derby.iapi.services.context.ContextManager;import org.apache.derby.iapi.services.monitor.ModuleControl;import org.apache.derby.iapi.services.monitor.ModuleSupportable;import org.apache.derby.iapi.services.monitor.Monitor;import org.apache.derby.iapi.sql.compile.Optimizer;import org.apache.derby.iapi.sql.compile.NodeFactory;import org.apache.derby.iapi.sql.compile.C_NodeTypes;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.services.property.PropertyUtil;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.reference.SQLState;import org.apache.derby.catalog.AliasInfo;import org.apache.derby.iapi.services.loader.ClassInfo;import org.apache.derby.iapi.util.StringUtil;/** * This class is a factory for QueryTreeNode nodes. It exists to provide * methods to generate new nodes without having to call new directly. * In the future, it may implement caching of nodes, as well, to avoid * memory management and garbage collection. * * @author Jeff Lichtman */public class NodeFactoryImpl extends NodeFactory implements ModuleControl, ModuleSupportable{ ////////////////////////////////////////////////////////////////////// // // CONSTANTS // ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // // STATE // ////////////////////////////////////////////////////////////////////// /* Do join order optimization by default */ private Boolean joinOrderOptimization = Boolean.TRUE; private final ClassInfo[] nodeCi = new ClassInfo[205]; ////////////////////////////////////////////////////////////////////// // // ModuleControl interface // ////////////////////////////////////////////////////////////////////// public boolean canSupport(Properties startParams) { return Monitor.isDesiredType( startParams, org.apache.derby.iapi.reference.EngineType.NONE ); } /** @see Monitor @exception StandardException Ooops */ public void boot(boolean create, Properties startParams) throws StandardException { /* ** This system property determines whether to optimize join order ** by default. It is used mainly for testing - there are many tests ** that assume the join order is fixed. */ String opt = PropertyUtil.getSystemProperty(Optimizer.JOIN_ORDER_OPTIMIZATION); if (opt != null) { joinOrderOptimization = Boolean.valueOf(opt); } } /** @see Monitor */ public void stop() { } /** Every Module needs a public niladic constructor. It just does. */ public NodeFactoryImpl() {} /** @see NodeFactory#doJoinOrderOptimization */ public Boolean doJoinOrderOptimization() { return joinOrderOptimization; } /** * @see NodeFactory#getNode * * @exception StandardException Thrown on error */ public QueryTreeNode getNode(int nodeType, ContextManager cm) throws StandardException { ClassInfo ci = nodeCi[nodeType]; Class nodeClass = null; if (ci == null) { String nodeName = nodeName(nodeType); try { nodeClass = Class.forName(nodeName); } catch (ClassNotFoundException cnfe) { if (SanityManager.DEBUG) { SanityManager.THROWASSERT("Unexpected ClassNotFoundException", cnfe); } } ci = new ClassInfo(nodeClass); nodeCi[nodeType] = ci; } QueryTreeNode retval = null; try { retval = (QueryTreeNode) ci.getNewInstance(); //retval = (QueryTreeNode) nodeClass.newInstance(); } catch (Exception iae) { if (SanityManager.DEBUG) { SanityManager.THROWASSERT("Unexpected Exception", iae); } } retval.setContextManager(cm); retval.setNodeType(nodeType); return retval; } /** * Translate a node type from C_NodeTypes to a class name * * @param nodeType A node type identifier from C_NodeTypes * * @exception StandardException Thrown on error */ protected String nodeName(int nodeType) throws StandardException { switch (nodeType) { // WARNING: WHEN ADDING NODE TYPES HERE, YOU MUST ALSO ADD // THEM TO tools/jar/DBMSnode.properties // xxxRESOLVE: why not make this a giant array and simply index into // it? manish Thu Feb 22 14:49:41 PST 2001 case C_NodeTypes.CURRENT_ROW_LOCATION_NODE: return C_NodeNames.CURRENT_ROW_LOCATION_NODE_NAME; case C_NodeTypes.GROUP_BY_LIST: return C_NodeNames.GROUP_BY_LIST_NAME; case C_NodeTypes.ORDER_BY_LIST: return C_NodeNames.ORDER_BY_LIST_NAME; case C_NodeTypes.PREDICATE_LIST: return C_NodeNames.PREDICATE_LIST_NAME; case C_NodeTypes.RESULT_COLUMN_LIST: return C_NodeNames.RESULT_COLUMN_LIST_NAME; case C_NodeTypes.SUBQUERY_LIST: return C_NodeNames.SUBQUERY_LIST_NAME; case C_NodeTypes.TABLE_ELEMENT_LIST: return C_NodeNames.TABLE_ELEMENT_LIST_NAME; case C_NodeTypes.UNTYPED_NULL_CONSTANT_NODE: return C_NodeNames.UNTYPED_NULL_CONSTANT_NODE_NAME; case C_NodeTypes.TABLE_ELEMENT_NODE: return C_NodeNames.TABLE_ELEMENT_NODE_NAME; case C_NodeTypes.VALUE_NODE_LIST: return C_NodeNames.VALUE_NODE_LIST_NAME; case C_NodeTypes.ALL_RESULT_COLUMN: return C_NodeNames.ALL_RESULT_COLUMN_NAME; case C_NodeTypes.GET_CURRENT_CONNECTION_NODE: return C_NodeNames.GET_CURRENT_CONNECTION_NODE_NAME; case C_NodeTypes.NOP_STATEMENT_NODE: return C_NodeNames.NOP_STATEMENT_NODE_NAME; case C_NodeTypes.SET_TRANSACTION_ISOLATION_NODE: return C_NodeNames.SET_TRANSACTION_ISOLATION_NODE_NAME; case C_NodeTypes.CHAR_LENGTH_OPERATOR_NODE: return C_NodeNames.LENGTH_OPERATOR_NODE_NAME; // ISNOTNULL compressed into ISNULL case C_NodeTypes.IS_NOT_NULL_NODE: case C_NodeTypes.IS_NULL_NODE: return C_NodeNames.IS_NULL_NODE_NAME; case C_NodeTypes.NOT_NODE: return C_NodeNames.NOT_NODE_NAME; case C_NodeTypes.SQL_TO_JAVA_VALUE_NODE: return C_NodeNames.SQL_TO_JAVA_VALUE_NODE_NAME; case C_NodeTypes.TABLE_NAME: return C_NodeNames.TABLE_NAME_NAME; case C_NodeTypes.GROUP_BY_COLUMN: return C_NodeNames.GROUP_BY_COLUMN_NAME; case C_NodeTypes.JAVA_TO_SQL_VALUE_NODE: return C_NodeNames.JAVA_TO_SQL_VALUE_NODE_NAME; case C_NodeTypes.FROM_LIST: return C_NodeNames.FROM_LIST_NAME; case C_NodeTypes.BOOLEAN_CONSTANT_NODE: return C_NodeNames.BOOLEAN_CONSTANT_NODE_NAME; case C_NodeTypes.AND_NODE: return C_NodeNames.AND_NODE_NAME; case C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE: case C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE: case C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE: case C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE: case C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE: case C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE: return C_NodeNames.BINARY_RELATIONAL_OPERATOR_NODE_NAME; case C_NodeTypes.BINARY_MINUS_OPERATOR_NODE: case C_NodeTypes.BINARY_PLUS_OPERATOR_NODE: case C_NodeTypes.BINARY_TIMES_OPERATOR_NODE: case C_NodeTypes.BINARY_DIVIDE_OPERATOR_NODE: case C_NodeTypes.MOD_OPERATOR_NODE: return C_NodeNames.BINARY_ARITHMETIC_OPERATOR_NODE_NAME; case C_NodeTypes.COALESCE_FUNCTION_NODE: return C_NodeNames.COALESCE_FUNCTION_NODE_NAME; case C_NodeTypes.CONCATENATION_OPERATOR_NODE: return C_NodeNames.CONCATENATION_OPERATOR_NODE_NAME; case C_NodeTypes.LIKE_OPERATOR_NODE: return C_NodeNames.LIKE_OPERATOR_NODE_NAME; case C_NodeTypes.OR_NODE: return C_NodeNames.OR_NODE_NAME; case C_NodeTypes.BETWEEN_OPERATOR_NODE: return C_NodeNames.BETWEEN_OPERATOR_NODE_NAME; case C_NodeTypes.CONDITIONAL_NODE: return C_NodeNames.CONDITIONAL_NODE_NAME; case C_NodeTypes.IN_LIST_OPERATOR_NODE: return C_NodeNames.IN_LIST_OPERATOR_NODE_NAME; case C_NodeTypes.BIT_CONSTANT_NODE: return C_NodeNames.BIT_CONSTANT_NODE_NAME; case C_NodeTypes.LONGVARBIT_CONSTANT_NODE: case C_NodeTypes.VARBIT_CONSTANT_NODE: case C_NodeTypes.BLOB_CONSTANT_NODE: return C_NodeNames.VARBIT_CONSTANT_NODE_NAME; case C_NodeTypes.CAST_NODE: return C_NodeNames.CAST_NODE_NAME; case C_NodeTypes.CHAR_CONSTANT_NODE: case C_NodeTypes.LONGVARCHAR_CONSTANT_NODE: case C_NodeTypes.VARCHAR_CONSTANT_NODE: case C_NodeTypes.CLOB_CONSTANT_NODE: return C_NodeNames.CHAR_CONSTANT_NODE_NAME; case C_NodeTypes.XML_CONSTANT_NODE: return C_NodeNames.XML_CONSTANT_NODE_NAME; case C_NodeTypes.COLUMN_REFERENCE: return C_NodeNames.COLUMN_REFERENCE_NAME; case C_NodeTypes.DROP_INDEX_NODE:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -