db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1495305 [19/21] - in /db/derby/code/trunk: java/engine/org/apache/derby/ java/engine/org/apache/derby/catalog/types/ java/engine/org/apache/derby/iapi/services/io/ java/engine/org/apache/derby/iapi/sql/ java/engine/org/apache/derby/iapi/sq...
Date Fri, 21 Jun 2013 07:47:52 GMT
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowNode.java Fri
Jun 21 07:47:47 2013
@@ -22,6 +22,7 @@
 package org.apache.derby.impl.sql.compile;
 
 import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.context.ContextManager;
 
 /**
  * Superclass of window definition and window reference.
@@ -32,32 +33,29 @@ public abstract class WindowNode extends
      * The provided name of the window if explicitly defined in a window
      * clause. If the definition is inlined, currently the definition has
      * windowName "IN_LINE".  The standard 2003 sec. 4.14.9 calls for a
-     * impl. defined one.
+     * implementation defined one.
      */
     private String windowName;
 
 
     /**
-     * Initializer
+     * Constructor
      *
-     * @param arg1 The window name
+     * @param windowName The window name
+     * @param cm         The context manager
      *
      * @exception StandardException
      */
-    public void init(Object arg1)
-        throws StandardException
+    WindowNode(String windowName, ContextManager cm) throws StandardException
     {
-        windowName = (String)arg1;
+        super(cm);
+        this.windowName = windowName;
     }
 
-
     /**
      * @return the name of this window
      */
     public String getName() {
         return windowName;
     }
-
-
-
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowReferenceNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowReferenceNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowReferenceNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowReferenceNode.java
Fri Jun 21 07:47:47 2013
@@ -22,6 +22,8 @@
 package org.apache.derby.impl.sql.compile;
 
 import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 
 /**
  * Represents a reference to an explicitly defined window
@@ -29,19 +31,21 @@ import org.apache.derby.iapi.error.Stand
 public final class WindowReferenceNode extends WindowNode
 {
     /**
-     * Initializer
+     * Constructor
      *
-     * @param arg1 The window name referenced
+     * @param windowName The window name referenced
+     * @param cm         The context manager
      *
      * @exception StandardException
      */
-    public void init(Object arg1)
+    WindowReferenceNode(String windowName, ContextManager cm)
         throws StandardException
     {
-        super.init(arg1);
+        super(windowName, cm);
+        setNodeType(C_NodeTypes.WINDOW_REFERENCE_NODE);
     }
 
