mkwan       2003/03/21 08:51:50

  Modified:    java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
                        NthIterator.java
               java/src/org/apache/xml/dtm Tag: XSLTC_DTM
                        DTMAxisIterator.java
               java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
                        DTMAxisIteratorBase.java
               java/src/org/apache/xml/dtm/ref/sax2dtm Tag: XSLTC_DTM
                        SAX2DTM2.java
  Log:
  XSLTC_DTM performance work
  Improvement for step[n]. Introduce a new interface getNodeByPosition(int 
position)
  in DTMAxisIterator, which is used by the NthIterator. The default 
implementation
  is in DTMAxisIteratorBase. The subclasses can override this interface to 
provide
  a faster customized implementation.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.9.10.6  +8 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java
  
  Index: NthIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java,v
  retrieving revision 1.9.10.5
  retrieving revision 1.9.10.6
  diff -u -r1.9.10.5 -r1.9.10.6
  --- NthIterator.java  30 Jan 2003 18:41:47 -0000      1.9.10.5
  +++ NthIterator.java  21 Mar 2003 16:51:49 -0000      1.9.10.6
  @@ -98,6 +98,12 @@
       }
   
       public int next() {
  +     if (_ready) {
  +         _ready = false;
  +         return _source.getNodeByPosition(_position);
  +     }
  +     return DTMAxisIterator.END;
  +     /*
        if (_ready && _position > 0) {
               final int pos = _source.isReverse()
                                          ? _source.getLast() - _position + 1
  @@ -112,6 +118,7 @@
            }
        }
        return DTMAxisIterator.END;
  +     */
       }
   
       public DTMAxisIterator setStartNode(final int node) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.4.12.3  +8 -0      
