[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XQuery/XPath 3.1: Node List to Node Set ("distinct

Subject: Re: XQuery/XPath 3.1: Node List to Node Set ("distinct nodes")
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 29 Dec 2021 00:10:30 -0000
Re:  XQuery/XPath 3.1: Node List to Node Set ("distinct
> On 28 Dec 2021, at 23:54, Dimitre Novatchev dnovatchev@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>
>    $nodes[index-of($nodes ! generate-id(.), generate-id(.))[1]]
>
> This seems a candidate for "the shortest solution" and it shouldn't be
inefficient, given a good optimizer:
>

It probably also gets a prize for the first practical use case of a filter
expression where the predicate is numeric and has different values for
different nodes in the input sequence.

It's going to be O(n*m) unless index-of() is optimized to use some kind of
index or hash lookup rather than a sequential search. That's assuming that the
expression $nodes ! generate-id(.) gets loop-lifted; if it isn't, then it
becomes O(n*n*m).

Aesthetically, I find generate-id() ugly and it would be nice to avoid it.

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.