Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed improvement for getAnnotationsOnPage #427

Merged
merged 1 commit into from
Sep 12, 2024
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
12 changes: 8 additions & 4 deletions add/data/xql/getAnnotationsOnPage.xql
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ declare function local:findAnnotations($edition as xs:string, $uri as xs:string,

(: TODO: search in other documents and in other collections :)
(: TODO: check if annotations hold URIs or IDRefs :)
functx:distinct-deep(
let $annots := collection(eutil:getPreference('edition_path', $edition))//mei:annot
let $ret :=
for $id in $elemIds

let $uriPlusId := concat($uri, '#', $id)

let $hashId := '#' || $id

(: all mei:annot elements in the editions 'edition_path' collection :)
let $annots := collection(eutil:getPreference('edition_path', $edition))//mei:annot

return
(:
Expand All @@ -124,7 +124,7 @@ declare function local:findAnnotations($edition as xs:string, $uri as xs:string,
:)
$annots[contains(@plist, $uriPlusId)][$uriPlusId = tokenize(@plist, '\s')] |
$annots[contains(@plist, $hashId)][$hashId = tokenize(@plist, '\s')]
)
return functx:distinct-deep($ret)
};

(:~
Expand Down Expand Up @@ -232,7 +232,11 @@ let $measureLike :=
for $id in $zones[@type = 'measure' or @type = 'staff']/string(@xml:id)
let $ref := concat('#', $id)
return
$mei//*[$ref = tokenize(@facs, '\s')]
(:
: The first predicate with `contains` is just a rough estimate to narrow down the result set.
: It uses the index and is fast while the second (exact) predicate is generally too slow
:)
$mei//*[contains(@facs, $ref)][$ref = tokenize(@facs, '\s+')]

let $svgLike := $surface//svg:svg

Expand Down