Hi, Nice work. I wonder if the BaseX query optimizer could not spot the idioms for the set operations and rewrite the query to something similar for the cases:
distinct-values(($arg1, $arg2)) distinct-values($arg1[.=$arg2]) distinct-values($arg1[not(.=$arg2)])
Regards /Andy
On Wed, Sep 25, 2013 at 8:04 PM, Arve Gengelbach ag@basex.org wrote:
Hej Arto,
One can even improve your map2 by using the [Simple map operator].
declare function local:difference-map-2-excl($a, $b) { let $m2 := map:new($b ! map:entry(., true())) return $a ! (if($m2(.)) then () else .) };
- map 299.47 ms
- map2 290.96 ms
- map2 + ! 128.25 ms
cheers Arve
[Simple map operator] http://www.w3.org/TR/xquery-30/#id-map-operator
Am 25.09.13 10:41 schrieb Arto Viitanen:
-----Original Message----- From: Arve Gengelbach [mailto:ag@basex.org] Sent: 25. syyskuuta 2013 9:08 To: Arto Viitanen Cc: basex-talk@mailman.uni-konstanz.de Subject: Re: [basex-talk] Set Operator Examples
Hej Arto,
just being interested: How does it compare to a FLOWR expression?
declare function local:difference-flowr($a, $b) { for $x in $a where not($x = $b) group by $x return $x[1] };
pred 51787.06 ms map 485.16 ms map2 325.09 ms flowr 45275.97 ms
-- Arto Viitanen Finland
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk