Improper use or potential bug

Sunday, 22 December 2019 · 3 messages · last reply 23 Dec 2019
FB
France Baril22 Dec 2019 15:48 #
This .xq works the first time when returning db:create. However, once the DB are created, if I run it again, files are note replaced. Instead, I get java.lang.ArrayIndexOutOfBoundsException. I can send the DB in private if necessary for debugging. The result is not exactly an index, it's just flattening a few levels of indirection to make future queries faster. I was testing this on 9.2.3. Also a side question, is there a way to rewrite this query so not all DBs are locked? I get lock: global. I would like to lock only DBs that start with 'index-prompt-' I tried hard coding the prefix in the db:create and db:replace fonctions but that didn't help. Since I will have this running on a loop (cannot catch updated on src DB), I don't want to lock the whole system each time this query is running. It does take a good 12 seconds to run.
(: USAGE:
for $prompt in db:attribute('index-prompt-en-us', 'setup_as_new', 'name')/..
return $prompt => prof:time()
 :)
let $langs :=
   for $lang in db:list()[string-length(.) = 5][substring(., 3, 1) = '-']
   return $lang
return
   for $lang in $langs
   let $index-db := 'index-prompt-' || $lang
   let $prompt-file-name := 'prompts-' || $lang || '.xml'
   let $index := <index>{
      for $string-group in
db:open('global-content')//*[name()='string-group']
      let $prompt-this-lang :=
$string-group/child::*[@xml:lang=$lang][normalize-space(.)!='']
      let $prompt-base :=
         if (exists($prompt-this-lang))
         then $prompt-this-lang
         else $string-group/child::*[@xml:lang='en-us']
       let $p2 :=  db:attribute('global-content', $string-group/data(@key),
'key')/..[name()='prompt'][ancestor::*[last()]/name()='prompt-refs'][@package=$string-group/data(@package)][@pkg-version=$string-group/data(@pkg-version)]
       let $prompts := (
          for $prompt-match in $p2
          return
                copy $copy := $prompt-base
                modify (
                   for $attr in $prompt-match/@*[name()!='package'
                      and name()!='pkg-version' and name()!='key']
                   return insert node $attr into $copy
                )
                return $copy
       )
       return
           $prompts
   }</index>

   return
      if (db:exists($index-db))
      then
          db:replace($index-db, $prompt-file-name, $index)
      else
          db:create($index-db, $index, $prompt-file-name , map {
'updindex': true() })
-- France Baril Architecte documentaire / Documentation architect france.baril at architextus.com
CG
Christian Grün22 Dec 2019 16:12 #
Hi France, Instead, I get java.lang.ArrayIndexOutOfBoundsException.
Quoted text · France Baril · 1 line
>
Could you send us the full stack trace? I was testing this on 9.2.3.
Quoted text · France Baril · 1 line
>
Can the problem be reproduced with 9.3.1?
Quoted text · France Baril · 4 lines
Also a side question, is there a way to rewrite this query so not all DBs > are locked? I get lock: global. I would like to lock only DBs that start > with 'index-prompt-' >
Currently no (unless you explicitly open all those databases in your query). See [1] for more information. Best, Christian [1] http://docs.basex.org/wiki/Transaction_Management#XQuery
FB
France Baril23 Dec 2019 12:53 #
9.3.1 seems to resolve the issue.
Quoted text · Christian Grün · 29 lines
On Sun, Dec 22, 2019 at 4:12 PM Christian Grün <christian.gruen at gmail.com> wrote: > Hi France, > > Instead, I get java.lang.ArrayIndexOutOfBoundsException. >> > > Could you send us the full stack trace? > > I was testing this on 9.2.3. >> > > Can the problem be reproduced with 9.3.1? > > Also a side question, is there a way to rewrite this query so not all DBs >> are locked? I get lock: global. I would like to lock only DBs that start >> with 'index-prompt-' >> > > Currently no (unless you explicitly open all those databases in your > query). See [1] for more information. > > Best, > Christian > > [1] http://docs.basex.org/wiki/Transaction_Management#XQuery > > >
-- France Baril Architecte documentaire / Documentation architect france.baril at architextus.com

⚡Generated with XQuery