Skip to content

Commit 3e4f94f

Browse files
authored
merge main into develop (#5158)
2 parents eefa338 + 755a631 commit 3e4f94f

13 files changed

Lines changed: 444 additions & 10 deletions

File tree

core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/util/QueryEvaluationUtil.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.eclipse.rdf4j.model.Value;
2121
import org.eclipse.rdf4j.model.base.CoreDatatype;
2222
import org.eclipse.rdf4j.model.datatypes.XMLDatatypeUtil;
23+
import org.eclipse.rdf4j.model.impl.BooleanLiteral;
2324
import org.eclipse.rdf4j.model.util.Literals;
2425
import org.eclipse.rdf4j.query.algebra.Compare.CompareOp;
2526
import org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException;
@@ -62,6 +63,13 @@ public class QueryEvaluationUtil {
6263
* @throws ValueExprEvaluationException In case the application of the EBV algorithm results in a type error.
6364
*/
6465
public static boolean getEffectiveBooleanValue(Value value) throws ValueExprEvaluationException {
66+
67+
if (value == BooleanLiteral.TRUE) {
68+
return true;
69+
} else if (value == BooleanLiteral.FALSE) {
70+
return false;
71+
}
72+
6573
if (value.isLiteral()) {
6674
Literal literal = (Literal) value;
6775
String label = literal.getLabel();
@@ -107,6 +115,15 @@ public static boolean compare(Value leftVal, Value rightVal, CompareOp operator)
107115

108116
public static boolean compare(Value leftVal, Value rightVal, CompareOp operator, boolean strict)
109117
throws ValueExprEvaluationException {
118+
if (leftVal == rightVal) {
119+
switch (operator) {
120+
case EQ:
121+
return true;
122+
case NE:
123+
return false;
124+
}
125+
}
126+
110127
if (leftVal != null && leftVal.isLiteral() && rightVal != null && rightVal.isLiteral()) {
111128
// Both left and right argument is a Literal
112129
return compareLiterals((Literal) leftVal, (Literal) rightVal, operator, strict);
@@ -162,6 +179,15 @@ public static boolean compareLiterals(Literal leftLit, Literal rightLit, Compare
162179
// - CoreDatatype.XSD:string
163180
// - RDF term (equal and unequal only)
164181

182+
if (leftLit == rightLit) {
183+
switch (operator) {
184+
case EQ:
185+
return true;
186+
case NE:
187+
return false;
188+
}
189+
}
190+
165191
CoreDatatype.XSD leftCoreDatatype = leftLit.getCoreDatatype().asXSDDatatypeOrNull();
166192
CoreDatatype.XSD rightCoreDatatype = rightLit.getCoreDatatype().asXSDDatatypeOrNull();
167193

@@ -329,7 +355,7 @@ && isSupportedDatatype(rightCoreDatatype)) {
329355
* <a href="http://www.w3.org/TR/rdf-concepts/#section-blank-nodes">6.6 Blank Nodes of [CONCEPTS]</a>.
330356
* </ul>
331357
* </blockquote>
332-
*
358+
* <p>
333359
* (emphasis ours)
334360
* <p>
335361
* When applying the SPARQL specification in a minimally-conforming manner, RDFterm-equal is supposed to return a
@@ -349,7 +375,6 @@ && isSupportedDatatype(rightCoreDatatype)) {
349375
* @param rightCoreDatatype the right datatype to compare
350376
* @throws ValueExprEvaluationException if query evaluation is operating in strict mode, and the two supplied
351377
* datatypes are both supported datatypes but not comparable.
352-
*
353378
* @see <a href="https://github.com/eclipse/rdf4j/issues/3947">Github issue #3947</a>
354379
*/
355380
private static void validateDatatypeCompatibility(boolean strict, CoreDatatype.XSD leftCoreDatatype,

core/sail/shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/ast/constraintcomponents/MaxCountConstraintComponent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public class MaxCountConstraintComponent extends AbstractConstraintComponent {
5454
// Performance degrades quickly as the maxCount increases when using a SPARQL Validation Approach. The default is 5,
5555
// but it can be tuned using the system property below.
5656
private static final String SPARQL_VALIDATION_APPROACH_LIMIT_PROPERTY = "org.eclipse.rdf4j.sail.shacl.ast.constraintcomponents.MaxCountConstraintComponent.sparqlValidationApproachLimit";
57-
private static final long SPARQL_VALIDATION_APPROACH_LIMIT = System
58-
.getProperty(SPARQL_VALIDATION_APPROACH_LIMIT_PROPERTY) == null ? 5
57+
public static long SPARQL_VALIDATION_APPROACH_LIMIT = System
58+
.getProperty(SPARQL_VALIDATION_APPROACH_LIMIT_PROPERTY) == null ? 1
5959
: Long.parseLong(System.getProperty(SPARQL_VALIDATION_APPROACH_LIMIT_PROPERTY));
6060

6161
private final long maxCount;

core/sail/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/benchmark/BenchmarkConfigs.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ public class BenchmarkConfigs {
2424

2525
public static List<List<Statement>> generateStatements(StatementCreator statementCreator) {
2626

27+
return generateStatements(NUMBER_OF_TRANSACTIONS, STATEMENTS_PER_TRANSACTION, NUMBER_OF_EMPTY_TRANSACTIONS,
28+
statementCreator);
29+
}
30+
31+
public static List<List<Statement>> generateStatements(int numberOfTransactions, int statementsPerTransaction,
32+
int numberOfEmptyTransactions, StatementCreator statementCreator) {
33+
2734
List<List<Statement>> allStatements = new ArrayList<>();
2835

29-
for (int j = 0; j < BenchmarkConfigs.NUMBER_OF_TRANSACTIONS; j++) {
36+
for (int j = 0; j < numberOfTransactions; j++) {
3037
List<Statement> statements = new ArrayList<>();
3138
allStatements.add(statements);
32-
for (int i = 0; i < BenchmarkConfigs.STATEMENTS_PER_TRANSACTION; i++) {
39+
for (int i = 0; i < statementsPerTransaction; i++) {
3340

3441
statementCreator.createStatement(statements, i, j);
3542
}
3643
}
3744

38-
for (int j = 0; j < BenchmarkConfigs.NUMBER_OF_EMPTY_TRANSACTIONS; j++) {
45+
for (int j = 0; j < numberOfEmptyTransactions; j++) {
3946
List<Statement> statements = new ArrayList<>();
4047
allStatements.add(statements);
4148
}

0 commit comments

Comments
 (0)