xml-xalan/java/src/org/apache/xml/dtm/DTMAxisIterator.java
  
  Index: DTMAxisIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTMAxisIterator.java,v
  retrieving revision 1.4.12.2
  retrieving revision 1.4.12.3
  diff -u -r1.4.12.2 -r1.4.12.3
  --- DTMAxisIterator.java      27 Jan 2003 19:45:27 -0000      1.4.12.2
  +++ DTMAxisIterator.java      21 Mar 2003 16:51:49 -0000      1.4.12.3
  @@ -135,4 +135,12 @@
      * Set if restartable.
      */
     public void setRestartable(boolean isRestartable);
  +
  +  /**
  +   * Return the node at the given position.
  +   * 
  +   * @param position The position
  +   * @return The node at the given position.
  +   */
  +  public int getNodeByPosition(int position);
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.5.12.5  +23 -2     
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java
  
  Index: DTMAxisIteratorBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMAxisIteratorBase.java,v
  retrieving revision 1.5.12.4
  retrieving revision 1.5.12.5
  diff -u -r1.5.12.4 -r1.5.12.5
  --- DTMAxisIteratorBase.java  30 Jan 2003 18:41:52 -0000      1.5.12.4
  +++ DTMAxisIteratorBase.java  21 Mar 2003 16:51:49 -0000      1.5.12.5
  @@ -289,7 +289,28 @@
     }
     
     public void setRestartable(boolean isRestartable) {
  -     _isRestartable = isRestartable;
  -     }  
  +    _isRestartable = isRestartable;
  +  }
  +  
  +  /**
  +   * Return the node at the given position.
  +   * 
  +   * @param position The position
  +   * @return The node at the given position.
  +   */
  +  public int getNodeByPosition(int position)
  +  {
  +    if (position > 0) {
  +      final int pos = isReverse() ? getLast() - position + 1
  +                                   : position;
  +      int node;
  +      while ((node = next()) != DTMAxisIterator.END) {
  +        if (pos == getPosition()) {
  +          return node;
  +        }
  +      }
  +    }
  +    return END;
  +  }
     
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.29  +106 -19   
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.28
  retrieving revision 1.1.2.29
  diff -u -r1.1.2.28 -r1.1.2.29
  --- SAX2DTM2.java     14 Mar 2003 20:18:56 -0000      1.1.2.28
  +++ SAX2DTM2.java     21 Mar 2003 16:51:50 -0000      1.1.2.29
  @@ -324,6 +324,44 @@
         }
   
       }
  +
  +    /**
  +     * Return the node at the given position.
  +     */
  +    public int getNodeByPosition(int position)
  +    {
  +      if (position <= 0)
  +        return DTM.NULL;
  +      
  +      int node = _currentNode; 
  +      int pos = 0;
  +      
  +      final int nodeType = _nodeType;
  +      if (nodeType != DTM.ELEMENT_NODE) {   
  +        while (node != DTM.NULL) {
  +          if (_exptype2(node) == nodeType) {
  +            pos++;
  +            if (pos == position)
  +              return makeNodeHandle(node);
  +          }
  +          
  +          node = _nextsib2(node);
  +        }
  +        return NULL;
  +      }
  +      else {
  +             while (node != DTM.NULL) {
  +               if (_exptype2(node) >= DTM.NTYPES) {
  +                 pos++;
  +                 if (pos == position)
  +                   return makeNodeHandle(node);
  +               }
  +               node = _nextsib2(node);
  +             }
  +             return NULL;
  +      }
  +    }
  +
     }  // end of TypedChildrenIterator
   
     /**
  @@ -475,6 +513,7 @@
                         ? DTM.NULL
                         : returnNode(makeNodeHandle(node));
       }
  +
     }  // end of TypedFollowingSiblingIterator
   
     /**
  @@ -709,39 +748,67 @@
       public int next()
       {
         int node = _currentNode;
  -      int expType;
   
  -      int nodeType = _nodeType;
  -      int startID = _startNodeID;
  +      final int nodeType = _nodeType;
  +      final int startNodeID = _startNodeID;
   
  -      if (nodeType >= DTM.NTYPES) {
  -        while (node != NULL && node != startID && _exptype2(node) != 
nodeType) {
  +      if (nodeType != DTM.ELEMENT_NODE) {
  +        while (node != NULL && node != startNodeID && _exptype2(node) != 
nodeType) {
             node = _nextsib2(node);
           }
  -      } else {
  -        while (node != NULL && node != startID) {
  -          expType = _exptype2(node);
  -          if (expType < DTM.NTYPES) {
  -            if (expType == nodeType) {
  -              break;
  -            }
  -          } else {
  -            if (m_extendedTypes[expType].getNodeType() == nodeType) {
  -              break;
  -            }
  -          }
  +      } 
  +      else {
  +        while (node != NULL && node != startNodeID && _exptype2(node) < 
DTM.NTYPES) {
             node = _nextsib2(node);
           }
         }
   
  -      if (node == DTM.NULL || node == _startNodeID) {
  +      if (node == DTM.NULL || node == startNodeID) {
           _currentNode = NULL;
           return NULL;
  -      } else {
  +      }
  +      else {
           _currentNode = _nextsib2(node);
           return returnNode(makeNodeHandle(node));
         }
       }
  +    
  +    /**
  +     * Return the index of the last node in this iterator.
  +     */    
  +    public int getLast()
  +    {
  +      if (_last != -1)
  +        return _last;
  +      
  +      setMark();
  +      
  +      int node = _currentNode;
  +      final int nodeType = _nodeType;
  +      final int startNodeID = _startNodeID;
  +      
  +      int last = 0;
  +      if (nodeType != DTM.ELEMENT_NODE) {
  +        while (node != NULL && node != startNodeID) {
  +          if (_exptype2(node) == nodeType) {
  +            last++;
  +          }
  +          node = _nextsib2(node);
  +        }
  +      }
  +      else {
  +        while (node != NULL && node != startNodeID) {
  +          if (_exptype2(node) >= DTM.NTYPES) {
  +            last++;
  +          }
  +          node = _nextsib2(node);
  +        }      
  +      }
  +      
  +      gotoMark();
  +      
  +      return (_last = last);
  +    }
     }  // end of TypedPrecedingSiblingIterator
   
     /**
  @@ -1436,6 +1503,26 @@
         }
   
         return this;
  +    }
  +
  +    /**
  +     * Return the node at the given position.
  +     */
  +    public int getNodeByPosition(int position)
  +    {
  +      if (position > 0 && position <= m_size) {
  +        return m_ancestors[position-1];
  +      }
  +      else
  +        return DTM.NULL;
  +    }
  +    
  +    /** 
  +     * Returns the position of the last node within the iteration, as
  +     * defined by XPath.    
  +     */
  +    public int getLast() {
  +      return m_size;
       }
     }  // end of TypedAncestorIterator
   
  
  
  

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

Reply via email to