Skip to content

refactor(query): decouple kgram execution engine from next query ast (#568) - #577

Merged
remiceres merged 3 commits into
feature/corese-nextfrom
feature/568-decouple-kgram-next-query
Sep 8, 2026
Merged

refactor(query): decouple kgram execution engine from next query ast (#568)#577
remiceres merged 3 commits into
feature/corese-nextfrom
feature/568-decouple-kgram-next-query

Conversation

@remiceres

Copy link
Copy Markdown
Contributor

Summary

Decouple fr.inria.corese.core.next.query and its internal KGRAM execution engine from legacy Corese v4 packages (fr.inria.corese.core.kgram.* and fr.inria.corese.core.sparql.*), eliminate temporary bridge adapters, and resolve all SonarLint code smells and cognitive complexity issues across the module.

Resolves #568

Architecture and Implementation Highlights

1. Complete Decoupling from Legacy IDatatype and Packages

• Replaced fr.inria.corese.core.sparql.api.IDatatype with fr.inria.corese.core.next.data.api.model.DatatypeValue across the internal KGRAM execution engine (next.query.impl.kgram).
• Introduced DatatypeValue and RdfValueOrder public contracts in core.next.data.
• Standardized total ordering rules conforming to SPARQL total order specifications.
• Validated by NextModuleBoundaryTest with 0 legacy imports in next.query.

2. Elimination of Compatibility Bridges and Native AST Evaluation

• Removed obsolete bridge classes: BindingAdapter, DatatypeAdapter, KgramNodeConverter, NextDatatypeValueAdapter, SparqlAstToExpression, SparqlBuiltinFunctionNameResolver, StorageManagerKgramValues.
• Introduced specialized native expression evaluators in next.query.impl.sparql.bridge:

  • NativeNumericExpressionEvaluator: arithmetic and numeric comparisons
  • NativeStringExpressionEvaluator: string operations and regex matching
  • NativeBooleanExpressionEvaluator: boolean logic and effective boolean value evaluation
  • NativeTemporalExpressionEvaluator: date/time extraction and calculations
  • NativeIriExpressionEvaluator: IRI validations and conversions
  • SparqlTermResolver: resolution and conversion between AST terms and Next data model
    • Simplified WhereCompiler, AstBackedExpr, and CoreseAstQueryBuilder.

3. Code Quality and SonarLint Remediation

• Resolved all 309 SonarLint code smells and bugs across all 86 files in corese-core.
• Reduced cognitive complexity under the threshold (< 15) in critical engine methods (PathFinder, Mappings, Eval, Query, Exp, BasicPatternGenerator, HeuristicsBasedEstimation).
• Documented all internal KGRAM subpackages with package-info.java.

Quality and Conformance Verification

• Internal unit tests (corese-core): 100% passing (./gradlew test).
• W3C Conformance suite (corese-w3c): 2,859 test cases evaluated against feature/corese-next baseline with exactly 0 regressions.
• Architectural boundary rules (NextModuleBoundaryTest): 100% compliant.

…568)

- Replace legacy IDatatype with DatatypeValue across next.query.impl.kgram
- Introduce native expression evaluators in next.query.impl.sparql.bridge
- Remove legacy bridging adapters (BindingAdapter, DatatypeAdapter, KgramNodeConverter, SparqlAstToExpression, StorageManagerKgramValues)
- Add DatatypeValue and RdfValueOrder contracts to next.data
- Enforce clean module boundaries with NextModuleBoundaryTest
… warnings (#568)

- Add package-info.java documentation across all next.query.impl.kgram subpackages
- Comply with SonarLint rule S1228 across the module
@remiceres remiceres added the Refactoring Issue created during the 2025 refactoring effort label Sep 7, 2026
@remiceres remiceres self-assigned this Sep 7, 2026
@remiceres
remiceres merged commit e3165ba into feature/corese-next Sep 8, 2026
1 check passed
@remiceres
remiceres deleted the feature/568-decouple-kgram-next-query branch September 8, 2026 07:34
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Overall Project 52.83% -1.66% 🍏
Files changed 34.98%

File Coverage
Value.java 100% 🍏
Evaluator.java 100% 🍏
WhereCompiler.java 100% 🍏
CoreseAstQueryBuilder.java 90.93% -2.59% 🍏
NextSparqlPipelineExecutor.java 88.83% -6.78% 🍏
CoreseRepository.java 84.68% -14.52%
Checker.java 82.84% -7.1% 🍏
QueryPrologueAst.java 77.78% 🍏
CoreseUpdate.java 77.23% -4.7% 🍏
RdfValueOrder.java 74.85% -25.15% 🍏
KgramNodes.java 74.16% -1.12% 🍏
StorageManagerEdge.java 73.47% 🍏
NodeImpl.java 72.16% -21.99% 🍏
NextFilterFromAst.java 71.43% -22.22% 🍏
SparqlKgramEvaluator.java 68% 🍏
NativeEvaluationContext.java 64.81% -35.19% 🍏
Query.java 62.72% -5.75%
SparqlTermResolver.java 61.99% -38.01% 🍏
StorageManagerProducer.java 59.71% -1.98% 🍏
CoreseBindingSet.java 49.3% -38.03%
DatatypeValue.java 48.62% -51.38%
AstBackedExpr.java 46.83% -52.57%
Mappings.java 40.32% -14.24%
Exp.java 39.25% -12.68%
Memory.java 39.06% -12.6%
ProcessVisitor.java 38.46% 🍏
FilterPattern.java 38.04% 🍏
Extern.java 37.9% -20.16%
NativeExpressionEvaluator.java 37.5% -62.5%
NativeBooleanExpressionEvaluator.java 36.38% -63.62%
NativeNumericExpressionEvaluator.java 34.02% -65.98%
Producer.java 33.33% 🍏
Eval.java 32.53% -10.66%
NativeValueComparison.java 27.85% -72.15%
Compile.java 27.34% -10.98%
NativeStringExpressionEvaluator.java 25.63% -74.37%
Mapping.java 25.57% -0.72%
JavaDScall.java 22.99% -13.79%
ProducerDefault.java 6.45% 🍏
Edge.java 6.12% 🍏
NativeTemporalExpressionEvaluator.java 5.92% -94.08%
ProcessVisitorDefault.java 5.62% -6.74%
ApproximateSearchEnv.java 5.1% -35.67%
CompleteSPARQL.java 4.58% -26.41%
EvalGraph.java 4.11% -48.42%
EvalJoin.java 2.93% -24.15%
EvalSPARQL.java 2.65% -19.55%
EnvironmentImpl.java 2.38% -1.59%
PathFinder.java 0% -38.1%
PointerType.java 0% -3.23%
Node.java 0% -30.77%
Filter.java 0% 🍏
BindingContext.java 0% 🍏
Expr.java 0% -71.43%
EventImpl.java 0% -41.03%
Environment.java 0% 🍏
NativeIriExpressionEvaluator.java 0%
BasicPatternGenerator.java 0% -43.88%
HeuristicsBasedEstimation.java 0% -46.11%
IterableEntity.java 0% -98.41%
Checker.java 0% -24.11%

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

Labels

Refactoring Issue created during the 2025 refactoring effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant