Dear all,

my scenario is a RestXQ:

- download resources and store them in temporary directory.

- do it with fork-join in order to obtain smaller latency

- compress to zip archive and return the archive data.

I've noticed often the archive arrives empty. So after investigation I've found that query [1] isnon predictable. It is often optimized to "count(0)".

I can manage to produce results from time to time but not consistently with [2].

[3] Seems the safer solution.

The behavior is the same with 9.x and 10.

Since I do not feel very comfortable, is there someone who can tell me if I'm doing it wrong or if there is a secure solution or if I should abandon fork-join tout-court?

Thanks a lot.

Regards,

Marco.

[1]

let $ops := (
  for $i in (1 to 5)
  let $url := "http://www.google.com";
  return function(){
(file:write(file:create-temp-file("ttt",string($i)),fetch:content-type($url)))
  }
)
let $download := xquery:fork-join($ops)
return count($ops)

[2]

let $ops := (
  for $i in (1 to 5)
  let $url := "http://www.google.com";
  return function(){
(file:write(file:create-temp-file("ttt",string($i)),fetch:content-type($url)),1)
  }
)
let $download := xquery:fork-join($ops)
return count($ops)

[3]

let $ops := xquery:fork-join(
  for $i in (1 to 5)
  let $url := "http://www.google.com";
  return function(){
    (1, file:write(file:create-temp-file("ttt",string($i)),fetch:content-type($url)))
  }
)
return count($ops)


Reply via email to