Class ConcatAssignments
java.lang.Object
org.aksw.jenax.sparql.expr.optimize.util.ConcatAssignments
- Type Parameters:
T-
Iterator for iterating all of a list's subLists with a given offset (default 0)
and increasing size.
- Author:
- raven
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.slf4j.Loggerstatic final org.apache.jena.sparql.expr.NodeValuestatic final org.apache.jena.sparql.expr.NodeValuestatic final org.apache.jena.sparql.expr.NodeValuestatic final org.apache.jena.sparql.expr.NodeValue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic E_RdfTermexpandAnyToTerm(org.apache.jena.sparql.expr.Expr expr) Expands both constants and functions to RDF terms I don't want to touch the legacy function - thats why this function has this namestatic E_RdfTermexpandConstant(org.apache.jena.graph.Node node) static E_RdfTermexpandConstant(org.apache.jena.sparql.expr.Expr expr) static E_RdfTermexpandRdfTerm(org.apache.jena.sparql.expr.Expr expr) static org.apache.jena.sparql.expr.ExprextractLanguageTag(org.apache.jena.sparql.expr.Expr expr) static org.apache.jena.sparql.expr.ExprgetDatatypeOrExpr(org.apache.jena.sparql.expr.Expr expr) static org.apache.jena.sparql.expr.ExprgetLexicalValueOrExpr(org.apache.jena.sparql.expr.Expr expr) TODO: If we really want the ___lexical value___, we need to apply a transformation to value field based on its type and on the RDF datatype.static List<org.apache.jena.sparql.expr.Expr>getOptimizedConcatArgs(org.apache.jena.sparql.expr.Expr expr) static org.apache.jena.sparql.expr.ExprgetTypeOrExpr(org.apache.jena.sparql.expr.Expr expr) static booleanisConcatExpr(org.apache.jena.sparql.expr.Expr expr) static booleanisOpConcatExpr(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb) static org.apache.jena.sparql.expr.ExprListmergeConsecutiveConstants(Iterable<org.apache.jena.sparql.expr.Expr> exprs) Merges consecutive string arguments.static org.apache.jena.sparql.expr.ExproptimizeEqualsConcat(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb) static org.apache.jena.sparql.expr.ExproptimizeOpConcat(org.apache.jena.sparql.expr.ExprFunction fn) Optimizes Equals(Concat(argsA), Concat(argsB)) FIXME: An combinations, where there are constants - Equals(Concat(args), const) //Assumes optimized form (the whole prefix in a single arg) The following cases are being handled: concat(prefixA, restA) = concat(prefixB, restB) If none of the prefixes is a substring of the other, the whole expression evaluated to false.static org.apache.jena.sparql.expr.ExproptimizeOpConcat(org.apache.jena.sparql.expr.ExprFunction2 fn) static org.apache.jena.sparql.expr.ExproptimizeOpConcat(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb, BinaryOperator<org.apache.jena.sparql.expr.Expr> exprFactory) static org.apache.jena.sparql.expr.ExproptimizeRdfTerm(org.apache.jena.sparql.expr.E_Equals expr) Converts op(f(argsA), f(argsB)) -> op1(op2(argsA[1], argsB[2]), ..., op2(...)) This is mainly used for translating Equals(rdfTerm(argsA), rdfTerm(argsB)) to And(Equals(argsA[0], argsB[0]), Equals(...), ...) Example: f(argsA) = f(argsB) -> argsA = argsB -> argsA.1 = argsB.1 && argsA.2 = argsB.2 && ...splitEqualsConcat(List<org.apache.jena.sparql.expr.Expr> la, List<org.apache.jena.sparql.expr.Expr> lb) Returns a list of alternatives (ors), whereas each alternative is a list of Equals expressions: [ [Equals("x", "x"), Equals(?a, ?b)], [...], ...splitEqualsConcat(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb) static List<org.apache.jena.sparql.expr.Expr>splitOpConcat(List<org.apache.jena.sparql.expr.Expr> la, List<org.apache.jena.sparql.expr.Expr> lb, BinaryOperator<org.apache.jena.sparql.expr.Expr> exprFactory) [(a1, b1)], [(a1, b1), (a2, b2)]static List<org.apache.jena.sparql.expr.Expr>splitOpConcat(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb, BinaryOperator<org.apache.jena.sparql.expr.Expr> exprFactory)
-
Field Details
-
logger
public static final org.slf4j.Logger logger -
TYPE_BLANK
public static final org.apache.jena.sparql.expr.NodeValue TYPE_BLANK -
TYPE_URI
public static final org.apache.jena.sparql.expr.NodeValue TYPE_URI -
TYPE_PLAIN_LITERAL
public static final org.apache.jena.sparql.expr.NodeValue TYPE_PLAIN_LITERAL -
TYPE_TYPED_LITERAL
public static final org.apache.jena.sparql.expr.NodeValue TYPE_TYPED_LITERAL
-
-
Constructor Details
-
ConcatAssignments
public ConcatAssignments()
-
-
Method Details
-
getTypeOrExpr
public static org.apache.jena.sparql.expr.Expr getTypeOrExpr(org.apache.jena.sparql.expr.Expr expr) -
getLexicalValueOrExpr
public static org.apache.jena.sparql.expr.Expr getLexicalValueOrExpr(org.apache.jena.sparql.expr.Expr expr) TODO: If we really want the ___lexical value___, we need to apply a transformation to value field based on its type and on the RDF datatype.- Parameters:
expr-- Returns:
-
getDatatypeOrExpr
public static org.apache.jena.sparql.expr.Expr getDatatypeOrExpr(org.apache.jena.sparql.expr.Expr expr) -
extractLanguageTag
public static org.apache.jena.sparql.expr.Expr extractLanguageTag(org.apache.jena.sparql.expr.Expr expr) -
expandAnyToTerm
Expands both constants and functions to RDF terms I don't want to touch the legacy function - thats why this function has this name- Parameters:
expr-- Returns:
-
expandRdfTerm
-
expandConstant
-
expandConstant
-
optimizeRdfTerm
public static org.apache.jena.sparql.expr.Expr optimizeRdfTerm(org.apache.jena.sparql.expr.E_Equals expr) Converts op(f(argsA), f(argsB)) -> op1(op2(argsA[1], argsB[2]), ..., op2(...)) This is mainly used for translating Equals(rdfTerm(argsA), rdfTerm(argsB)) to And(Equals(argsA[0], argsB[0]), Equals(...), ...) Example: f(argsA) = f(argsB) -> argsA = argsB -> argsA.1 = argsB.1 && argsA.2 = argsB.2 && ... TODO: How to account for extra information that might be available on the constraints on the variables, such as argX.y is a constant? Note: This does not work it many cases for e.g. concat : concat("ab", "c") = concat("a", "bc")- Parameters:
expr-- Returns:
-
mergeConsecutiveConstants
public static org.apache.jena.sparql.expr.ExprList mergeConsecutiveConstants(Iterable<org.apache.jena.sparql.expr.Expr> exprs) Merges consecutive string arguments. Used for concat: concat("a", "b", "c") becomes concat("abc");- Parameters:
concat-- Returns:
-
isConcatExpr
public static boolean isConcatExpr(org.apache.jena.sparql.expr.Expr expr) -
optimizeOpConcat
public static org.apache.jena.sparql.expr.Expr optimizeOpConcat(org.apache.jena.sparql.expr.ExprFunction fn) Optimizes Equals(Concat(argsA), Concat(argsB)) FIXME: An combinations, where there are constants - Equals(Concat(args), const) //Assumes optimized form (the whole prefix in a single arg) The following cases are being handled: concat(prefixA, restA) = concat(prefixB, restB) If none of the prefixes is a substring of the other, the whole expression evaluated to false. otherwise, if the prefixes are equal, they will be removed. if only one further argument remains, the concat will be removed. Also, if one of the arguments is a constant, then it is treated as Concat(const), and theabove rules are applied- Parameters:
expr-- Returns:
-
optimizeOpConcat
public static org.apache.jena.sparql.expr.Expr optimizeOpConcat(org.apache.jena.sparql.expr.ExprFunction2 fn) -
optimizeEqualsConcat
public static org.apache.jena.sparql.expr.Expr optimizeEqualsConcat(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb) -
optimizeOpConcat
public static org.apache.jena.sparql.expr.Expr optimizeOpConcat(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb, BinaryOperator<org.apache.jena.sparql.expr.Expr> exprFactory) -
isOpConcatExpr
public static boolean isOpConcatExpr(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb) -
getOptimizedConcatArgs
public static List<org.apache.jena.sparql.expr.Expr> getOptimizedConcatArgs(org.apache.jena.sparql.expr.Expr expr) - Parameters:
expr-- Returns:
-
splitEqualsConcat
public static List<List<org.apache.jena.sparql.expr.Expr>> splitEqualsConcat(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb) - Parameters:
ta- The first concat expressiontb- The second concat expression- Returns:
-
splitOpConcat
public static List<org.apache.jena.sparql.expr.Expr> splitOpConcat(org.apache.jena.sparql.expr.Expr ta, org.apache.jena.sparql.expr.Expr tb, BinaryOperator<org.apache.jena.sparql.expr.Expr> exprFactory) -
splitOpConcat
public static List<org.apache.jena.sparql.expr.Expr> splitOpConcat(List<org.apache.jena.sparql.expr.Expr> la, List<org.apache.jena.sparql.expr.Expr> lb, BinaryOperator<org.apache.jena.sparql.expr.Expr> exprFactory) [(a1, b1)], [(a1, b1), (a2, b2)]- Parameters:
la-lb-- Returns:
-
splitEqualsConcat
public static List<List<org.apache.jena.sparql.expr.Expr>> splitEqualsConcat(List<org.apache.jena.sparql.expr.Expr> la, List<org.apache.jena.sparql.expr.Expr> lb) Returns a list of alternatives (ors), whereas each alternative is a list of Equals expressions: [ [Equals("x", "x"), Equals(?a, ?b)], [...], ... ]- Parameters:
la-lb-- Returns:
-