Optimization issue? - maps and count
Friday, 6 December 2019 · 2 messages
JE
Johannes Echterhoff6 Dec 2019 17:17 #
All,
The following query:
let $lookupSequence := ('a','b')
let $map := map {'c': 'x'}
let $mapLookupEvaluation := $map?($lookupSequence)
return
(
'Evaluation of the map lookup is: ' || string-join($mapLookupEvaluation,", "),
'count($mapLookupEvaluation) is: ' || count($mapLookupEvaluation)
)Results in:
Evaluation of the map lookup is:
count($mapLookupEvaluation) is: 2
I would have expected 0 instead of 2. Am I missing something?
Best regards,
Johannes
CG
Christian Grün6 Dec 2019 18:06 #
Hi Johannes,
You’ve found a little bug that was introduced more than two years ago (a wrong static type was attached to the map constructor; we ignored the fact that a map lookup may yield an empty sequence). A new snapshot is available [1,2].
Thanks for the report,
Christian
[1] https://github.com/BaseXdb/basex/issues/1766
[2] http://files.basex.org/releases/latest/
Quoted text · Johannes Echterhoff · 40 lines
On Fri, Dec 6, 2019 at 5:18 PM Johannes Echterhoff <echterhoff at interactive-instruments.de> wrote: > > All, > > The following query: > > > > let $lookupSequence := ('a','b') > > let $map := map {'c': 'x'} > > let $mapLookupEvaluation := $map?($lookupSequence) > > return > > ( > > 'Evaluation of the map lookup is: ' || string-join($mapLookupEvaluation,", "), > > 'count($mapLookupEvaluation) is: ' || count($mapLookupEvaluation) > > ) > > > > Results in: > > Evaluation of the map lookup is: > > count($mapLookupEvaluation) is: 2 > > > > I would have expected 0 instead of 2. Am I missing something? > > Best regards, > > Johannes
Written for BaseX 9.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery