<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29918</bug_id>
          
          <creation_ts>2016-10-06 16:40:49 +0000</creation_ts>
          <short_desc>[FO31] map:find ordering constraint prevents streaming evaluation</short_desc>
          <delta_ts>2016-12-16 19:55:39 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Functions and Operators 3.1</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Josh Spiegel">josh.spiegel</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>andrew_coleman</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>127672</commentid>
    <comment_count>0</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2016-10-06 16:40:49 +0000</bug_when>
    <thetext>Step 3 in the definition of map:find:

&lt;quote&gt;
To process an item that is a map, perform both of the following steps, in order:

 a. If the map contains a key-value entry (K, V) where K is the same key as $key, then add V as a new member to the end of the result array.

 b. For each key-value entry (K, V) in the map (in ·implementation-dependent· order), process V (which is, in general, a sequence).
&lt;/quote&gt;

The requirement that a matching entry be added to the result first blocks any hope of streaming evaluation.  I would like the working group to consider making the order implementation-dependent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127833</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-10-18 15:28:44 +0000</bug_when>
    <thetext>The WG discussed the bug in Josh&apos;s absence and was unconvinced by the rationale, but we are leaving it open so Josh can argue the case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127988</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-10-31 18:01:54 +0000</bug_when>
    <thetext>I&apos;m not convinced that there is a requirement for streamed evaluation of maps, since I think they are by their nature direct-access data structures. However, if we accept this requirement we could change the rule to read:

&lt;quote&gt;
To process an item that is a map, then for each key-value entry (K, V) in the map (in ·implementation-dependent· order), perform both the following steps, in order:

 a. If K is the same key as $key, then add V as a new member to the end of the result array.

 b. Process V (which is, in general, a sequence).
&lt;/quote&gt;

We could also relax the rules on ordering further, but this goes explicitly against a previous decision of the WG which wanted the order to be as predictable as possible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127989</commentid>
    <comment_count>3</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2016-10-31 18:59:19 +0000</bug_when>
    <thetext>I think that streaming JSON processing is a valid use case, just like streaming XML is.  The working group has made previous decisions in similar cases to facilitate streaming JSON processing so it would not make sense to change direction just for this function.  Further, imposing a partial ordering here isn&apos;t useful since the entries are already unordered.  So, relaxing the ordering constraints here does not hurt interoperability in a meaningful way.

I agree that the change proposed in comment 2 would resolve this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128008</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-11-01 16:53:33 +0000</bug_when>
    <thetext>The changes were agreed and have been applied.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>