累积最大值,为每个父记录计算 [英] Cumulative Maximum, calculate for every parent record

查看:64
本文介绍了累积最大值,为每个父记录计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人使用累积最大仿函数并注意到性能问题吗?

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.

检查xslt会发现对每个循环记录都进行了最大计算...

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

一个人可以将计算移到祖父母,并在自定义XSL路径"中指出新的xslt,但我真的很想保留在映射工具中进行映射的可能性.

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.

有什么建议吗?

亲切问候
马丁·布林

Kind Regards
Martin Bring

http://martinbring.blogspot.com

推荐答案

通过删除累积最大值"并添加3个脚本函子,以另一种方式进行计算,可以解决此问题.映射时间减少了40倍.

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.

以前在200分钟内映射的11 Mb,10,000行,现在在5分钟内映射.

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

解决方案
一个没有输入或输出的脚本功能,内联XSLT调用模板",包含来自EXSLT

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>

一个脚本类函数无输入XSLT内联XSLT调用模板",其中没有输入或输出,其中包含一个变量,该变量在模板上设置了属性点,并设置了要计算的节点

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>  

一个脚本类功能"Inline XSLT"具有一个输出,使用该变量将其值填充到输出元素中.

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!

这篇关于累积最大值,为每个父记录计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