Skip to content

[fix] fn:random-number-generator#1 spec compliant#3916

Draft
line-o wants to merge 7 commits intoeXist-db:developfrom
line-o:fix/3915
Draft

[fix] fn:random-number-generator#1 spec compliant#3916
line-o wants to merge 7 commits intoeXist-db:developfrom
line-o:fix/3915

Conversation

@line-o
Copy link
Member

@line-o line-o commented Jun 3, 2021

Description:

Seeded random-number-generators must be reproducible within a single execution context and are recommended to be reproducible across executions, too.

By using the same efficient hashing algorithm djb2 on the string representation of any atomic value we achieve
both goals with any atomic types given as the seed.

Reference:

XQuery specification: https://www.w3.org/TR/xpath-functions-31/#func-random-number-generator

fixes #3915
fixes #3912

Type of tests:

XQsuite tests

@line-o line-o marked this pull request as draft June 3, 2021 17:40
@line-o line-o added this to the eXist-5.3.1 milestone Jul 1, 2021
@adamretter adamretter modified the milestones: eXist-5.3.1, eXist-5.3.2 Dec 16, 2021
@adamretter adamretter modified the milestones: eXist-5.3.2, eXist-6.0.2 Feb 14, 2022
@adamretter adamretter modified the milestones: eXist-6.0.2, eXist-6.1.1 Jan 15, 2023
@adamretter adamretter modified the milestones: eXist-6.1.1, eXist-7.0.1 Feb 4, 2023
@line-o line-o modified the milestones: eXist-7.0.1, eXist-7.0.0 Mar 12, 2026
@line-o line-o added the xquery issue is related to xquery implementation label Mar 12, 2026
@line-o line-o added this to v7.0.0 Mar 12, 2026
line-o added 3 commits March 12, 2026 19:03
Test all allowed seed types and also rejections.
random-number-generator finally accepts all AtomicTypes as seeds.
All seeds will be turned to strings and then hashed with djb2.
This algorithm is a good trade-off in terms of spread and speed.
The overall performance increase is significant.
Test runs with this simple approach are 20% faster
than even checking the type and switching the method
based on that type.
- all method arguments marked final
- use new switch where possible and useful
- remove redundant final keyword for static methods which cannot be overridden
- replace old non-javadoc comment blocks with @OverRide annotation
@line-o line-o changed the title [test] extend tests for fn:random-number-generator#1 [fix] fn:random-number-generator#1 spec compliant Mar 12, 2026
@line-o
Copy link
Member Author

line-o commented Mar 12, 2026

I will not attempt to fix one of the complexity issues that codacy reports. These functions are hot code and should be handled with utmost care.

@line-o line-o moved this to In progress in v7.0.0 Mar 12, 2026
@line-o
Copy link
Member Author

line-o commented Mar 12, 2026

I am a little surprised to see that the numbers from the XQTS runner workflow do not seem to match with my local run

local

Tests Failures Errors Skipped Success rate Time
31815 3681 188 1259 87.84% 203.684

GHA previous

Tests Failures Errors Skipped Success rate Time
31815 3736 190 1185 ?? 549.3731

GHA current

Tests Failures Errors Skipped Success rate Time
31815 3735 190 1185 ?? 635.1577

@line-o
Copy link
Member Author

line-o commented Mar 12, 2026

The skips are very different. Maybe we are still using a version of XQTS runner that does not skip static typing?

@line-o
Copy link
Member Author

line-o commented Mar 12, 2026

And once #6128 is merged I will have to rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

xquery issue is related to xquery implementation

Projects

Status: In progress

2 participants