You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by jk...@apache.org on 2001/12/10 21:55:50 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/dtm/ref DTMDefaultBase.java DTMManagerDefault.java

jkesselm    01/12/10 12:55:50

  Modified:    java/src/org/apache/xml/dtm/ref DTMDefaultBase.java
                        DTMManagerDefault.java
  Log:
  Efficiency improvement to the new DTM "overflow addressing" scheme.
  In some tests, this one alteration shaved about 30% off the runtime.
  
  Revision  Changes    Path
  1.23      +39 -10    xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java
  
  Index: DTMDefaultBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DTMDefaultBase.java	2001/11/29 16:30:47	1.22
  +++ DTMDefaultBase.java	2001/12/10 20:55:50	1.23
  @@ -144,6 +144,11 @@
      * The DTM manager who "owns" this DTM.
      */
     protected DTMManager m_mgr;
  +  /**
  +   * m_mgr cast to DTMManagerDefault, or null if it isn't an instance
  +   * (Efficiency hook)
  +   */
  +  protected DTMManagerDefault m_mgrDefault=null;
   
     /** The document identity number(s). If we have overflowed the addressing
      * range of the first that was assigned to us, we may add others. */
  @@ -213,6 +218,9 @@
       m_parent = new SuballocatedIntVector(m_initialblocksize);
   
       m_mgr = mgr;
  +    if(mgr instanceof DTMManagerDefault)
  +      m_mgrDefault=(DTMManagerDefault)mgr;
  +    
       m_documentBaseURI = (null != source) ? source.getSystemId() : null;
       m_dtmIdent.setElementAt(dtmIdentity,0);
       m_wsfilter = whiteSpaceFilter;
  @@ -225,11 +233,9 @@
       }
       else
       {
  -
  -      // %REVIEW% Is there a better way to do this?
  -      DTMManagerDefault dmd = (DTMManagerDefault) m_mgr;
  -
  -      m_expandedNameTable = dmd.getExpandedNameTable(this);
  +      // Note that this fails if we aren't talking to an instance of
  +      // DTMManagerDefault
  +      m_expandedNameTable = m_mgrDefault.getExpandedNameTable(this);
       }
   
       if (null != whiteSpaceFilter)
  @@ -903,6 +909,8 @@
      * any subclass of DTMDefaultBase to ever change the algorithm. (I don't
      * really like doing so, and would love to have an excuse not to...)
      * 
  +   * %OPT% Performance is critical for this operation.
  +   *
      * %REVIEW% Should this be exposed at the package/public layers?
      * 
      * @param NodeHandle (external representation of node)
  @@ -911,11 +919,27 @@
     final protected int makeNodeIdentity(int nodeHandle)
     {
       if(NULL==nodeHandle) return NULL;
  +
  +    if(m_mgrDefault!=null)
  +    {
  +      // Optimization: use the DTMManagerDefault's fast DTMID-to-offsets
  +      // table.  I'm not wild about this solution but this operation
  +      // needs need extreme speed.
  +
  +      int whichDTMindex=nodeHandle>>>DTMManager.IDENT_DTM_NODE_BITS;
  +
  +      // %REVIEW% Wish I didn't have to perform the pre-test, but
  +      // someone is apparently asking DTMs whether they contain nodes
  +      // which really don't belong to them. That's probably a bug
  +      // which should be fixed, but until it is:
  +      if(m_mgrDefault.m_dtms[whichDTMindex]!=this)
  +	return NULL;
  +      else
  +	return
  +	  m_mgrDefault.m_dtm_offsets[whichDTMindex]
  +	  | (nodeHandle & DTMManager.IDENT_NODE_DEFAULT);
  +    }
   	  
  -    if(JJK_DEBUG && nodeHandle<DTMManager.IDENT_NODE_DEFAULT)
  -      System.err.println("GONK! (only useful in limited situations)");
  -	  
  -		/**JJK*/int jjk=DTMManager.IDENT_DTM_DEFAULT;
       int whichDTMid=m_dtmIdent.indexOf(nodeHandle & DTMManager.IDENT_DTM_DEFAULT);
       return (whichDTMid==NULL) 
         ? NULL
  @@ -1467,7 +1491,12 @@
      */
     public int getExpandedTypeID(int nodeHandle)
     {
  -    return _exptype(makeNodeIdentity(nodeHandle));
  +    // %REVIEW% This _should_ only be null if someone asked the wrong DTM about the node...
  +    // which one would hope would never happen...
  +    int id=makeNodeIdentity(nodeHandle);
  +    if(id==NULL)
  +      return NULL;
  +    return _exptype(id);
     }
   
     /**
  
  
  
  1.32      +15 -13    xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java
  
  Index: DTMManagerDefault.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- DTMManagerDefault.java	2001/11/29 16:30:47	1.31
  +++ DTMManagerDefault.java	2001/12/10 20:55:50	1.32
  @@ -110,23 +110,25 @@
      * 
      * This array grows as necessary; see addDTM().
      * 
  -   * %REVIEW% Could use a Fast...Vector approach. Growth is uncommon,
  -   * so I'm not worrying about it.
  +   * This array grows as necessary; see addDTM(). Growth is uncommon... but
  +   * access needs to be blindingly fast since it's used in node addressing.
      */
     protected DTM m_dtms[] = new DTM[256];
   	
  -	/** Map from DTM identifier numbers to offsets. For small DTMs with a 
  -	 * single identifier, this will always be 0. In overflow addressing, where
  -	 * additional identifiers are allocated to access nodes beyond the range of
  -	 * a single Node Handle, this table is used to map the handle's node field
  -	 * into the actual node identifier.
  +  /** Map from DTM identifier numbers to offsets. For small DTMs with a 
  +   * single identifier, this will always be 0. In overflow addressing, where
  +   * additional identifiers are allocated to access nodes beyond the range of
  +   * a single Node Handle, this table is used to map the handle's node field
  +   * into the actual node identifier.
      * 
      * This array grows as necessary; see addDTM().
      * 
  -   * %REVIEW% Could use a FastIntVector approach. Growth is uncommon,
  -   * so I'm not worrying about it.
  -	 */
  -	protected int m_dtm_offsets[] = new int[256];
  +   * This array grows as necessary; see addDTM(). Growth is uncommon... but
  +   * access needs to be blindingly fast since it's used in node addressing.
  +   * (And at the moment, that includes accessing it from DTMDefaultBase,
  +   * which is why this is not Protected or Private.)
  +   */
  +  int m_dtm_offsets[] = new int[256];
   
     /**
      * Add a DTM to the DTM table. This convenience call adds it as the 
  @@ -738,7 +740,7 @@
         ((SAX2DTM) dtm).clearCoRoutine();
       }
   
  -		// Multiple DTM IDs maybe assigned to a single DTM. 
  +		// Multiple DTM IDs may be assigned to a single DTM. 
   		// The Right Answer is to ask which (if it supports
   		// extension, the DTM will need a list anyway). The 
   		// Wrong Answer, applied if the DTM can't help us,
  @@ -750,7 +752,7 @@
   		{
   			org.apache.xml.utils.SuballocatedIntVector ids=((DTMDefaultBase)dtm).getDTMIDs();
   			for(int i=ids.size()-1;i>=0;--i)
  -				m_dtms[ids.elementAt(i)>>DTMManager.IDENT_DTM_NODE_BITS]=null;
  +				m_dtms[ids.elementAt(i)>>>DTMManager.IDENT_DTM_NODE_BITS]=null;
   		}
   		else
   		{
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org