RE: DN-FO-09: 15.1.11 fn:distinct-values

--- Michael Rys <mrys@microsoft.com> wrote:
> Being able to have fn:distinct-values return the values
> implementation-dependent provides for better performance for this often
> performance critical operation. Thus I would be strongly against
> mandating an order.

Right now, because of ensuring this possibility for better performance, it has
become problematic to provide a correct example what this function really returns.

The example in the document says:

             "fn:distinct-values(1, 2.0, 3, 2) returns (1, 3, 2.0)"
       
Actually:
             fn:distinct-values(1, 2.0, 3, 2) *might return* (1, 3, 2.0)

At least this needs to be corrected in the document. Your reply does not mention the
issue with the example.


> 
> If you need to preserve order you have the following options:
> 
> - Write your own function that does so
> - Lobby your favorite vendor to provide the functionality
> - Lobby for the next version of XQuery/XPath to provide this
> functionality.
> 
> In order to do any of the last two, you would need to provide some
> compelling use cases.

I have an use case ready:

The sequence is a sequence of random numbers. I want to get rid of the duplicates,
but otherwise preserve the order. This is essential, because a random sequence:


  "3 1 5 2 4 9 6 5 8 10 7"

transformed always to:

  "1 2 3 4 5 6 7 8 9 10"

is really useless.


Best regards,

Dimitre Novatchev.





> 
> Best regards
> Michael
> 
> > -----Original Message-----
> > From: public-qt-comments-request@w3.org [mailto:public-qt-comments-
> > request@w3.org] On Behalf Of Dimitre Novatchev
> > Sent: Monday, June 23, 2003 10:59 AM
> > To: public-qt-comments@w3.org
> > Subject: DN-FO-09: 15.1.11 fn:distinct-values
> > 
> > 
> > DN-FO-09: 15.1.11 fn:distinct-values
> > 
> > There are two issues with this function:
> > 
> > 1. This function is of little use because "The order of the values
> > returned
> > is implementation dependent".
> >    The programmer will not be able to find the answer to the following
> two
> > questions:
> > 
> > 	* Which values and in what order are exactly returned?
> > 	* What should we do if we need to preserve order in the result?
> > 
> > 
> > 2.    The example is wrong:
> >             "fn:distinct-values(1, 2.0, 3, 2) returns (1, 3, 2.0)"
> >       Actually:
> >             fn:distinct-values(1, 2.0, 3, 2) might return (1, 3, 2.0)
> > 
> > 	because the order in which the values are returned is
> implementation
> > dependent.
> > 
> > Suggested solution:
> > 	Change the semantics of the function to return each first in
> > sequence order
> > distinct value.
> > 
> > Dimitre Novatchev.
> > 
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Received on Tuesday, 24 June 2003 00:25:53 UTC