-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2382 from eclipse/develop
Merge develop into master for 3.3.0 release
- Loading branch information
Showing
864 changed files
with
15,670 additions
and
2,353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...est/java/org/eclipse/rdf4j/query/parser/sparql/function/CustomFunctionEvaluationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 Eclipse RDF4J contributors. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*******************************************************************************/ | ||
package org.eclipse.rdf4j.query.parser.sparql.function; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.StringReader; | ||
|
||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.TupleQueryResult; | ||
import org.eclipse.rdf4j.repository.RepositoryConnection; | ||
import org.eclipse.rdf4j.repository.sail.SailRepository; | ||
import org.eclipse.rdf4j.rio.RDFFormat; | ||
import org.eclipse.rdf4j.sail.memory.MemoryStore; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Integration tests for evaluation of custom functions in SPARQL | ||
* | ||
* @author Jeen Broekstra | ||
*/ | ||
public class CustomFunctionEvaluationTest { | ||
|
||
private SailRepository rep; | ||
|
||
@Before | ||
public void setUp() { | ||
rep = new SailRepository(new MemoryStore()); | ||
} | ||
|
||
@Test | ||
public void testTriplesourceRetrieval() throws Exception { | ||
String data = "<ex:s1> a <ex:CustomClass> . <ex:s1> <ex:related> <ex:s2>, <ex:s3> ."; | ||
String query = "SELECT ?s ?result WHERE { ?s a <ex:CustomClass>. BIND(<urn:triplesourceCustomFunction>(?s) as ?result) }"; | ||
|
||
try (RepositoryConnection conn = rep.getConnection()) { | ||
conn.add(new StringReader(data), "", RDFFormat.TURTLE); | ||
|
||
TupleQueryResult result = conn.prepareTupleQuery(query).evaluate(); | ||
BindingSet bs = result.next(); | ||
assertThat(bs.getValue("result").stringValue()).isEqualTo("related to ex:s2, ex:s3"); | ||
} | ||
|
||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...t/java/org/eclipse/rdf4j/query/parser/sparql/function/TestTripleSourceCustomFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 Eclipse RDF4J contributors. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*******************************************************************************/ | ||
package org.eclipse.rdf4j.query.parser.sparql.function; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.rdf4j.model.IRI; | ||
import org.eclipse.rdf4j.model.Statement; | ||
import org.eclipse.rdf4j.model.Value; | ||
import org.eclipse.rdf4j.model.ValueFactory; | ||
import org.eclipse.rdf4j.query.QueryResults; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.TripleSource; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.function.Function; | ||
|
||
/** | ||
* A test-only function that evaluates against the supplied triple source. It looks up the 'ex:related' relations for | ||
* the given input IRI and outputs a single literal of the form "related to v1, v2, v3". | ||
* | ||
* @author Jeen Broekstra | ||
* | ||
*/ | ||
public class TestTripleSourceCustomFunction implements Function { | ||
|
||
@Override | ||
public String getURI() { | ||
return "urn:triplesourceCustomFunction"; | ||
} | ||
|
||
@Override | ||
public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { | ||
throw new UnsupportedOperationException("can only evaluate with triplesource"); | ||
} | ||
|
||
@Override | ||
public Value evaluate(TripleSource tripleSource, Value... args) throws ValueExprEvaluationException { | ||
IRI subject = (IRI) args[0]; | ||
IRI related = tripleSource.getValueFactory().createIRI("ex:related"); | ||
List<? extends Statement> relatedStatements = QueryResults | ||
.asList(tripleSource.getStatements(subject, related, null)); | ||
|
||
StringBuilder functionResult = new StringBuilder(); | ||
functionResult.append("related to "); | ||
for (Statement st : relatedStatements) { | ||
functionResult.append(st.getObject().stringValue()); | ||
functionResult.append(", "); | ||
} | ||
functionResult.setLength(functionResult.length() - 2); | ||
|
||
return tripleSource.getValueFactory().createLiteral(functionResult.toString()); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
.../resources/META-INF/services/org.eclipse.rdf4j.query.algebra.evaluation.function.Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.eclipse.rdf4j.query.parser.sparql.function.TestTripleSourceCustomFunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.