Bugs item #1991738, was opened at 2008-06-12 11:30
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=1991738&group_id=56967

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: PF/compiler
Group: Pathfinder 0.24
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Wouter Alink (vzzzbx)
Assigned to: Nobody/Anonymous (nobody)
Summary: XQ: compilation or runtime choice

Initial Comment:
(stable nightly build, compiled from supersourcetarball, June 11, 2008)

The following query takes about 35 minutes to compile (and I have reason to 
believe it was also the reason why the machine crashed after it was executed a 
few times):

for $run in pf:collection("log.xml")//run
let $successCount := if ($run/success) then count($run/success/task) else 0
let $failureCount := if ($run/failure) then count($run/failure/task) else 0
let $nooutputCount := if ($run/nooutput) then (if ($run/nooutput/@count) then 
zero-or-one($run/nooutput/@count) else 0) + count($run/nooutput/task) else 0
let $totalTasks := $successCount + $failureCount + $nooutputCount
return <run>
           { $run/@tool }
           { for $v in $run/prepared/date/@unixtime[. > 0] return attribute 
preparation {$v  - exactly-one($run/started/date/@unixtime)} }
           { for $v in $run/executed/date/@unixtime[. > 0] return attribute 
execution {$v  - exactly-one($run/prepared/date/@unixtime)} }
           { for $v in $run/validated/date/@unixtime[. > 0] return attribute 
validation {$v  - exactly-one($run/executed/date/@unixtime)} }
           { for $v in $run/committed/date/@unixtime[. > 0] return attribute 
commit {$v  - exactly-one($run/validated/date/@unixtime)} }
           { for $v in $run/prepared/date/@unixtime[. > 0 and $totalTasks > 0] 
return attribute preparationPerTask {($v  - 
exactly-one($run/started/date/@unixtime)) div $totalTasks} }
           { for $v in $run/executed/date/@unixtime[. > 0 and $totalTasks > 0] 
return attribute executionPerTask {($v  - 
exactly-one($run/prepared/date/@unixtime)) div $totalTasks} }
           { for $v in $run/validated/date/@unixtime[. > 0 and $totalTasks > 0] 
return attribute validationPerTask {($v  - 
exactly-one($run/executed/date/@unixtime)) div $totalTasks} }
           { for $v in $run/committed/date/@unixtime[. > 0 and $totalTasks > 0] 
return attribute commitPerTask {($v  - 
exactly-one($run/validated/date/@unixtime)) div $totalTasks} }
           {attribute allowedExecution {exactly-one($run/allowedExecutionTime) 
* 1000}}
           {attribute successCount {$successCount}}
           {attribute failureCount {$failureCount}}
           {attribute nooutputCount {$nooutputCount}}
           {attribute totalTasks {$totalTasks}}
       </run>


but, as you might have noticed the query is not written  in a very nice way... 
Therefore i tried to rewrite the query to the (hopefully) equivalent:

for $run in pf:collection("log.xml")//run
let $successCount := count($run/success/task)
let $failureCount := count($run/failure/task)
let $nooutputCount := if ($run/nooutput/@count) then 
exactly-one($run/nooutput/@count) cast as xs:integer else 0 + 
count($run/nooutput/task)
let $totalTasks := ($successCount + $failureCount + $nooutputCount) cast as 
xs:integer

let $started := $run/started/date/@unixtime cast as xs:integer?
let $prepared := $run/prepared/date/@unixtime cast as xs:integer?
let $executed := $run/executed/date/@unixtime cast as xs:integer?
let $validated := $run/validated/date/@unixtime cast as xs:integer?
let $committed := $run/committed/date/@unixtime cast as xs:integer?

return element { "run" } {
  $run/@tool,

  if ($prepared > 0) then attribute preparation { $prepared  - $started } else 
(),
  if ($executed > 0) then attribute execution { $executed  - $prepared } else 
(),
  if ($validated > 0) then attribute validation { $validated  - $executed } 
else (),
  if ($committed > 0) then attribute commit { $committed  - $validated } else 
(),
  if ($totalTasks > 0)
  then
    (if ($prepared > 0) then attribute preparationPerTask { ($prepared  - 
$started) div $totalTasks } else (),
    if ($executed > 0) then attribute executionPerTask { ($executed  - 
$prepared) div $totalTasks } else (),
    if ($validated > 0) then attribute vaalidationPerTask { ($validated  - 
$executed) div $totalTasks } else (),
    if ($committed > 0) then attribute commitPerTask { ($committed  - 
$validated) div $totalTasks } else ())
  else
    (), 
  attribute allowedExecution {exactly-one($run/allowedExecutionTime) * 1000},
  attribute successCount {$successCount},
  attribute failureCount {$failureCount},
  attribute nooutputCount {$nooutputCount},
  attribute totalTasks {$totalTasks}
}


This query compiles within seconds, but then the runtime environment complains:

MAPI  = [EMAIL PROTECTED]
QUERY = for $run in pf:collection("log.xml")//run
ERROR = !ERROR: merged_union: tail of first BAT/column of table 2 must be 
sorted.
        !ERROR: CMDmerged_union: operation failed.

Unfortunately I cannot provide the log.xml-document, but when leaving out the 
if-statement:
"if ($totalTasks > 0) then ... else ()"
the query executes fine. 
p.s. This workaround works for us at the moment.





----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=1991738&group_id=56967

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-bugs

Reply via email to