-    // java.lang.Object override
+    @Override
     public String toString() {
         return "referenced window: " + getName() + "\n" +
             super.toString();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java
Fri Jun 21 07:47:47 2013
@@ -26,46 +26,50 @@ import org.apache.derby.iapi.error.Stand
 import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.io.FormatableBitSet;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.LanguageFactory;
 import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 
 
 /**
  * A WindowResultSetNode represents a result set for a window partitioning on a
- * select. Modelled on the code in GroupByNode.
+ * select. Modeled on the code in GroupByNode.
  */
-public class WindowResultSetNode extends SingleChildResultSetNode
+class WindowResultSetNode extends SingleChildResultSetNode
 {
     /**
      * The parent to the WindowResultSetNode.  We generate a ProjectRestrict
      * over the windowing node and parent is set to that node.
      */
     FromTable   parent;
-    List windowFuncCalls;
+    List<WindowFunctionNode> windowFuncCalls;
     WindowDefinitionNode wdn;
 
     /**
-     * Intializer for a WindowResultSetNode.
-     * @param bottomPR The project restrict result set we want to wrap
-     * @param windowDef The window definition
-     * @param windowFuncCalls All window function calls in SELECT's select list
-     * and order by list.
+     * Constructor for a WindowResultSetNode.
+     *
+     * @param bottomPR     The project restrict result set we want to wrap
+     * @param windowDef    The window definition
+     * @param windowFuncCalls
+     *                     All window function calls in SELECT's select list
+     *                     and order by list.
      * @param nestingLevel Nesting level
+     * @param cm           The context manager
      *
      * @exception StandardException     Thrown on error
      */
-    public void init(
-        Object bottomPR,
-        Object windowDef,
-        Object windowFuncCalls,
-        Object nestingLevel) throws StandardException
+    WindowResultSetNode(ResultSetNode            bottomPR,
+                        WindowDefinitionNode     windowDef,
+                        List<WindowFunctionNode> windowFuncCalls,
+                        int                      nestingLevel,
+                        ContextManager           cm) throws StandardException
     {
-        super.init(bottomPR, null);
-        this.wdn = (WindowDefinitionNode)windowDef;
-        this.windowFuncCalls = (List) windowFuncCalls;
-        setLevel(((Integer)nestingLevel).intValue());
+        super(bottomPR, null, cm);
+        setNodeType(C_NodeTypes.WINDOW_RESULTSET_NODE);
+        this.wdn = windowDef;
+        this.windowFuncCalls = windowFuncCalls;
+        setLevel(nestingLevel);
 
         ResultColumnList newBottomRCL;
 
@@ -98,9 +102,7 @@ public class WindowResultSetNode extends
         /*
         ** Get the new PR, put above the WindowResultSetNode.
         */
-        ResultColumnList rclNew = (ResultColumnList)getNodeFactory().
-            getNode(C_NodeTypes.RESULT_COLUMN_LIST,
-                    getContextManager());
+        ResultColumnList rclNew = new ResultColumnList(getContextManager());
 
         int sz = resultColumns.size();
         for (int i = 0; i < sz; i++)
@@ -116,32 +118,25 @@ public class WindowResultSetNode extends
         // have to be projected out upstream.
         rclNew.copyOrderBySelect(resultColumns);
 
-        parent = (FromTable) getNodeFactory().getNode(
-                                        C_NodeTypes.PROJECT_RESTRICT_NODE,
-                                        this, // child
-                                        rclNew,
-                                        null, // havingClause,
-                                        null, // restriction list
-                                        null, // project subqueries
-                                        null, // havingSubquerys,
-                                        null, // tableProperties,
-                                        getContextManager());
+        parent = new ProjectRestrictNode(this, // child
+                                         rclNew,
+                                         null, // havingClause,
+                                         null, // restriction list
+                                         null, // project subqueries
+                                         null, // havingSubquerys,
+                                         null, // tableProperties,
+                                         getContextManager());
 
 
         /*
          * Reset the bottom RCL to be empty.
          */
-        childResult.setResultColumns((ResultColumnList)
-                                            getNodeFactory().getNode(
-                                                C_NodeTypes.RESULT_COLUMN_LIST,
-                                                getContextManager()));
+        childResult.setResultColumns(new ResultColumnList(getContextManager()));
 
         /*
          * Set the Windowing RCL to be empty
          */
-        resultColumns = (ResultColumnList) getNodeFactory().getNode(
-                                            C_NodeTypes.RESULT_COLUMN_LIST,
-                                            getContextManager());
+        resultColumns = new ResultColumnList(getContextManager());
 
 
         // Add all referenced columns in select list to windowing node's RCL
@@ -150,8 +145,6 @@ public class WindowResultSetNode extends
         CollectNodesVisitor<ColumnReference> getCRVisitor =
             new CollectNodesVisitor<ColumnReference>(ColumnReference.class);
 
-        ResultColumnList prcl = parent.getResultColumns();
-
         parent.getResultColumns().accept(getCRVisitor);
 
         // Find all unique columns referenced and add those to windowing result
@@ -179,10 +172,9 @@ public class WindowResultSetNode extends
         ResultColumnList windowingRCL = resultColumns;
 
         for (int i= 0; i< uniqueCols.size(); i++) {
-            ValueNode crOrVcn = (ValueNode) uniqueCols.get(i);
+            ValueNode crOrVcn = uniqueCols.get(i);
 
-            ResultColumn newRC = (ResultColumn) getNodeFactory().getNode(
-                    C_NodeTypes.RESULT_COLUMN,
+            ResultColumn newRC = new ResultColumn(
                     "##UnWindowingColumn",
                     crOrVcn,
                     getContextManager());
@@ -194,8 +186,7 @@ public class WindowResultSetNode extends
             newRC.setVirtualColumnId(bottomRCL.size());
 
             // now add this column to the windowing result column list
-            ResultColumn wRC = (ResultColumn) getNodeFactory().getNode(
-                    C_NodeTypes.RESULT_COLUMN,
+            ResultColumn wRC = new ResultColumn(
                     "##UnWindowingColumn",
                     crOrVcn,
                     getContextManager());
@@ -208,11 +199,10 @@ public class WindowResultSetNode extends
              ** Reset the original node to point to the
              ** Windowing result set.
              */
-            VirtualColumnNode vc = (VirtualColumnNode) getNodeFactory().getNode(
-                    C_NodeTypes.VIRTUAL_COLUMN_NODE,
+            VirtualColumnNode vc = new VirtualColumnNode(
                     this, // source result set.
                     wRC,
-                    new Integer(windowingRCL.size()),
+                    windowingRCL.size(),
                     getContextManager());
 
             SubstituteExpressionVisitor seVis =
@@ -223,15 +213,15 @@ public class WindowResultSetNode extends
 
 
     /**
-     * @return true if an equivalent column reference to cand is already
-     * present in uniqueColRefs
+     * @return {@code true} if an equivalent column reference to {@code cand}
+     *         is already present in {@code uniqueColRefs}
      */
-    private boolean colRefAlreadySeen(List uniqueColRefs,
+    private boolean colRefAlreadySeen(List<ValueNode> uniqueColRefs,
                                       ColumnReference cand)
             throws StandardException {
 
         for (int i= 0; i< uniqueColRefs.size(); i++) {
-            ColumnReference cr = (ColumnReference) uniqueColRefs.get(i);
+            ColumnReference cr = (ColumnReference)uniqueColRefs.get(i);
 
             if (cr.isEquivalent(cand)) {
                 return true;
@@ -250,24 +240,18 @@ public class WindowResultSetNode extends
          * call with an RC.  We toss out the list of RCs, we need to get
          * each RC as we process its corresponding window function.
          */
-        LanguageFactory lf =
-            getLanguageConnectionContext().getLanguageFactory();
-
         ResultColumnList bottomRCL  = childResult.getResultColumns();
         ResultColumnList windowingRCL = resultColumns;
 
         ReplaceWindowFuncCallsWithCRVisitor replaceCallsVisitor =
             new ReplaceWindowFuncCallsWithCRVisitor(
-                (ResultColumnList) getNodeFactory().getNode(
-                    C_NodeTypes.RESULT_COLUMN_LIST,
-                    getContextManager()),
+                new ResultColumnList(getContextManager()),
                 ((FromTable) childResult).getTableNumber(),
                 ResultSetNode.class);
         parent.getResultColumns().accept(replaceCallsVisitor);
 
         for (int i=0; i < windowFuncCalls.size(); i++) {
-            WindowFunctionNode winFunc =
-                (WindowFunctionNode) windowFuncCalls.get(i);
+            WindowFunctionNode winFunc = windowFuncCalls.get(i);
 
             if (SanityManager.DEBUG) {
                 SanityManager.ASSERT(
@@ -280,8 +264,7 @@ public class WindowResultSetNode extends
                 (WindowDefinitionNode)winFunc.getWindow();
 
             if (funcWindow == wdn) {
-                ResultColumn newRC = (ResultColumn) getNodeFactory().getNode(
-                    C_NodeTypes.RESULT_COLUMN,
+                ResultColumn newRC = new ResultColumn(
                     "##winFuncResult",
                     winFunc.getNewNullResultExpression(),
                     getContextManager());
@@ -290,27 +273,21 @@ public class WindowResultSetNode extends
                 newRC.bindResultColumnToExpression();
                 bottomRCL.addElement(newRC);
                 newRC.setVirtualColumnId(bottomRCL.size());
-                int winFuncResultVColId = newRC.getVirtualColumnId();
 
                 /*
                 ** Set the WindowResultSetNode result column to point to this.
                 ** The Windowing Node result was created when we called
                 ** ReplaceWindowFuncCallsWithCRVisitor.
                 */
-                ColumnReference newColumnRef =
-                    (ColumnReference) getNodeFactory().getNode(
-                        C_NodeTypes.COLUMN_REFERENCE,
-                        newRC.getName(),
-                        null,
-                        getContextManager());
+                ColumnReference newColumnRef = new ColumnReference(
+                        newRC.getName(), null, getContextManager());
 
                 newColumnRef.setSource(newRC);
                 newColumnRef.setNestingLevel(this.getLevel());
                 newColumnRef.setSourceLevel(this.getLevel());
                 newColumnRef.markGeneratedToReplaceWindowFunctionCall();
 
-                ResultColumn tmpRC = (ResultColumn) getNodeFactory().getNode(
-                    C_NodeTypes.RESULT_COLUMN,
+                ResultColumn tmpRC = new ResultColumn(
                     newRC.getColumnName(),
                     newColumnRef,
                     getContextManager());
@@ -338,6 +315,7 @@ public class WindowResultSetNode extends
      * override
      * @see QueryTreeNode#generate
      */
+    @Override
     void generate(ActivationClassBuilder acb, MethodBuilder mb)
             throws StandardException
     {
@@ -415,6 +393,7 @@ public class WindowResultSetNode extends
      * QueryTreeNode override
      * @see QueryTreeNode#printSubNodes
      */
+    @Override
     public void printSubNodes(int depth) {
         if (SanityManager.DEBUG) {
 			super.printSubNodes(depth);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLConstantNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLConstantNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLConstantNode.java
Fri Jun 21 07:47:47 2013
@@ -23,31 +23,16 @@ package    org.apache.derby.impl.sql.com
 
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.io.StoredFormatIds;
-import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.types.TypeId;
 
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
-
-import org.apache.derby.iapi.util.ReuseFactory;
-
 public final class XMLConstantNode extends ConstantNode
 {
-    /**
-     * Initializer for an XMLConstantNode.
-     *
-     * @param arg1 The TypeId for the type of the node
-     *
-     * @exception StandardException
-     */
-    public void init(
-                    Object arg1)
-        throws StandardException
-    {
-        super.init(
-                    arg1,
-                    Boolean.TRUE,
-                    ReuseFactory.getInteger(0));
+    XMLConstantNode(TypeId t, ContextManager cm)
+            throws StandardException {
+        super(t, true, 0, cm);
+        setNodeType(C_NodeTypes.XML_CONSTANT_NODE);
     }
 
     /**
@@ -60,6 +45,7 @@ public final class XMLConstantNode exten
      *
      * @exception StandardException        Thrown on error
      */
+    @Override
     Object getConstantValueAsObject() throws StandardException 
     {
         return value.getObject();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLOptTrace.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLOptTrace.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLOptTrace.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLOptTrace.java Fri
Jun 21 07:47:47 2013
@@ -26,19 +26,11 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
 import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-import org.apache.derby.iapi.util.JBitSet;
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.iapi.sql.compile.AccessPath;
 import org.apache.derby.iapi.sql.compile.CostEstimate;
@@ -50,7 +42,11 @@ import org.apache.derby.iapi.sql.compile
 import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
 import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;
 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
+import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
 import org.apache.derby.iapi.util.IdUtil;
+import org.apache.derby.iapi.util.JBitSet;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 /**
  * Optimizer tracer which produces output in an xml format.
@@ -496,14 +492,22 @@ class   XMLOptTrace implements  OptTrace
         try {
             if ( isBaseTable( optimizable ) )
             {
-                TableDescriptor td = ((FromBaseTable) ((ProjectRestrictNode) optimizable).getChildResult()).getTableDescriptor();
-                return makeTableName( td.getSchemaName(), td.getName() );
+                ProjectRestrictNode prn = (ProjectRestrictNode) optimizable;
+                TableDescriptor td = 
+                    ((FromBaseTable) prn.getChildResult()).getTableDescriptor();
+                return makeTableName( td.getSchemaName(),
+                                      td.getName(),
+                                      prn.getContextManager() );
             }
             else if ( isTableFunction( optimizable ) )
             {
+                ProjectRestrictNode prn = (ProjectRestrictNode) optimizable;
                 AliasDescriptor ad =
-                    ((StaticMethodCallNode) ((FromVTI) ((ProjectRestrictNode) optimizable).getChildResult()).getMethodCall()
).ad;
-                return makeTableName( ad.getSchemaName(), ad.getName() );
+                    ((StaticMethodCallNode) ((FromVTI) prn.getChildResult()).
+                        getMethodCall() ).ad;
+                return makeTableName( ad.getSchemaName(), 
+                                      ad.getName(),
+                                      prn.getContextManager() );
             }
             else if ( isFromTable( optimizable ) )
             {
@@ -521,7 +525,7 @@ class   XMLOptTrace implements  OptTrace
         String  nodeClass = optimizable.getClass().getName();
         String  unqualifiedName = nodeClass.substring( nodeClass.lastIndexOf( "." ) + 1 );
 
-        return makeTableName( null, unqualifiedName );
+        return makeTableName( null, unqualifiedName, null );
     }
 
     /** Return true if the optimizable is a base table */
@@ -556,10 +560,10 @@ class   XMLOptTrace implements  OptTrace
     }
 
     /** Make a TableName */
-    private TableName   makeTableName( String schemaName, String unqualifiedName )
+    private TableName   makeTableName(
+            String schemaName, String unqualifiedName, ContextManager cm )
     {
-        TableName   result = new TableName();
-        result.init( schemaName, unqualifiedName );
+        TableName result = new TableName(schemaName, unqualifiedName, cm);
 
         return result;
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java
Fri Jun 21 07:47:47 2013
@@ -21,23 +21,19 @@
 
 package org.apache.derby.impl.sql.compile;
 
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.services.loader.ClassFactory;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
-
-import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.types.TypeId;
 
 /**
  * This class implements TypeCompiler for the XML type.
  */
 
-public class XMLTypeCompiler extends BaseTypeCompiler
+class XMLTypeCompiler extends BaseTypeCompiler
 {
     /**
      * Tell whether this type (XML) can be converted to the given type.
@@ -145,6 +141,7 @@ public class XMLTypeCompiler extends Bas
     /**
      * @see BaseTypeCompiler#dataValueMethodName
      */
+    @Override
     protected String dataValueMethodName()
     {
         int formatId = getStoredFormatIdFromTypeId();



Mime
View raw message