tags:

views:

230

answers:

1

Have anyone used the Cumulative Maximum functoid and noticed performance problems?

Abstract
If one wants to map the maximum value of a field you can use the functoid Cumulative Maximum.

Problem
After we had used it for a while we noticed degraded performance on larger files.

Examining the xslt one notices that the max calculation is made for each looping record...

One could move the calculation to the grand parent, and point out the new xslt in the Custom XSL Path, but I really like to keep the possibility to map in the mapping tool.

Any suggestions?

Kind Regards
Martin Bring

http://martinbring.blogspot.com

+3  A: 

By removing the Cumulative Maximum and adding 3 scripting functoids, doing the calculation in another way, the problem is solved. Mapping time decreased by a factor of 40.

11 Mb, 10 000 rows, was previously mapped in 200 minutes is now mapped in 5 minutes.

Solution
One scripting functoid, "Inline XSLT Call Template" with no input or output, containing the max() portion of the library from EXSLT Math library found here. Instead of using the whole library I unzipped the file and "extracted" the max() template.

 <xsl:template name="GetMax">
   <xsl:param name="nodes" /> 

    <xsl:choose>
      <xsl:when test="not($nodes)">NaN</xsl:when> 
      <xsl:otherwise>
        <xsl:for-each select="$nodes">
          <xsl:sort data-type="number" order="descending" /> 
          <xsl:if test="position() = 1">
          <xsl:value-of select="number(.)" /> 
        </xsl:if>
       </xsl:for-each>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>

One scripting functoid, "Inline XSLT Call Template" with no input or output, containing a variable which select attribute points at the template with the node set to calculate

<xsl:variable name="var:MaxValueDate">
    <xsl:call-template name ="GetMax">
            <xsl:with-param name ="nodes" select="Root//Parent/ValueToCalculate" />
    </xsl:call-template>
</xsl:variable>

One scripting functoid, "Inline XSLT" with one output, using the variable to populate an output element with its value.

<OutputElement>
        <xsl:value-of select="$var:MaxValueDate" />
</OutputElement>

Voila!

Martin Bring