Saxon 9.6.0.5 giving different output from Saxon 9.5.1.7 for counts involving union ()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Saxon 9.6.0.5 giving different output from Saxon 9.5.1.7 for counts involving union ()

David Rudel
Was there a change to the XPath specification that would modify the correct results for a calculation using the "union ()" idiom?

I am getting different results with Saxon 9.6.0.5 versus Saxon 9.5.1.7, and Saxon 9.6.0.5 is taking about twice as long. 

The particular structure giving a different result is

f_y="{count((for $c in $y.chains return key('connection.chain.key',$c/@id,$connection.table)) union ())}"

If there is no reason why this type of structure should give a different result in Saxon 9.6.0.5 versus Saxon 9.5.1.7, I'll write up a repro.

-David

--

"A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.

------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Saxon 9.6.0.5 giving different output from Saxon 9.5.1.7 for counts involving union ()

Michael Kay
No, I don’t think there’s been any change in the spec here. More likely to be an optimizer bug (in either the old or the new release!)

I think your expression could be rewritten as

{count(key(‘connection.chain.key’, $y.chains/@id, $connection.table))}

I’ll be hapy to look at a repro for this.

Michael Kay
Saxonica


> On 27 Oct 2015, at 00:01, David Rudel <[hidden email]> wrote:
>
> Was there a change to the XPath specification that would modify the correct results for a calculation using the "union ()" idiom?
>
> I am getting different results with Saxon 9.6.0.5 versus Saxon 9.5.1.7, and Saxon 9.6.0.5 is taking about twice as long.
>
> The particular structure giving a different result is
>
> f_y="{count((for $c in $y.chains return key('connection.chain.key',$c/@id,$connection.table)) union ())}"
>
> If there is no reason why this type of structure should give a different result in Saxon 9.6.0.5 versus Saxon 9.5.1.7, I'll write up a repro.
>
> -David
>
> --
>
> "A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Saxon 9.6.0.5 giving different output from Saxon 9.5.1.7 for counts involving union ()

David Rudel
Hey Mike,

Here is a repro.
The expected behavior is for count_1, count_2, and count_3 to all give the same result.

In this repro, count_1 differs from the other 2 in the case of x=3073 or x=3099.  count_1 is wrong because it is double-counting cases where a node shows up in the list. Duplicates are not being removed.

I noticed in some more complex cases that count_2 and count_3 were also giving different values, so that {count($seq)} was giving values greater than {count($seq union $seq)}.

stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/" xmlns:exsl="http://exslt.org/common" xmlns:chain="chain"
   exclude-result-prefixes="xs saxon">
<xsl:variable name="path" select="replace(base-uri(),'(.*/)[^/]+?.xml','$1')"/>
   
   <xsl:key name="single.link.key" match="chains/chain" use="l/xs:integer(@link)"/>
   
   <xsl:key name="connection.chain.key" match="TIDs/TID" use="c!xs:string(@chainID)"/>
     
<xsl:variable name="connection.table">
<TIDs>
<TID id="514">
<c chainID="5"/>
<c chainID="6"/></TID>
<TID id="515">
<c chainID="5"/>
<c chainID="6"/></TID>
<TID id="516">
<c chainID="5"/>
<c chainID="6"/></TID>
</TIDs>
</xsl:variable>
         
   <xsl:template match="/">
      <xsl:variable name="root" select="."/>        
         <data>
            <xsl:for-each select="(3073,3074,3075,3099)">
               <xsl:sort select="."/>
               <xsl:variable name="x" select="."/>
               <xsl:variable name="x.chains" select="key('single.link.key',.,$root)"/>
               <xsl:text>
     </xsl:text>
            <xsl:variable name="x.TIDs" select="(for $c in $x.chains return key('connection.chain.key',$c/@id,$connection.table)) union ()"/>
               <from x="{.}"
                count_1="{count((for $c in $x.chains return key('connection.chain.key',$c/@id,$connection.table)) union ())}"
                count_2="{count($x.TIDs)}"
                count_3="{count($x.TIDs union $x.TIDs)}"
                />
            </xsl:for-each>
         </data>
   </xsl:template>

</xsl:stylesheet>


Source:
<?xml version="1.0" encoding="UTF-8"?>
<chains>
<chain id="5">
<l link="3073"/>
<l link="3075"/>
<l link="3099"/></chain>
<chain id="6">
<l link="3073"/>
<l link="3074"/>
<l link="3099"/></chain>
</chains>


On Tue, Oct 27, 2015 at 10:15 AM, Michael Kay <[hidden email]> wrote:
No, I don’t think there’s been any change in the spec here. More likely to be an optimizer bug (in either the old or the new release!)

I think your expression could be rewritten as

{count(key(‘connection.chain.key’, $y.chains/@id, $connection.table))}

I’ll be hapy to look at a repro for this.

Michael Kay
Saxonica


> On 27 Oct 2015, at 00:01, David Rudel <[hidden email]> wrote:
>
> Was there a change to the XPath specification that would modify the correct results for a calculation using the "union ()" idiom?
>
> I am getting different results with Saxon 9.6.0.5 versus Saxon 9.5.1.7, and Saxon 9.6.0.5 is taking about twice as long.
>
> The particular structure giving a different result is
>
> f_y="{count((for $c in $y.chains return key('connection.chain.key',$c/@id,$connection.table)) union ())}"
>
> If there is no reason why this type of structure should give a different result in Saxon 9.6.0.5 versus Saxon 9.5.1.7, I'll write up a repro.
>
> -David
>
> --
>
> "A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.
> ------------------------------------------------------------------------------
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help



--

"A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.

------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help