Skip to content

perf(query): optimize temporal filter evaluation and literal decoding (#636) - #641

Merged
remiceres merged 2 commits into
feature/corese-nextfrom
perf/optimize-temporal-filters
Oct 22, 2026
Merged

remiceres merged 2 commits into
feature/corese-nextfrom
perf/optimize-temporal-filters

Conversation

@remiceres

Copy link
Copy Markdown
Contributor

Closes #636

Summary of Changes

  • CoreseDatatype: Replaced reflective Class.forName and Constructor.newInstance with direct constructBuiltin switch for standard XSD datatypes.
  • CoreseDate / CoreseDateTime: Added precomputed epochMillis with fast primitive $\mathcal{O}(1)$ comparison when timezones match, bypassing heavy XMLGregorianCalendar.compare().
  • CoreseStringableImpl: Added lazy cached decoding fields (cachedDateTime and cachedDate) with sentinel, eliminating duplicate parsing across join intermediate tuples. Refactored cast() reducing Cognitive Complexity to < 10.
  • SimpleDate / SimpleDateTime: Singleton DATATYPE_FACTORY eliminating per-instance allocation overhead.
  • NativeCastExpressionEvaluator: Identity short-circuit for already-typed XSDDatatype.DATETIME terms.

Benchmarks & Validation

  • Microbenchmarks: 26.0x faster lazy cached cast (11.6 ns vs 302.2 ns), 1.8x faster epoch long comparison.
  • Bowlogna (1.23M triples): Q3 (61-95ms), Q4 (22-23ms), Q12 (37-49ms), Q16 (176ms), Q17 (18ms).
  • W3C Conformance: 100% SPARQL 1.0 pass, 493/495 SPARQL 1.1 pass (2 documented reference disparities).
  • SonarLint: 0 alerts on modified code.

…#636)

- Replace reflective CoreseDatatype instantiation with fast constructBuiltin switch
- Add fast epochMillis comparison in CoreseDate/CoreseDateTime for equal-timezone operands
- Introduce lazy cached dateTime/date decoding on CoreseStringableImpl
- Use singleton DatatypeFactory in SimpleDate and SimpleDateTime
- Add identity short-circuit for xsd:dateTime cast on already-typed terms
- Clean up unused fields and resolve S1301 switch alerts
@github-actions

Copy link
Copy Markdown
Overall Project 57.89% -0.05% 🍏
Files changed 64.46% 🍏

File Coverage
SimpleDate.java 98.4% 🍏
SimpleDateTime.java 98.4% 🍏
NativeCastExpressionEvaluator.java 82.35% -0.41% 🍏
CoreseDate.java 78.55% -10.91% 🍏
CoreseDatatype.java 69.06% -2.48% 🍏
CoreseDateTime.java 57.58% -30.3% ❌
CoreseStringableImpl.java 34.1% -50.29% ❌

@github-actions

Copy link
Copy Markdown

Test Results

  416 files    416 suites   26s ⏱️
3 355 tests 3 355 ✅ 0 💤 0 ❌
3 389 runs  3 389 ✅ 0 💤 0 ❌

Results for commit 8879895.

… exception handling

- Address Copilot review feedback:
  - Guard CoreseDate.cast(RDF.xsddate) to verify getCode() == DATE before returning this, preventing CoreseDateTime masquerade
  - Widen catch in CoreseDatatype.createDatatype to catch RuntimeException matching legacy reflection behavior
  - Refactor epoch calculation into computeSafeEpoch helper handling specific exceptions
  - Add testCastIdentityAndConversions unit test
@remiceres
remiceres merged commit d2c4e1f into feature/corese-next Oct 22, 2026
1 check passed
@remiceres
remiceres deleted the perf/optimize-temporal-filters branch October 22, 2026 12:03
@github-actions

Copy link
Copy Markdown
Overall Project 57.9% -0.04% 🍏
Files changed 73.35% 🍏

File Coverage
SimpleDate.java 98.4% 🍏
SimpleDateTime.java 98.4% 🍏
CoreseDateTime.java 87.88% 🍏
NativeCastExpressionEvaluator.java 82.35% -0.41% 🍏
CoreseDate.java 81.79% -8.2% 🍏
CoreseDatatype.java 69.06% -2.48% 🍏
CoreseStringableImpl.java 48.55% -35.84% ❌

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant