async module vs xq-promise
Thursday, 24 March 2016 · 2 messages · last reply 28 Mar 2016
MG
Maximilian Gärber24 Mar 2016 14:43 #
Hi all,
I just started to use the async module and I guess I am out of sync about the relation to xq-promise:
Basex now has asyn:fork-join which exectues in parallel and comes back with all results
xq-promise has p:fork-join which seems to be the previous implementation
Could I swap one for the other?
Side note: async:eval which works like
xquery:eval is great, but I have to do something like this for functions:let $ids := async:eval("declare variable $f external; declare variable
$name external; $f($name)", map { 'f': '_:get-meta', 'name' : $name })
return $idsWith get-meta being a local function that accepts a single parameter. Is there an easier way to do this?
Regards,
Max
CG
Christian Grün28 Mar 2016 13:21 #
Hi Max,
Quoted text · Maximilian Gärber · 2 lines
> xq-promise has p:fork-join which seems to be the previous implementation > Could I swap one for the other?
Right! A side note: I have slightly extended our documentation, because I guess it was not clearly to everyone what’s the difference between parallel and asynchronous execution [1].
Quoted text · Maximilian Gärber · 7 lines
> let $ids := async:eval("declare variable $f external; declare variable > $name external; $f($name)", map { 'f': '_:get-meta', 'name' : $name }) > return $ids > ``` > > With get-meta being a local function that accepts a single parameter. > Is there an easier way to do this?
Hm. If you have a single argument, you could bind it to the context item:
async:eval(".", map { '': $var })If you have several variables, it may be better to write an extra function, which prefixes your query with additional variable declarations (see e.g. here: [2]).
Best,
Christian
[1] http://docs.basex.org/wiki/Async_Module
[2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/modules/util.xqm#L78-L96
Quoted text · Maximilian Gärber · 5 lines
> > > Regards, > > Max
Written for BaseX 8.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery