mkwan       2003/02/28 08:31:21

  Modified:    java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
                        SAXImpl.java
               java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
                        DTMDefaultBase.java DTMDefaultBaseIterators.java
                        DTMDefaultBaseTraversers.java
               java/src/org/apache/xml/dtm/ref/sax2dtm Tag: XSLTC_DTM
                        SAX2DTM.java SAX2DTM2.java
  Log:
  XSLTC_DTM performance work
  Do not create the previous sibling array for XSLTC. This array is not used
  in XSLTC's SAXImpl. Creating it is a waste of time.
  
  We add a boolean flag to the constructors of DTMDefaultBase and its
  subclasses to indicate whether the previous sibling array should be created.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.37  +12 -4     
xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
  
  Index: SAXImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java,v
  retrieving revision 1.1.2.36
  retrieving revision 1.1.2.37
  diff -u -r1.1.2.36 -r1.1.2.37
  --- SAXImpl.java      27 Feb 2003 19:56:04 -0000      1.1.2.36
  +++ SAXImpl.java      28 Feb 2003 16:31:05 -0000      1.1.2.37
  @@ -116,6 +116,7 @@
       private static final String XMLSPACE_STRING = "xml:space";
       private static final String PRESERVE_STRING = "preserve";
       private static final String XMLNS_PREFIX = "xmlns";
  +    private static final String XML_URI = 
