Changes

Jump to navigation Jump to search
1,642 bytes added ,  04:07, 4 January 2016
Created page with "This article is part of the XQuery Portal. It lists specific extensions and optimizations of the BaseX XQuery processor. =Optimizations= ==Non-determinism== The [h..."
This article is part of the [[XQuery|XQuery Portal]].

It lists specific extensions and optimizations of the BaseX XQuery processor.

=Optimizations=

==Non-determinism==

The [http://www.w3.org/TR/xpath-functions-31/#dt-deterministic XQuery Functions and Operators specification] defines functions that are “guaranteed to produce ·identical· results from repeated calls within a single ·execution scope· if the explicit and implicit arguments are identical” as ''deterministic''. In BaseX, many extension functions are non-deterministic or side-effecting. If an expression is internally flagged as non-deterministic, various optimizations that might change their execution order will not be applied.

<pre class="brush:xquery">
(: QUERY A... :)
let $n := 456
for $i in 1 to 2
return $n

(: ...will be optimized to :)
for $i in 1 to 2
return 456

(: QUERY B will not be rewritten :)
let $n := random:integer()
for $i in 1 to 2
return $n
</pre>

In some cases, functions may contain non-deterministic code, but the query compiler may not be able to detect this statically. See the following example:

<pre class="brush:xquery">
for $read in (file:read-text#1, file:read-binary#1)
let $ignored := non-deterministic $read('input.file')
return ()
</pre>

Two non-deterministic functions will be bound to <code>$read</code>, and the result of the function call will be bound to <code>$ignored</code>. As the variable is not referenced in the subsequent code, the let clause would usually be discarded by the compiler. In the given query, however, execution will be enforced because of the BaseX-specific {{Code|non-deterministic}} keyword.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu