Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 37 additions & 25 deletions src/main/xar-resources/modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -73,68 +73,80 @@ function app:browse($module as xs:string?) as map(*) {
return map { "result": $module//xqdoc:function }
};

(:
: The search functions below all distribute `$app:data//` over the
: top-level union branches rather than nesting the union inside a
: parenthesised step expression. Both forms are semantically equivalent,
: but the parenthesised form `$app:data//(A | B)` defeats the structural
: index fast path: at runtime the engine materialises the full descendant
: axis under each `$app:data` root and applies the union as a generic
: step expression, instead of dispatching each branch by qname through
: the structural index. The split form `$app:data//A | $app:data//B` is
: ~10x faster on a typical xqdoc corpus and scales linearly in branch
: count rather than in (branches x descendants).
:
: See https://github.com/eXist-db/exist/pull/6303 for the upstream
: optimiser-side companion fix that handles the related single-step
: `//(name)` shape.
:)

declare %private
function app:search-in-module-location($q as xs:string?) as map(*) {
map {
"result": $app:data//(
xqdoc:control[contains(xqdoc:location, $q)]/..//xqdoc:function
)
"result":
$app:data//xqdoc:control[contains(xqdoc:location, $q)]/..//xqdoc:function
}
};

declare %private
function app:search-in-module-name($q as xs:string?) as map(*) {
map {
"result": $app:data//(
xqdoc:module[contains(xqdoc:uri, $q)]/..//xqdoc:function
)
"result":
$app:data//xqdoc:module[contains(xqdoc:uri, $q)]/..//xqdoc:function
}
};

declare %private
function app:search-in-description($q as xs:string?) as map(*) {
map {
"result": $app:data//(
xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
"result":
$app:data//xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
|
xqdoc:module[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
)
$app:data//xqdoc:module[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
}
};

declare %private
function app:search-in-signature($q as xs:string?) as map(*) {
map {
"result": $app:data//(
xqdoc:function[ngram:contains(xqdoc:name, $q)]
"result":
$app:data//xqdoc:function[ngram:contains(xqdoc:name, $q)]
|
xqdoc:function[ngram:contains(xqdoc:signature, $q)]
)
$app:data//xqdoc:function[ngram:contains(xqdoc:signature, $q)]
}
};

declare %private
function app:search-everywhere($q as xs:string?) as map(*) {
map {
"result": $app:data//(
xqdoc:function[ngram:contains(xqdoc:name, $q)]
"result":
$app:data//xqdoc:function[ngram:contains(xqdoc:name, $q)]
|
xqdoc:function[ngram:contains(xqdoc:signature, $q)]
$app:data//xqdoc:function[ngram:contains(xqdoc:signature, $q)]
|
xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
$app:data//xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
|
xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:param, $q)]
$app:data//xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:param, $q)]
|
xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:return, $q)]
$app:data//xqdoc:function[ngram:contains(xqdoc:comment/xqdoc:return, $q)]
|
xqdoc:control[contains(xqdoc:location, $q)]/..//xqdoc:function
$app:data//xqdoc:control[contains(xqdoc:location, $q)]/..//xqdoc:function
|
xqdoc:module[contains(xqdoc:uri, $q)]/..//xqdoc:function
$app:data//xqdoc:module[contains(xqdoc:uri, $q)]/..//xqdoc:function
|
xqdoc:module[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
$app:data//xqdoc:module[ngram:contains(xqdoc:comment/xqdoc:description, $q)]
|
xqdoc:module[ngram:contains(xqdoc:name, $q)]/..//xqdoc:function
)
$app:data//xqdoc:module[ngram:contains(xqdoc:name, $q)]/..//xqdoc:function
}
};

Expand Down