"http://www.w3.org/XML/1998/namespace";;
   
       private boolean _escaping = true;
       private boolean _disableEscaping = false;
  @@ -1054,7 +1055,8 @@
                    boolean doIndexing, int blocksize)
       {
         super(mgr, saxSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
  -            doIndexing, blocksize);
  +            doIndexing, blocksize, false);
  +      
         _size = blocksize;
         
         // Use a smaller size for the space stack if the blocksize is small
  @@ -1225,8 +1227,14 @@
           //_parentStack[0] = DTMDefaultBase.ROOTNODE;  // root
           //_currentAttributeNode = 1;
   
  -        definePrefixAndUri(EMPTYSTRING, EMPTYSTRING);
  -        startPrefixMapping(XML_PREFIX, 
"http://www.w3.org/XML/1998/namespace";);
  +        //definePrefixAndUri(EMPTYSTRING, EMPTYSTRING);
  +        Integer eType = new Integer(0);
  +        _nsIndex.put(eType, eType);
  +        _uriCount++;
  +        
  +        super.startPrefixMapping(XML_PREFIX, XML_URI);
  +        eType = new Integer(getIdForNamespace(XML_URI));
  +        _nsIndex.put(eType, new Integer(_uriCount++));
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.28.2.15 +55 -16    
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.28.2.14
  retrieving revision 1.28.2.15
  diff -u -r1.28.2.14 -r1.28.2.15
  --- DTMDefaultBase.java       27 Feb 2003 19:56:04 -0000      1.28.2.14
  +++ DTMDefaultBase.java       28 Feb 2003 16:31:11 -0000      1.28.2.15
  @@ -155,7 +155,7 @@
   
     /** The document identity number(s). If we have overflowed the addressing
      * range of the first that was assigned to us, we may add others. */
  -  protected SuballocatedIntVector m_dtmIdent=new SuballocatedIntVector(32);
  +  protected SuballocatedIntVector m_dtmIdent;
   
     /** The mask for the identity.
         %REVIEW% Should this really be set to the _DEFAULT? What if
  @@ -206,7 +206,7 @@
                        XMLStringFactory xstringfactory, boolean doIndexing)
     {
       this(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
  -         doIndexing, DEFAULT_BLOCKSIZE);
  +         doIndexing, DEFAULT_BLOCKSIZE, true);
     }
   
     /**
  @@ -222,21 +222,39 @@
      * @param doIndexing true if the caller considers it worth it to use
      *                   indexing schemes.
      * @param blocksize The block size of the DTM.
  +   * @param usePrevsib true if we want to build the previous sibling node 
array.
      */
     public DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity,
                           DTMWSFilter whiteSpaceFilter,
                           XMLStringFactory xstringfactory, boolean doIndexing,
  -                        int blocksize)
  +                        int blocksize, boolean usePrevsib)
     {
       //m_blocksize = blocksize;
  -    int numblocks = (blocksize <= 64) ? DEFAULT_NUMBLOCKS_SMALL : 
  -                     DEFAULT_NUMBLOCKS;
  +    
  +    // Use smaller sizes for the internal node arrays if the block size
  +    // is small.
  +    int numblocks;    
  +    if (blocksize <= 64)
  +    {
  +      numblocks = DEFAULT_NUMBLOCKS_SMALL;
  +      m_dtmIdent= new SuballocatedIntVector(4, 1);
  +    }
  +    else
  +    {
  +      numblocks = DEFAULT_NUMBLOCKS;
  +      m_dtmIdent= new SuballocatedIntVector(32);
  +    }
       
       m_exptype = new SuballocatedIntVector(blocksize, numblocks);
       m_firstch = new SuballocatedIntVector(blocksize, numblocks);
       m_nextsib = new SuballocatedIntVector(blocksize, numblocks);
  -    m_prevsib = new SuballocatedIntVector(blocksize, numblocks);
       m_parent  = new SuballocatedIntVector(blocksize, numblocks);
  +    
  +    // Only create the m_prevsib array if the usePrevsib flag is true.
  +    // Some DTM implementations (e.g. SAXImpl) do not need this array.
  +    // We can save the time to build it in those cases.
  +    if (usePrevsib)
  +      m_prevsib = new SuballocatedIntVector(blocksize, numblocks);
   
       m_mgr = mgr;
       if(mgr instanceof DTMManagerDefault)
  @@ -750,14 +768,17 @@
           else
             ps.println("First child: " + firstChild);
   
  -        int prevSibling = _prevsib(index);
  +        if (m_prevsib != null)
  +        {
  +          int prevSibling = _prevsib(index);
   
  -        if (DTM.NULL == prevSibling)
  -          ps.println("Prev sibling: DTM.NULL");
  -        else if (NOTPROCESSED == prevSibling)
  -          ps.println("Prev sibling: NOTPROCESSED");
  -        else
  -          ps.println("Prev sibling: " + prevSibling);
  +          if (DTM.NULL == prevSibling)
  +            ps.println("Prev sibling: DTM.NULL");
  +          else if (NOTPROCESSED == prevSibling)
  +            ps.println("Prev sibling: NOTPROCESSED");
  +          else
  +            ps.println("Prev sibling: " + prevSibling);
  +        }
   
           int nextSibling = _nextsib(index);
   
  @@ -1192,9 +1213,27 @@
      */
     public int getPreviousSibling(int nodeHandle)
     {
  -     if (nodeHandle == DTM.NULL)
  -     return DTM.NULL;
  -    return makeNodeHandle(_prevsib(makeNodeIdentity(nodeHandle)));
  +    if (nodeHandle == DTM.NULL)
  +      return DTM.NULL;
  +    
  +    if (m_prevsib != null)
  +      return makeNodeHandle(_prevsib(makeNodeIdentity(nodeHandle)));
  +    else
  +    {
  +      // If the previous sibling array is not built, we get at
  +      // the previous sibling using the parent, firstch and 
  +      // nextsib arrays. 
  +      int nodeID = makeNodeIdentity(nodeHandle);
  +      int parent = _parent(nodeID);
  +      int node = _firstch(parent);
  +      int result = DTM.NULL;
  +      while (node != nodeID)
  +      {
  +        result = node;
  +        node = _nextsib(node);
  +      }
  +      return result;
  +    }
     }
   
     /**
  
  
  
  1.12.2.14 +4 -2      
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseIterators.java
  
  Index: DTMDefaultBaseIterators.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseIterators.java,v
  retrieving revision 1.12.2.13
  retrieving revision 1.12.2.14
  diff -u -r1.12.2.13 -r1.12.2.14
  --- DTMDefaultBaseIterators.java      29 Jan 2003 17:13:18 -0000      
1.12.2.13
  +++ DTMDefaultBaseIterators.java      28 Feb 2003 16:31:12 -0000      
1.12.2.14
  @@ -108,16 +108,18 @@
      * @param doIndexing true if the caller considers it worth it to use 
      *                   indexing schemes.
      * @param blocksize The block size of the DTM.
  +   * @param usePrevsib true if we want to build the previous sibling node 
array.
      */
     public DTMDefaultBaseIterators(DTMManager mgr, Source source,
                                    int dtmIdentity,
                                    DTMWSFilter whiteSpaceFilter,
                                    XMLStringFactory xstringfactory,
                                    boolean doIndexing,
  -                                 int blocksize)
  +                                 int blocksize,
  +                                 boolean usePrevsib)
     {
       super(mgr, source, dtmIdentity, whiteSpaceFilter, 
  -          xstringfactory, doIndexing, blocksize);
  +          xstringfactory, doIndexing, blocksize, usePrevsib);
     }
   
     /**
  
  
  
  1.9.2.6   +4 -2      
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseTraversers.java
  
  Index: DTMDefaultBaseTraversers.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseTraversers.java,v
  retrieving revision 1.9.2.5
  retrieving revision 1.9.2.6
  diff -u -r1.9.2.5 -r1.9.2.6
  --- DTMDefaultBaseTraversers.java     29 Jan 2003 17:13:18 -0000      1.9.2.5
  +++ DTMDefaultBaseTraversers.java     28 Feb 2003 16:31:14 -0000      1.9.2.6
  @@ -113,16 +113,18 @@
      * @param doIndexing true if the caller considers it worth it to use
      *                   indexing schemes.
      * @param blocksize The block size of the DTM.
  +   * @param usePrevsib true if we want to build the previous sibling node 
array.
      */
     public DTMDefaultBaseTraversers(DTMManager mgr, Source source,
                                     int dtmIdentity,
                                     DTMWSFilter whiteSpaceFilter,
                                     XMLStringFactory xstringfactory,
                                     boolean doIndexing,
  -                                  int blocksize)
  +                                  int blocksize,
  +                                  boolean usePrevsib)
     {
       super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
  -          doIndexing, blocksize);
  +          doIndexing, blocksize, usePrevsib);
     }
   
     /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.28.2.20 +9 -4      
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
  
  Index: SAX2DTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java,v
  retrieving revision 1.28.2.19
  retrieving revision 1.28.2.20
  diff -u -r1.28.2.19 -r1.28.2.20
  --- SAX2DTM.java      27 Feb 2003 19:56:04 -0000      1.28.2.19
  +++ SAX2DTM.java      28 Feb 2003 16:31:17 -0000      1.28.2.20
  @@ -263,7 +263,7 @@
     {
   
       this(mgr, source, dtmIdentity, whiteSpaceFilter,
  -          xstringfactory, doIndexing, DEFAULT_BLOCKSIZE);
  +          xstringfactory, doIndexing, DEFAULT_BLOCKSIZE, true);
     }
     
     /**
  @@ -279,16 +279,18 @@
      * @param doIndexing true if the caller considers it worth it to use
      *                   indexing schemes.
      * @param blocksize The block size of the DTM.
  +   * @param usePrevsib true if we want to build the previous sibling node 
array.
      */
     public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity,
                    DTMWSFilter whiteSpaceFilter,
                    XMLStringFactory xstringfactory,
                    boolean doIndexing,
  -                 int blocksize)
  +                 int blocksize,
  +                 boolean usePrevsib)
     {
   
       super(mgr, source, dtmIdentity, whiteSpaceFilter,
  -          xstringfactory, doIndexing, blocksize);
  +          xstringfactory, doIndexing, blocksize, usePrevsib);
   
       // %OPT% Use smaller sizes for all internal storage units when
       // the blocksize is small. This reduces the cost of creating an RTF.
  @@ -919,10 +921,13 @@
   
       m_firstch.addElement(canHaveFirstChild ? NOTPROCESSED : DTM.NULL);
       m_nextsib.addElement(NOTPROCESSED);
  -    m_prevsib.addElement(previousSibling);
       m_parent.addElement(parentIndex);
       m_exptype.addElement(expandedTypeID);
       m_dataOrQName.addElement(dataOrPrefix);
  +
  +    if (m_prevsib != null) {
  +      m_prevsib.addElement(previousSibling);
  +    }
   
       if (DTM.NULL != previousSibling) {
         m_nextsib.setElementAt(nodeIndex,previousSibling);
  
  
  
  1.1.2.22  +9 -5      
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java
  
  Index: SAX2DTM2.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java,v
  retrieving revision 1.1.2.21
  retrieving revision 1.1.2.22
  diff -u -r1.1.2.21 -r1.1.2.22
  --- SAX2DTM2.java     27 Feb 2003 21:44:35 -0000      1.1.2.21
  +++ SAX2DTM2.java     28 Feb 2003 16:31:20 -0000      1.1.2.22
  @@ -1728,7 +1728,7 @@
     protected int m_SHIFT;
     protected int m_MASK;
     protected int m_blocksize;
  -    
  +      
     // A constant for empty string
     private static final String EMPTY_STR = "";
   
  @@ -1742,7 +1742,7 @@
     {
   
       this(mgr, source, dtmIdentity, whiteSpaceFilter,
  -          xstringfactory, doIndexing, DEFAULT_BLOCKSIZE);
  +          xstringfactory, doIndexing, DEFAULT_BLOCKSIZE, true);
     }
    
     /**
  @@ -1752,11 +1752,12 @@
                    DTMWSFilter whiteSpaceFilter,
                    XMLStringFactory xstringfactory,
                    boolean doIndexing,
  -                 int blocksize)
  +                 int blocksize,
  +                 boolean usePrevsib)
     {
   
       super(mgr, source, dtmIdentity, whiteSpaceFilter,
  -          xstringfactory, doIndexing, blocksize);
  +          xstringfactory, doIndexing, blocksize, usePrevsib);
           
       // Initialize the values of m_SHIFT and m_MASK.
       int shift;
  @@ -2217,10 +2218,13 @@
   
       m_firstch.addElement(DTM.NULL);
       m_nextsib.addElement(DTM.NULL);
  -    m_prevsib.addElement(previousSibling);
       m_parent.addElement(parentIndex);
       m_exptype.addElement(expandedTypeID);
       m_dataOrQName.addElement(dataOrPrefix);
  +
  +    if (m_prevsib != null) {
  +      m_prevsib.addElement(previousSibling);
  +    }
   
       if (DTM.NULL != previousSibling) {
         m_nextsib.setElementAt(nodeIndex,previousSibling);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to