Changes

Jump to navigation Jump to search
570 bytes added ,  09:54, 1 March 2017
The following implementation-defined annotations are available:
* {{Code|%basex:inline([limit])}} enforces controls if functions will be inlined. If XQuery functions are ''inlined'', the function call will be replaced by a FLWOR expression, in which the function variables are bound to let clauses, and in which the function body is returned. This optimization triggers further query rewritings that will speed up your query. An example: '''Query:''' <pre class="brush:xquery">declare function local:square($a) { $a * $a };for $i in 1 to 3return local:square($i)</pre> '''Query after function inlining of :''' <pre class="brush:xquery">for $i in 1 to 3return let $a := $i return $a * $a function</pre> '''Query after further optimizations:''' <pre class="brush:xquery">for $i in 1 to 3return $i * $i</pre> By default, XQuery functions will be ''inlined'' if the query body does not exceed the value assigned to the {{Option|INLINELIMIT}} option.  The annotation can be used to overwrite this global limit: Function inlining limit can be enforced if no argument is specified as argument. Inlining can will be disabled by specifying if {{Code|0}}is specified.
'''Example:'''
<pre class="brush:xquery">
(: disable function inlining; the full stack trace will be shown... :)
declare %basex:inline(0) function local:e() { error() };
local:e()
- query.xq, 2/9
</pre>
 
In the next example, function inlining was disabled globally by assigning {{Code|0}} to the [[Options#INLINELIMIT|INLINELIMIT]] option. However, annotation is enforced to a single function:
 
'''Example:'''
<pre class="brush:xquery">
declare option db:inlinelimit '0';
declare %basex:inline function local:id($x) { $x };
local:id(123)
</pre>
 
The query will be optimized to {{Code|123}}.
* {{Code|%basex:lazy}} enforces the lazy evaluation of a global variable. Example:
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu