Class FusePathPlusTailAlternationUnionTransform
java.lang.Object
org.eclipse.rdf4j.queryrender.sparql.ir.util.transform.BaseTransform
org.eclipse.rdf4j.queryrender.sparql.ir.util.transform.FusePathPlusTailAlternationUnionTransform
Fuse a path triple followed by a UNION of two single-step tail triples into a single path with an alternation tail.
Shape: - Input: PT: ?s P ?mid . UNION of two branches that each connect ?mid to the same end variable via constant
predicates in opposite directions (forward/inverse), optionally GRAPH-wrapped with the same graph ref. - Output: ?s
P/(p|^p) ?end .
Notes: - Does not fuse across UNIONs marked as new scope (explicit user UNIONs). - Requires the bridge variable
(?mid) to be an
_anon_path_* var so we never eliminate user-visible vars.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final class -
Field Summary
Fields inherited from class BaseTransform
ANON_PATH_INVERSE_PREFIX, ANON_PATH_PREFIX -
Method Summary
Modifier and TypeMethodDescriptionstatic IrBGPapply(IrBGP bgp, TupleExprIRRenderer r) classifyTailJoin(FusePathPlusTailAlternationUnionTransform.BranchTriple bt, Var midVar, TupleExprIRRenderer r) static booleancompatibleGraphs(Var a, Var b) getSingleBranchSp(IrBGP branch) Methods inherited from class BaseTransform
bgpWithLines, branchHasAnonPathBridge, copyAllExcept, fuseAdjacentPtThenPt, fuseAdjacentSpThenPt, fuseAltInverseTailBGP, fusePtSpPtSequence, invertNegatedPropertySet, iri, isAnonPathInverseVar, isAnonPathVar, isConstantIriPredicate, joinPathWithLaterSp, mergeNpsMembers, normalizeCompactNps, orientBareNpsForNext, rewriteContainers, sameVar, sameVarOrValue, unionBranchesAllHaveAnonPathBridge, unionBranchesShareAnonPathVarWithAllowedRoleMapping, unionBranchesShareCommonAnonPathVarName, unionIsExplicitAndAllBranchesScoped, varOrValueModifier and TypeMethodDescriptionstatic IrBGPbgpWithLines(IrBGP original, List<IrNode> lines) Build a new IrBGP with the same scope flag and the provided lines.static booleanbranchHasAnonPathBridge(IrBGP branch) True if the given branch contains at least one variable with the parser-generated _anon_path_ (or inverse variant) prefix anywhere in its simple triple-like structures.static voidcopyAllExcept(IrBGP from, IrBGP to, IrNode except) static IrBGPFuse adjacent IrPathTriple nodes when the first's object equals the second's subject.static IrBGPstatic IrBGPFuse a path triple whose object is a bridge var with a constant-IRI tail triple that also uses the bridge var, producing a new path with an added '/^p' or '/p' segment.static IrBGPFuse a three-line sequence: IrPathTriple (A), IrStatementPattern (B), IrPathTriple (C) into A then ( ^B.p / C ).static StringinvertNegatedPropertySet(String npsText) If the given path text is a negated property set of the form !static Stringiri(Var pred, TupleExprIRRenderer r) Convenience: render a constant-IRI predicate Var to text.static booleanTrue when the anonymous path var explicitly encodes inverse orientation.static booleanisAnonPathVar(Var v) static booleanConvenience: true iff SP has a constant-IRI predicate.static IrBGPstatic StringmergeNpsMembers(String a, String b) Merge NPS members of two canonical strings '!static StringnormalizeCompactNps(String path) Normalize compact negated-property-set forms into the canonical parenthesized variant.static IrBGPRe-orient a bare negated property set path "!static IrNoderewriteContainers(IrNode n, Function<IrBGP, IrBGP> f) Utility: rewrite container nodes by applying a given function to their inner IrBGP children.static booleanstatic booleansameVarOrValue(Var a, Var b) True when both variables denote the same term: compares names if both are variables without value, or compares values if both are constants.static booleanTrue if all UNION branches contain at least one _anon_path_* variable (or inverse variant).static booleanNew-scope UNION safety: true iff the two UNION branches share at least one _anon_path_* variable name.static booleanTrue if all UNION branches share at least one common variable name that starts with the _anon_path_ prefix.static booleanUniversal safeguard for explicit user UNIONs: true iff the UNION is marked as new scope and all its branches are also marked as new scope.static StringvarOrValue(Var v, TupleExprIRRenderer r)
-
Method Details
-
apply
-
compatibleGraphs
-
classifyTailJoin
public static FusePathPlusTailAlternationUnionTransform.TripleJoin classifyTailJoin(FusePathPlusTailAlternationUnionTransform.BranchTriple bt, Var midVar, TupleExprIRRenderer r) -
getSingleBranchSp
public static FusePathPlusTailAlternationUnionTransform.BranchTriple getSingleBranchSp(IrBGP branch)
-