org.apache.derby.impl.sql.compile
Class NodeFactoryImpl

java.lang.Object
  extended by org.apache.derby.iapi.sql.compile.NodeFactory
      extended by org.apache.derby.impl.sql.compile.NodeFactoryImpl
All Implemented Interfaces:
ModuleControl, ModuleSupportable

public class NodeFactoryImpl
extends NodeFactory
implements ModuleControl, ModuleSupportable

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.


Field Summary
private static java.util.Vector emptyVector
           
private  java.lang.Boolean joinOrderOptimization
           
private  ClassInfo[] nodeCi
           
 
Fields inherited from class org.apache.derby.iapi.sql.compile.NodeFactory
MODULE
 
Constructor Summary
NodeFactoryImpl()
          Every Module needs a public niladic constructor.
 
Method Summary
 void boot(boolean create, java.util.Properties startParams)
          Boot this module with the given properties.
 boolean canSupport(java.util.Properties startParams)
          Module supports the standard database engine and a storeless SQL engine.
 java.lang.Boolean doJoinOrderOptimization()
          Tell whether to do join order optimization.
 QueryTreeNode getCreateAliasNode(java.lang.Object aliasName, java.lang.Object targetName, java.lang.Object aliasSpecificInfo, char aliasType, java.lang.Boolean delimitedIdentifier, ContextManager cm)
          Get one of the several types of create alias nodes.
 QueryTreeNode getNode(int nodeType, ContextManager cm)
          Get a node that takes no initializer arguments.
 ResultSetNode mapTableAsVTI(TableDescriptor td, java.lang.String correlationName, ResultColumnList resultColumns, java.util.Properties tableProperties, ContextManager cm)
          Return a node that represents invocation of the virtual table for the given table descriptor.
protected  java.lang.String nodeName(int nodeType)
          Translate a node type from C_NodeTypes to a class name
 void stop()
          Stop the module.
 
Methods inherited from class org.apache.derby.iapi.sql.compile.NodeFactory
getNode, getNode, getNode, getNode, getNode, getNode, getNode, getNode, getNode, getNode, getNode, getNode, getNode, getNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

joinOrderOptimization

private java.lang.Boolean joinOrderOptimization

nodeCi

private final ClassInfo[] nodeCi

emptyVector

private static final java.util.Vector emptyVector
Constructor Detail

NodeFactoryImpl

public NodeFactoryImpl()
Every Module needs a public niladic constructor. It just does.

Method Detail

canSupport

public boolean canSupport(java.util.Properties startParams)
Module supports the standard database engine and a storeless SQL engine. Probably a single NodeFactory will only ever exist, see DERBY-673, as part of the compile system.

Specified by:
canSupport in interface ModuleSupportable
Returns:
true if this instance can be used, false otherwise.

boot

public void boot(boolean create,
                 java.util.Properties startParams)
          throws StandardException
Description copied from interface: ModuleControl
Boot this module with the given properties. Creates a module instance that can be found using the findModule() methods of Monitor. The module can only be found using one of these findModule() methods once this method has returned.

An implementation's boot method can throw StandardException. If it is thrown the module is not registered by the monitor and therefore cannot be found through a findModule(). In this case the module's stop() method is not called, thus throwing this exception must free up any resources.

When create is true the contents of the properties object will be written to the service.properties of the persistent service. Thus any code that requires an entry in service.properties must explicitly place the value in this properties set using the put method.
Typically the properties object contains one or more default properties sets, which are not written out to service.properties. These default sets are how callers modify the create process. In a JDBC connection database create the first set of defaults is a properties object that contains the attributes that were set on the jdbc:derby: URL. This attributes properties set has the second default properties set as its default. This set (which could be null) contains the properties that the user set on their DriverManager.getConnection() call, and are thus not owned by Derby code, and thus must not be modified by Derby code.

When create is false the properties object contains all the properties set in the service.properties file plus a limited number of attributes from the JDBC URL attributes or connection properties set. This avoids properties set by the user compromising the boot process. An example of a property passed in from the JDBC world is the bootPassword for encrypted databases.

Code should not hold onto the passed in properties reference after boot time as its contents may change underneath it. At least after the complete boot is completed, the links to all the default sets will be removed.

Specified by:
boot in interface ModuleControl
Throws:
StandardException - Ooops
See Also:
Monitor

stop

public void stop()
Description copied from interface: ModuleControl
Stop the module. The module may be found via a findModule() method until some time after this method returns. Therefore the factory must be prepared to reject requests to it once it has been stopped. In addition other modules may cache a reference to the module and make requests of it after it has been stopped, these requests should be rejected as well.

Specified by:
stop in interface ModuleControl
See Also:
Monitor

doJoinOrderOptimization

public java.lang.Boolean doJoinOrderOptimization()
Description copied from class: NodeFactory
Tell whether to do join order optimization.

Specified by:
doJoinOrderOptimization in class NodeFactory
Returns:
Boolean.TRUE means do join order optimization, Boolean.FALSE means don't do it.
See Also:
NodeFactory.doJoinOrderOptimization()

getNode

public QueryTreeNode getNode(int nodeType,
                             ContextManager cm)
                      throws StandardException
Description copied from class: NodeFactory
Get a node that takes no initializer arguments.

Specified by:
getNode in class NodeFactory
Parameters:
nodeType - Identifier for the type of node.
cm - A ContextManager
Returns:
A new QueryTree node.
Throws:
StandardException - Thrown on error
See Also:
NodeFactory.getNode(int, org.apache.derby.iapi.services.context.ContextManager)

nodeName

protected java.lang.String nodeName(int nodeType)
                             throws StandardException
Translate a node type from C_NodeTypes to a class name

Parameters:
nodeType - A node type identifier from C_NodeTypes
Throws:
StandardException - Thrown on error

getCreateAliasNode

public QueryTreeNode getCreateAliasNode(java.lang.Object aliasName,
                                        java.lang.Object targetName,
                                        java.lang.Object aliasSpecificInfo,
                                        char aliasType,
                                        java.lang.Boolean delimitedIdentifier,
                                        ContextManager cm)
                                 throws StandardException
Get one of the several types of create alias nodes. Carved out of parser so this could be used by ALTER PUBLICATION.

Specified by:
getCreateAliasNode in class NodeFactory
Parameters:
aliasName - The name of the alias
targetName - The full path/method name
aliasSpecificInfo - The full path of the target method name, if any
aliasType - The type of alias to create
delimitedIdentifier - Whether or not to treat the class name as a delimited identifier if trying to resolve it as a class alias.
cm - A ContextManager
Returns:
A CreateAliasNode matching the given parameters
Throws:
StandardException - Thrown on error

mapTableAsVTI

public ResultSetNode mapTableAsVTI(TableDescriptor td,
                                   java.lang.String correlationName,
                                   ResultColumnList resultColumns,
                                   java.util.Properties tableProperties,
                                   ContextManager cm)
                            throws StandardException
Return a node that represents invocation of the virtual table for the given table descriptor. The mapping of the table descriptor to a specific VTI class name will occur as part of the "init" phase for the NewInvocationNode that we create here.

Currently only handles no argument vtis corresponding to a subset of the diagnostic tables. (e.g. lock_table). The node returned is a FROM_VTI node with a passed in NEW_INVOCATION_NODE representing the class, with no arguments. Other attributes of the original FROM_TABLE node (such as resultColumns) are passed into the FROM_VTI node.

Specified by:
mapTableAsVTI in class NodeFactory
Parameters:
td - Table that is really a vti
correlationName - Correlation name of table clause
resultColumns - Columns extracted from table.
tableProperties - Properties being passed onto the table scan
cm - Current context manager
Throws:
StandardException

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.