diff --git a/bom/pom.xml b/bom/pom.xml
index 165f191e91c..eb75ce9afa0 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -309,11 +309,6 @@
rdf4j-common-transaction${project.version}
-
- org.eclipse.rdf4j
- rdf4j-common-util
- ${project.version}
- org.eclipse.rdf4jrdf4j-common-xml
diff --git a/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchIndexTest.java b/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchIndexTest.java
index 75c47e613e0..0a279ae7dc1 100644
--- a/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchIndexTest.java
+++ b/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchIndexTest.java
@@ -17,11 +17,9 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Literal;
-import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.ValueFactory;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
@@ -307,9 +305,7 @@ public void testAddMultiple() throws Exception {
assertStatement(statement22, document);
// check if the text field stores all added string values
- Set texts = new HashSet<>();
- texts.add("cats");
- texts.add("dogs");
+ HashSet texts = new HashSet<>(List.of("cats", "dogs"));
// FIXME
// assertTexts(texts, document);
@@ -377,7 +373,7 @@ public void testContexts() throws Exception {
// delete context 1
connection.begin();
- connection.clear(new Resource[] { CONTEXT_1 });
+ connection.clear(CONTEXT_1);
connection.commit();
assertNoStatement(statementContext111);
assertNoStatement(statementContext121);
@@ -428,7 +424,7 @@ public void testContextsRemoveContext2() throws Exception {
// delete context 2
connection.begin();
- connection.clear(new Resource[] { CONTEXT_2 });
+ connection.clear(CONTEXT_2);
connection.commit();
assertStatement(statementContext111);
assertStatement(statementContext121);
@@ -449,10 +445,10 @@ public void testRejectedDatatypes() {
Literal literal2 = vf.createLiteral("hi there, too", STRING);
Literal literal3 = vf.createLiteral("1.0");
Literal literal4 = vf.createLiteral("1.0", FLOAT);
- assertEquals("Is the first literal accepted?", true, index.accept(literal1));
- assertEquals("Is the second literal accepted?", true, index.accept(literal2));
- assertEquals("Is the third literal accepted?", true, index.accept(literal3));
- assertEquals("Is the fourth literal accepted?", false, index.accept(literal4));
+ assertTrue("Is the first literal accepted?", index.accept(literal1));
+ assertTrue("Is the second literal accepted?", index.accept(literal2));
+ assertTrue("Is the third literal accepted?", index.accept(literal3));
+ assertFalse("Is the fourth literal accepted?", index.accept(literal4));
}
private void assertStatement(Statement statement) throws Exception {
@@ -471,10 +467,6 @@ private void assertNoStatement(Statement statement) throws Exception {
assertNoStatement(statement, document);
}
- /**
- * @param statement112
- * @param document
- */
private void assertStatement(Statement statement, SearchDocument document) {
List fields = document.getProperty(SearchFields.getPropertyField(statement.getPredicate()));
assertNotNull("field " + statement.getPredicate() + " not found in document " + document, fields);
@@ -486,10 +478,6 @@ private void assertStatement(Statement statement, SearchDocument document) {
fail("Statement not found in document " + statement);
}
- /**
- * @param statement112
- * @param document
- */
private void assertNoStatement(Statement statement, SearchDocument document) {
List fields = document.getProperty(SearchFields.getPropertyField(statement.getPredicate()));
if (fields == null) {
diff --git a/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailGeoSPARQLTest.java b/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailGeoSPARQLTest.java
index d865d2cc953..27cbcb6fb55 100644
--- a/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailGeoSPARQLTest.java
+++ b/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailGeoSPARQLTest.java
@@ -75,7 +75,7 @@ public void tearDown() throws Exception {
}
@Test
- public void testTriplesStored() throws Exception {
+ public void testTriplesStored() {
delegateTest.testTriplesStored();
}
diff --git a/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailIndexedPropertiesTest.java b/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailIndexedPropertiesTest.java
index b183a7a057e..686760b42f4 100644
--- a/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailIndexedPropertiesTest.java
+++ b/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailIndexedPropertiesTest.java
@@ -74,7 +74,7 @@ public void tearDown() throws Exception {
}
@Test
- public void testTriplesStored() throws Exception {
+ public void testTriplesStored() {
delegateTest.testTriplesStored();
}
diff --git a/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailTest.java b/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailTest.java
index d1dd51065c9..d436d6ab955 100644
--- a/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailTest.java
+++ b/compliance/elasticsearch/src/test/java/org/eclipse/rdf4j/sail/elasticsearch/ElasticsearchSailTest.java
@@ -74,7 +74,7 @@ public void tearDown() throws Exception {
}
@Test
- public void testTriplesStored() throws Exception {
+ public void testTriplesStored() {
delegateTest.testTriplesStored();
}
@@ -133,17 +133,17 @@ public void testUnionQuery() throws RepositoryException, MalformedQueryException
}
@Test
- public void testContextHandling() throws Exception {
+ public void testContextHandling() {
delegateTest.testContextHandling();
}
@Test
- public void testConcurrentReadingAndWriting() throws Exception {
+ public void testConcurrentReadingAndWriting() {
delegateTest.testConcurrentReadingAndWriting();
}
@Test
- public void testNullContextHandling() throws Exception {
+ public void testNullContextHandling() {
delegateTest.testNullContextHandling();
}
@@ -153,7 +153,7 @@ public void testFuzzyQuery() throws MalformedQueryException, RepositoryException
}
@Test
- public void testReindexing() throws Exception {
+ public void testReindexing() {
delegateTest.testReindexing();
}
diff --git a/compliance/elasticsearch/src/test/java/org/elasticsearch/bootstrap/JarHell.java b/compliance/elasticsearch/src/test/java/org/elasticsearch/bootstrap/JarHell.java
index 3aae44f99fe..96bd031b72f 100644
--- a/compliance/elasticsearch/src/test/java/org/elasticsearch/bootstrap/JarHell.java
+++ b/compliance/elasticsearch/src/test/java/org/elasticsearch/bootstrap/JarHell.java
@@ -24,10 +24,10 @@ public class JarHell {
private JarHell() {
}
- public static void checkJarHell() throws Exception {
+ public static void checkJarHell() {
}
- public static void checkJarHell(URL urls[]) throws Exception {
+ public static void checkJarHell(URL urls[]) {
}
public static void checkVersionFormat(String targetVersion) {
diff --git a/compliance/geosparql/src/test/java/org/eclipse/rdf4j/query/algebra/geosparql/MemoryGeoSPARQLQueryTest.java b/compliance/geosparql/src/test/java/org/eclipse/rdf4j/query/algebra/geosparql/MemoryGeoSPARQLQueryTest.java
index 3c359fb7946..fc351f8358d 100644
--- a/compliance/geosparql/src/test/java/org/eclipse/rdf4j/query/algebra/geosparql/MemoryGeoSPARQLQueryTest.java
+++ b/compliance/geosparql/src/test/java/org/eclipse/rdf4j/query/algebra/geosparql/MemoryGeoSPARQLQueryTest.java
@@ -24,7 +24,7 @@ public MemoryGeoSPARQLQueryTest(String displayName, String testURI, String name,
}
@Override
- protected Repository newRepository() throws Exception {
+ protected Repository newRepository() {
return new SailRepository(new MemoryStore());
}
}
diff --git a/compliance/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/LuceneSailTest.java b/compliance/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/LuceneSailTest.java
index 295fa4e3ce4..9f93f91cb1b 100644
--- a/compliance/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/LuceneSailTest.java
+++ b/compliance/lucene/src/test/java/org/eclipse/rdf4j/sail/lucene/LuceneSailTest.java
@@ -12,7 +12,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.io.IOException;
import java.util.Collections;
import java.util.List;
@@ -36,13 +35,13 @@ public class LuceneSailTest extends AbstractLuceneSailTest {
* LuceneSail)
*/
@Override
- protected void configure(LuceneSail sail) throws IOException {
+ protected void configure(LuceneSail sail) {
sail.setParameter(LuceneSail.INDEX_CLASS_KEY, LuceneIndex.class.getName());
sail.setParameter(LuceneSail.LUCENE_RAMDIR_KEY, "true");
}
@Test
- public void testReindexing_SingleResource() throws Exception {
+ public void testReindexing_SingleResource() {
// wipe the Lucene index to allow specific test data
try (RepositoryConnection connection = repository.getConnection()) {
diff --git a/compliance/model/src/test/java/org/eclipse/rdf4j/model/util/IsomorphicTest.java b/compliance/model/src/test/java/org/eclipse/rdf4j/model/util/IsomorphicTest.java
index b74595bbe0c..abb13e98fe4 100644
--- a/compliance/model/src/test/java/org/eclipse/rdf4j/model/util/IsomorphicTest.java
+++ b/compliance/model/src/test/java/org/eclipse/rdf4j/model/util/IsomorphicTest.java
@@ -182,7 +182,7 @@ public void bsbmNotIsomorphic() {
}
@Test
- public void testValidationReport() throws IOException {
+ public void testValidationReport() {
Model m1 = getModel("shaclValidationReport.ttl");
Model m2 = getModel("shaclValidationReport.ttl");
@@ -191,7 +191,7 @@ public void testValidationReport() throws IOException {
@Test
@Timeout(2)
- public void testValidationReport_LexicalOrdering() throws IOException {
+ public void testValidationReport_LexicalOrdering() {
Model m1 = getModel("shaclValidationReport.ttl");
Model m2 = getModel("shaclValidationReport.ttl");
@@ -205,7 +205,7 @@ public void testValidationReport_LexicalOrdering() throws IOException {
}
@Test
- public void testValidationReport_Changed() throws IOException {
+ public void testValidationReport_Changed() {
Model m1 = getModel("shaclValidationReport.ttl");
Model m2 = getModel("shaclValidationReport-changed.ttl");
diff --git a/compliance/pom.xml b/compliance/pom.xml
index 9d36c436e3d..f1f901ce146 100644
--- a/compliance/pom.xml
+++ b/compliance/pom.xml
@@ -173,6 +173,13 @@
+
+ com.github.siom79.japicmp
+ japicmp-maven-plugin
+
+ true
+
+
diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/HTTPRepositoryTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/HTTPRepositoryTest.java
index 3214a789d36..a29b6d0cab4 100644
--- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/HTTPRepositoryTest.java
+++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/HTTPRepositoryTest.java
@@ -59,7 +59,7 @@ protected Repository createRepository() {
@Test
@Timeout(value = 10)
- public void testSubqueryDeadlock() throws Exception {
+ public void testSubqueryDeadlock() {
String mainQueryStr = "SELECT ?property WHERE { ?property a rdf:Property . }";
String subQueryStr = "SELECT ?range WHERE { ?property rdfs:range ?range . }";
diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/HTTPStoreConnectionTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/HTTPStoreConnectionTest.java
index 3f946758ef2..9728d94387a 100644
--- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/HTTPStoreConnectionTest.java
+++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/HTTPStoreConnectionTest.java
@@ -73,7 +73,7 @@ public void testContextInTransactionAdd(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
- public void testUpdateExecution(IsolationLevel level) throws Exception {
+ public void testUpdateExecution(IsolationLevel level) {
setupTest(level);
IRI foobar = vf.createIRI("foo:bar");
@@ -116,7 +116,7 @@ public void testAddMalformedLiteralsDefaultConfig(IsolationLevel level) throws E
@MethodSource("parameters")
@Override
@Disabled("See SES-1833")
- public void testAddMalformedLiteralsStrictConfig(IsolationLevel level) throws Exception {
+ public void testAddMalformedLiteralsStrictConfig(IsolationLevel level) {
System.err.println("SES-1833: temporarily disabled testAddMalformedLiteralsStrictConfig() for HTTPRepository");
}
diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/RDFSchemaHTTPRepositoryConnectionTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/RDFSchemaHTTPRepositoryConnectionTest.java
index b1783d81709..dc3891ca895 100644
--- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/RDFSchemaHTTPRepositoryConnectionTest.java
+++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/http/RDFSchemaHTTPRepositoryConnectionTest.java
@@ -56,7 +56,7 @@ protected Repository createRepository(File dataDir) {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testTransactionIsolation(IsolationLevel level) throws Exception {
+ public void testTransactionIsolation(IsolationLevel level) {
System.err.println("temporarily disabled testTransactionIsolation() for HTTPRepository");
}
@@ -64,7 +64,7 @@ public void testTransactionIsolation(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testAutoCommit(IsolationLevel level) throws Exception {
+ public void testAutoCommit(IsolationLevel level) {
System.err.println("temporarily disabled testAutoCommit() for HTTPRepository");
}
@@ -72,7 +72,7 @@ public void testAutoCommit(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testRollback(IsolationLevel level) throws Exception {
+ public void testRollback(IsolationLevel level) {
System.err.println("temporarily disabled testRollback() for HTTPRepository");
}
@@ -80,7 +80,7 @@ public void testRollback(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testEmptyCommit(IsolationLevel level) throws Exception {
+ public void testEmptyCommit(IsolationLevel level) {
System.err.println("temporarily disabled testEmptyCommit() for HTTPRepository");
}
@@ -88,7 +88,7 @@ public void testEmptyCommit(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testEmptyRollback(IsolationLevel level) throws Exception {
+ public void testEmptyRollback(IsolationLevel level) {
System.err.println("temporarily disabled testEmptyRollback() for HTTPRepository");
}
@@ -96,7 +96,7 @@ public void testEmptyRollback(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testSizeCommit(IsolationLevel level) throws Exception {
+ public void testSizeCommit(IsolationLevel level) {
System.err.println("temporarily disabled testSizeCommit() for HTTPRepository");
}
@@ -104,7 +104,7 @@ public void testSizeCommit(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testSizeRollback(IsolationLevel level) throws Exception {
+ public void testSizeRollback(IsolationLevel level) {
System.err.println("temporarily disabled testSizeRollback() for HTTPRepository");
}
@@ -112,7 +112,7 @@ public void testSizeRollback(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testGetContextIDs(IsolationLevel level) throws Exception {
+ public void testGetContextIDs(IsolationLevel level) {
System.err.println("temporarily disabled testGetContextIDs() for HTTPRepository");
}
@@ -120,7 +120,7 @@ public void testGetContextIDs(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testInferencerQueryDuringTransaction(IsolationLevel level) throws Exception {
+ public void testInferencerQueryDuringTransaction(IsolationLevel level) {
System.err.println("temporarily disabled testInferencerDuringTransaction() for HTTPRepository");
}
@@ -128,7 +128,7 @@ public void testInferencerQueryDuringTransaction(IsolationLevel level) throws Ex
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testInferencerTransactionIsolation(IsolationLevel level) throws Exception {
+ public void testInferencerTransactionIsolation(IsolationLevel level) {
System.err.println("temporarily disabled testInferencerTransactionIsolation() for HTTPRepository");
}
@@ -150,7 +150,7 @@ public void testAddMalformedLiteralsDefaultConfig(IsolationLevel level) throws E
@ParameterizedTest
@MethodSource("parameters")
@Disabled
- public void testQueryDefaultGraph(IsolationLevel level) throws Exception {
+ public void testQueryDefaultGraph(IsolationLevel level) {
// ignore - schema caching inferencer uses different context handling
}
@@ -158,7 +158,7 @@ public void testQueryDefaultGraph(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Disabled
- public void testDeleteDefaultGraph(IsolationLevel level) throws Exception {
+ public void testDeleteDefaultGraph(IsolationLevel level) {
// ignore - schema caching inferencer uses different context handling
}
@@ -166,7 +166,7 @@ public void testDeleteDefaultGraph(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Disabled
- public void testContextStatementsNotDuplicated(IsolationLevel level) throws Exception {
+ public void testContextStatementsNotDuplicated(IsolationLevel level) {
// ignore - schema caching inferencer uses different context handling
}
@@ -174,7 +174,7 @@ public void testContextStatementsNotDuplicated(IsolationLevel level) throws Exce
@ParameterizedTest
@MethodSource("parameters")
@Disabled
- public void testContextStatementsNotDuplicated2(IsolationLevel level) throws Exception {
+ public void testContextStatementsNotDuplicated2(IsolationLevel level) {
// ignore - schema caching inferencer uses different context handling
}
@@ -182,7 +182,7 @@ public void testContextStatementsNotDuplicated2(IsolationLevel level) throws Exc
@MethodSource("parameters")
@Override
@Disabled("See SES-1833")
- public void testAddMalformedLiteralsStrictConfig(IsolationLevel level) throws Exception {
+ public void testAddMalformedLiteralsStrictConfig(IsolationLevel level) {
System.err.println("SES-1833: temporarily disabled testAddMalformedLiteralsStrictConfig() for HTTPRepository");
}
diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/manager/LocalRepositoryManagerIntegrationTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/manager/LocalRepositoryManagerIntegrationTest.java
index 08659ddceff..63822645f3b 100644
--- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/manager/LocalRepositoryManagerIntegrationTest.java
+++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/manager/LocalRepositoryManagerIntegrationTest.java
@@ -11,17 +11,17 @@
package org.eclipse.rdf4j.repository.manager;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.fail;
import java.io.File;
-import java.io.IOException;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.InputStream;
import org.eclipse.rdf4j.model.Model;
+import org.eclipse.rdf4j.model.util.Configurations;
+import org.eclipse.rdf4j.model.vocabulary.CONFIG;
import org.eclipse.rdf4j.model.vocabulary.OWL;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.repository.Repository;
@@ -56,11 +56,10 @@ public class LocalRepositoryManagerIntegrationTest extends RepositoryManagerInte
private static final String PROXY_ID = "proxy";
/**
- * @throws java.lang.Exception
*/
@BeforeEach
@Override
- public void setUp() throws Exception {
+ public void setUp() {
subject = new LocalRepositoryManager(datadir);
subject.init();
@@ -74,10 +73,9 @@ public void setUp() throws Exception {
}
/**
- * @throws IOException if a problem occurs deleting temporary resources
*/
@AfterEach
- public void tearDown() throws IOException {
+ public void tearDown() {
subject.shutDown();
}
@@ -90,22 +88,22 @@ public void tearDown() throws IOException {
@Test
public void testGetRepository() throws RepositoryConfigException, RepositoryException {
Repository rep = subject.getRepository(TEST_REPO);
- assertNotNull("Expected repository to exist.", rep);
- assertTrue("Expected repository to be initialized.", rep.isInitialized());
+ assertThat(rep).isNotNull();
+ assertThat(rep.isInitialized()).isTrue();
rep.shutDown();
rep = subject.getRepository(TEST_REPO);
- assertNotNull("Expected repository to exist.", rep);
- assertTrue("Expected repository to be initialized.", rep.isInitialized());
+ assertThat(rep).isNotNull();
+ assertThat(rep.isInitialized()).isTrue();
}
@Test
- public void testRestartManagerWithoutTransaction() throws Exception {
+ public void testRestartManagerWithoutTransaction() {
Repository rep = subject.getRepository(TEST_REPO);
- assertNotNull("Expected repository to exist.", rep);
- assertTrue("Expected repository to be initialized.", rep.isInitialized());
+ assertThat(rep).isNotNull();
+ assertThat(rep.isInitialized()).isTrue();
try (RepositoryConnection conn = rep.getConnection()) {
conn.add(conn.getValueFactory().createIRI("urn:sesame:test:subject"), RDF.TYPE, OWL.ONTOLOGY);
- assertEquals(1, conn.size());
+ assertThat(conn.size()).isEqualTo(1);
} finally {
rep.shutDown();
subject.shutDown();
@@ -114,10 +112,10 @@ public void testRestartManagerWithoutTransaction() throws Exception {
subject = new LocalRepositoryManager(datadir);
subject.init();
Repository rep2 = subject.getRepository(TEST_REPO);
- assertNotNull("Expected repository to exist.", rep2);
- assertTrue("Expected repository to be initialized.", rep2.isInitialized());
+ assertThat(rep2).isNotNull();
+ assertThat(rep2.isInitialized()).isTrue();
try (RepositoryConnection conn2 = rep2.getConnection()) {
- assertEquals(1, conn2.size());
+ assertThat(conn2.size()).isEqualTo(1);
} finally {
rep2.shutDown();
subject.shutDown();
@@ -126,15 +124,15 @@ public void testRestartManagerWithoutTransaction() throws Exception {
}
@Test
- public void testRestartManagerWithTransaction() throws Exception {
+ public void testRestartManagerWithTransaction() {
Repository rep = subject.getRepository(TEST_REPO);
- assertNotNull("Expected repository to exist.", rep);
- assertTrue("Expected repository to be initialized.", rep.isInitialized());
+ assertThat(rep).isNotNull();
+ assertThat(rep.isInitialized()).isTrue();
try (RepositoryConnection conn = rep.getConnection()) {
conn.begin();
conn.add(conn.getValueFactory().createIRI("urn:sesame:test:subject"), RDF.TYPE, OWL.ONTOLOGY);
conn.commit();
- assertEquals(1, conn.size());
+ assertThat(conn.size()).isEqualTo(1);
} finally {
rep.shutDown();
subject.shutDown();
@@ -143,10 +141,10 @@ public void testRestartManagerWithTransaction() throws Exception {
subject = new LocalRepositoryManager(datadir);
subject.init();
Repository rep2 = subject.getRepository(TEST_REPO);
- assertNotNull("Expected repository to exist.", rep2);
- assertTrue("Expected repository to be initialized.", rep2.isInitialized());
+ assertThat(rep2).isNotNull();
+ assertThat(rep2.isInitialized()).isTrue();
try (RepositoryConnection conn2 = rep2.getConnection()) {
- assertEquals(1, conn2.size());
+ assertThat(conn2.size()).isEqualTo(1);
} finally {
rep2.shutDown();
subject.shutDown();
@@ -185,12 +183,60 @@ public void testAddWithExistingSysRepository() {
}
}
+ @Test
+ public void testGetRepositoryConfig_Legacy() throws Exception {
+ // set up legacy configuration
+ new File(datadir, "repositories/legacy").mkdir();
+ InputStream in = getClass().getResourceAsStream("/fixtures/memory-legacy.ttl");
+ Model model = Rio.parse(in, RDFFormat.TURTLE);
+ Rio.write(model, new FileOutputStream(new File(datadir, "repositories/legacy/config.ttl")),
+ RDFFormat.TURTLE);
+
+ RepositoryConfig config = subject.getRepositoryConfig("legacy");
+ assertThat(config).isNotNull();
+ assertThat(config.getTitle()).isEqualTo("Legacy Test Repository");
+
+ // verify manager has converted the config file.
+ File convertedConfig = new File(datadir, "repositories/legacy/config.ttl");
+
+ Model convertedModel = Rio.parse(new FileInputStream(convertedConfig), convertedConfig.toURI().toString(),
+ RDFFormat.TURTLE);
+ assertThat(convertedModel.getNamespaces()).contains(CONFIG.NS);
+ assertThat(Configurations.hasLegacyConfiguration(convertedModel)).isFalse();
+ }
+
+ @Test
+ public void testGetRepositoryConfig_Legacy_useLegacy() throws Exception {
+ // set up legacy configuration
+ new File(datadir, "repositories/legacy").mkdir();
+ InputStream in = getClass().getResourceAsStream("/fixtures/memory-legacy.ttl");
+ Model model = Rio.parse(in, RDFFormat.TURTLE);
+ Rio.write(model, new FileOutputStream(new File(datadir, "repositories/legacy/config.ttl")),
+ RDFFormat.TURTLE);
+
+ System.setProperty("org.eclipse.rdf4j.model.vocabulary.useLegacyConfig", "true");
+ RepositoryConfig config = subject.getRepositoryConfig("legacy");
+ System.setProperty("org.eclipse.rdf4j.model.vocabulary.useLegacyConfig", "");
+
+ assertThat(config).isNotNull();
+ assertThat(config.getTitle()).isEqualTo("Legacy Test Repository");
+
+ // verify manager has NOT converted the config file.
+ File convertedConfig = new File(datadir, "repositories/legacy/config.ttl");
+
+ Model convertedModel = Rio.parse(new FileInputStream(convertedConfig), convertedConfig.toURI().toString(),
+ RDFFormat.TURTLE);
+ assertThat(convertedModel.getNamespaces()).doesNotContain(CONFIG.NS);
+ assertThat(Configurations.hasLegacyConfiguration(convertedModel)).isTrue();
+ }
+
@Test
public void testAddConfig_validation() throws Exception {
InputStream in = getClass().getResourceAsStream("/fixtures/memory-invalid.ttl");
Model model = Rio.parse(in, RDFFormat.TURTLE);
- assertThrows(RepositoryConfigException.class, () -> RepositoryConfigUtil.getRepositoryConfig(model, "Test"));
+ assertThatExceptionOfType(RepositoryConfigException.class)
+ .isThrownBy(() -> RepositoryConfigUtil.getRepositoryConfig(model, "Test"));
}
}
diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/manager/RepositoryManagerIntegrationTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/manager/RepositoryManagerIntegrationTest.java
index d9e60313300..1c1fc756d16 100644
--- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/manager/RepositoryManagerIntegrationTest.java
+++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/manager/RepositoryManagerIntegrationTest.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.rdf4j.repository.manager;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
@@ -26,7 +25,7 @@ public class RepositoryManagerIntegrationTest {
protected RepositoryManager subject;
@BeforeEach
- public void setUp() throws Exception {
+ public void setUp() {
subject = new RepositoryManager() {
@Override
@@ -36,7 +35,7 @@ public void setHttpClient(HttpClient httpClient) {
}
@Override
- public URL getLocation() throws MalformedURLException {
+ public URL getLocation() {
return null;
}
diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLGraphQueryResultTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLGraphQueryResultTest.java
index 7c282077a1c..ce00e457a9b 100644
--- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLGraphQueryResultTest.java
+++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLGraphQueryResultTest.java
@@ -42,7 +42,7 @@ public static void stopServer() throws Exception {
}
@Override
- protected Repository newRepository() throws Exception {
+ protected Repository newRepository() {
return new SPARQLRepository(HTTPMemServer.REPOSITORY_URL,
Protocol.getStatementsLocation(HTTPMemServer.REPOSITORY_URL));
diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLRepositoryTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLRepositoryTest.java
index edae8e4ad5d..4e4140920ef 100644
--- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLRepositoryTest.java
+++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLRepositoryTest.java
@@ -56,7 +56,7 @@ public static void stopServer() throws Exception {
}
@Override
- protected Repository createRepository() throws Exception {
+ protected Repository createRepository() {
return new SPARQLRepository(HTTPMemServer.REPOSITORY_URL,
Protocol.getStatementsLocation(HTTPMemServer.REPOSITORY_URL));
diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLStoreConnectionTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLStoreConnectionTest.java
index 4dd72cc17a9..d23d25184f7 100644
--- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLStoreConnectionTest.java
+++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/SPARQLStoreConnectionTest.java
@@ -86,7 +86,7 @@ protected Repository createRepository(File dataDir) {
@MethodSource("parameters")
@Override
@Disabled
- public void testDuplicateFilter(IsolationLevel level) throws Exception {
+ public void testDuplicateFilter(IsolationLevel level) {
System.err.println("temporarily disabled testDuplicateFilter() for SPARQLRepository");
}
@@ -110,7 +110,7 @@ public void testAddRemoveInsert(IsolationLevel level) throws RDF4JException {
@MethodSource("parameters")
@Override
@Disabled("relies on pending updates being visible in own connection")
- public void testSizeRollback(IsolationLevel level) throws Exception {
+ public void testSizeRollback(IsolationLevel level) {
System.err.println("temporarily disabled testSizeRollback() for SPARQLRepository");
}
@@ -118,7 +118,7 @@ public void testSizeRollback(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled("relies on pending updates being visible in own connection")
- public void testAutoCommit(IsolationLevel level) throws Exception {
+ public void testAutoCommit(IsolationLevel level) {
System.err.println("temporarily disabled testAutoCommit() for SPARQLRepository");
}
@@ -126,7 +126,7 @@ public void testAutoCommit(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled("relies on pending updates being visible in own connection")
- public void testRollback(IsolationLevel level) throws Exception {
+ public void testRollback(IsolationLevel level) {
System.err.println("temporarily disabled testRollback() for SPARQLRepository");
}
@@ -134,7 +134,7 @@ public void testRollback(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled("relies on pending updates being visible in own connection")
- public void testEmptyRollback(IsolationLevel level) throws Exception {
+ public void testEmptyRollback(IsolationLevel level) {
System.err.println("temporarily disabled testEmptyRollback() for SPARQLRepository");
}
@@ -142,7 +142,7 @@ public void testEmptyRollback(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled("relies on pending updates being visible in own connection")
- public void testEmptyCommit(IsolationLevel level) throws Exception {
+ public void testEmptyCommit(IsolationLevel level) {
System.err.println("temporarily disabled testEmptyCommit() for SPARQLRepository");
}
@@ -150,7 +150,7 @@ public void testEmptyCommit(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled
- public void testSizeCommit(IsolationLevel level) throws Exception {
+ public void testSizeCommit(IsolationLevel level) {
System.err.println("temporarily disabled testSizeCommit() for SPARQLRepository");
}
@@ -158,7 +158,7 @@ public void testSizeCommit(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled
- public void testGetStatementsInMultipleContexts(IsolationLevel level) throws Exception {
+ public void testGetStatementsInMultipleContexts(IsolationLevel level) {
System.err.println(
"temporarily disabled testGetStatementsInMultipleContexts() for SPARQLRepository: implementation of statement context using SPARQL not yet complete");
// TODO see SES-1776
@@ -214,7 +214,7 @@ private void enableQuadModeOnConnection(SPARQLConnection con) throws Exception {
@MethodSource("parameters")
@Override
@Disabled
- public void testGetStatementsInSingleContext(IsolationLevel level) throws Exception {
+ public void testGetStatementsInSingleContext(IsolationLevel level) {
System.err.println(
"temporarily disabled testGetStatementsInSingleContext() for SPARQLRepository: implementation of statement context using SPARQL not yet complete");
// TODO see SES-1776
@@ -224,14 +224,14 @@ public void testGetStatementsInSingleContext(IsolationLevel level) throws Except
@MethodSource("parameters")
@Override
@Disabled("can not execute test because required data add results in illegal SPARQL syntax")
- public void testGetStatementsMalformedLanguageLiteral(IsolationLevel level) throws Exception {
+ public void testGetStatementsMalformedLanguageLiteral(IsolationLevel level) {
System.err.println("temporarily disabled testGetStatementsMalformedLanguageLiteral() for SPARQLRepository");
}
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testPreparedTupleQuery(IsolationLevel level) throws Exception {
+ public void testPreparedTupleQuery(IsolationLevel level) {
setupTest(level);
testCon.add(alice, name, nameAlice, context2);
@@ -273,7 +273,7 @@ public void testPreparedTupleQuery(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled
- public void testGetNamespaces(IsolationLevel level) throws Exception {
+ public void testGetNamespaces(IsolationLevel level) {
System.err.println("disabled testGetNamespaces() as namespace retrieval is not supported by SPARQL");
}
@@ -281,7 +281,7 @@ public void testGetNamespaces(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled
- public void testGetNamespace(IsolationLevel level) throws Exception {
+ public void testGetNamespace(IsolationLevel level) {
System.err.println("disabled testGetNamespace() as namespace retrieval is not supported by SPARQL");
}
@@ -289,7 +289,7 @@ public void testGetNamespace(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled
- public void testImportNamespacesFromIterable(IsolationLevel level) throws Exception {
+ public void testImportNamespacesFromIterable(IsolationLevel level) {
System.err
.println("disabled testImportNamespacesFromIterable() as namespace setting is not supported by SPARQL");
}
@@ -298,14 +298,14 @@ public void testImportNamespacesFromIterable(IsolationLevel level) throws Except
@MethodSource("parameters")
@Override
@Disabled
- public void testTransactionIsolation(IsolationLevel level) throws Exception {
+ public void testTransactionIsolation(IsolationLevel level) {
System.err.println("temporarily disabled testTransactionIsolation() for SPARQLRepository");
}
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testPreparedTupleQueryUnicode(IsolationLevel level) throws Exception {
+ public void testPreparedTupleQueryUnicode(IsolationLevel level) {
setupTest(level);
testCon.add(alexander, name, Александър);
@@ -333,7 +333,7 @@ public void testPreparedTupleQueryUnicode(IsolationLevel level) throws Exception
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testSimpleGraphQuery(IsolationLevel level) throws Exception {
+ public void testSimpleGraphQuery(IsolationLevel level) {
setupTest(level);
testCon.add(alice, name, nameAlice, context2);
@@ -370,7 +370,7 @@ public void testSimpleGraphQuery(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testPreparedGraphQuery(IsolationLevel level) throws Exception {
+ public void testPreparedGraphQuery(IsolationLevel level) {
setupTest(level);
testCon.add(alice, name, nameAlice, context2);
@@ -412,7 +412,7 @@ public void testPreparedGraphQuery(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testSimpleTupleQuery(IsolationLevel level) throws Exception {
+ public void testSimpleTupleQuery(IsolationLevel level) {
setupTest(level);
testCon.add(alice, name, nameAlice, context2);
@@ -451,7 +451,7 @@ public void testSimpleTupleQuery(IsolationLevel level) throws Exception {
@ParameterizedTest
@MethodSource("parameters")
@Override
- public void testSimpleTupleQueryUnicode(IsolationLevel level) throws Exception {
+ public void testSimpleTupleQueryUnicode(IsolationLevel level) {
setupTest(level);
testCon.add(alexander, name, Александър);
@@ -478,13 +478,13 @@ public void testSimpleTupleQueryUnicode(IsolationLevel level) throws Exception {
@MethodSource("parameters")
@Override
@Disabled
- public void testBNodeSerialization(IsolationLevel level) throws Exception {
+ public void testBNodeSerialization(IsolationLevel level) {
System.err.println("temporarily disabled testBNodeSerialization() for SPARQLRepository");
}
@ParameterizedTest
@MethodSource("parameters")
- public void testUpdateExecution(IsolationLevel level) throws Exception {
+ public void testUpdateExecution(IsolationLevel level) {
setupTest(level);
IRI foobar = vf.createIRI("foo:bar");
diff --git a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java
index 9e2bf2e1b1e..763d3c2a6d2 100644
--- a/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java
+++ b/compliance/repository/src/test/java/org/eclipse/rdf4j/repository/sparql/federation/RepositoryFederatedServiceIntegrationTest.java
@@ -82,7 +82,7 @@ public void after() {
}
@Test
- public void test() throws Exception {
+ public void test() {
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s1"), RDFS.LABEL, l("val1"))));
@@ -92,7 +92,7 @@ public void test() throws Exception {
}
@Test
- public void test2() throws Exception {
+ public void test2() {
addData(serviceRepo, Lists.newArrayList(
vf.createStatement(iri("s1"), RDFS.LABEL, l("val1")),
@@ -105,7 +105,7 @@ public void test2() throws Exception {
}
@Test
- public void test3() throws Exception {
+ public void test3() {
addData(serviceRepo, Lists.newArrayList(
vf.createStatement(iri("s1"), RDFS.LABEL, l("val1")),
@@ -118,7 +118,7 @@ public void test3() throws Exception {
}
@Test
- public void test3a() throws Exception {
+ public void test3a() {
addData(serviceRepo, Lists.newArrayList(
vf.createStatement(iri("s1"), RDFS.LABEL, l("val1")),
@@ -133,7 +133,7 @@ public void test3a() throws Exception {
}
@Test
- public void test4() throws Exception {
+ public void test4() {
addData(serviceRepo, Lists.newArrayList(
vf.createStatement(iri("s1"), RDFS.LABEL, l("val1")),
@@ -146,7 +146,7 @@ public void test4() throws Exception {
}
@Test
- public void test4a() throws Exception {
+ public void test4a() {
addData(serviceRepo, Lists.newArrayList(
vf.createStatement(iri("s1"), RDFS.LABEL, l("val1")),
@@ -160,7 +160,7 @@ public void test4a() throws Exception {
}
@Test
- public void test4b() throws Exception {
+ public void test4b() {
addData(serviceRepo, Lists.newArrayList(
vf.createStatement(iri("s1"), RDFS.LABEL, l("val1")),
@@ -173,7 +173,7 @@ public void test4b() throws Exception {
}
@Test
- public void test5() throws Exception {
+ public void test5() {
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s1"), RDFS.LABEL, l("val1"))));
@@ -185,7 +185,7 @@ public void test5() throws Exception {
}
@Test
- public void test5a() throws Exception {
+ public void test5a() {
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s1"), RDFS.LABEL, l("val1"))));
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s2"), RDFS.LABEL, l("val2"))));
@@ -199,7 +199,7 @@ public void test5a() throws Exception {
}
@Test
- public void test5b() throws Exception {
+ public void test5b() {
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s1"), RDFS.LABEL, l("val1"))));
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s2"), RDFS.LABEL, l("val2"))));
@@ -212,7 +212,7 @@ public void test5b() throws Exception {
}
@Test
- public void test6() throws Exception {
+ public void test6() {
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s1"), RDFS.LABEL, l("val1"))));
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s2"), RDFS.LABEL, l("val2"))));
@@ -228,7 +228,7 @@ public void test6() throws Exception {
}
@Test
- public void test6b() throws Exception {
+ public void test6b() {
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s1"), RDFS.LABEL, l("val1"))));
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s2"), RDFS.LABEL, l("val2"))));
@@ -244,7 +244,7 @@ public void test6b() throws Exception {
}
@Test
- public void test7_CrossProduct() throws Exception {
+ public void test7_CrossProduct() {
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s1"), RDFS.LABEL, l("serviceVal"))));
@@ -256,7 +256,7 @@ public void test7_CrossProduct() throws Exception {
}
@Test
- public void test8_subSelectAll() throws Exception {
+ public void test8_subSelectAll() {
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s1"), RDFS.LABEL, l("val1"))));
@@ -266,7 +266,7 @@ public void test8_subSelectAll() throws Exception {
}
@Test
- public void test8a_subSelectAll() throws Exception {
+ public void test8a_subSelectAll() {
addData(serviceRepo, Lists.newArrayList(vf.createStatement(iri("s1"), RDFS.LABEL, l("val1"))));
@@ -313,7 +313,7 @@ public void test9_connectionHandling() throws Exception {
}
@Test
- public void test10_consumePartially() throws Exception {
+ public void test10_consumePartially() {
/*
* The purpose of this test is validate that connections are closed properly, even if a result is consume only
diff --git a/compliance/repository/src/test/resources/fixtures/memory-legacy.ttl b/compliance/repository/src/test/resources/fixtures/memory-legacy.ttl
new file mode 100644
index 00000000000..a4d10cfb50a
--- /dev/null
+++ b/compliance/repository/src/test/resources/fixtures/memory-legacy.ttl
@@ -0,0 +1,23 @@
+#
+# 'Test' main-memory repository config - legacy configuration
+#
+@prefix rdfs: .
+@prefix rep: .
+@prefix sr: .
+@prefix sail: .
+@prefix ms: .
+@prefix sb: .
+
+[] a rep:Repository ;
+ rep:repositoryID "legacy" ;
+ rdfs:label "Legacy Test Repository" ;
+ rep:repositoryImpl [
+ rep:repositoryType "openrdf:SailRepository" ;
+ sr:sailImpl [
+ sail:sailType "openrdf:MemoryStore" ;
+ sail:iterationCacheSyncThreshold "1000";
+ ms:persist false ;
+ ms:syncDelay 0 ;
+ sb:evaluationStrategyFactory "org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategyFactory"
+ ]
+ ].
diff --git a/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrIndexTest.java b/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrIndexTest.java
index 40c7e3a71de..af57bfb2784 100644
--- a/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrIndexTest.java
+++ b/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrIndexTest.java
@@ -105,7 +105,7 @@ public static void setUpClass() throws Exception {
}
@AfterClass
- public static void tearDownClass() throws Exception {
+ public static void tearDownClass() {
System.setProperty("solr.solr.home", toRestoreSolrHome == null ? "" : toRestoreSolrHome);
toRestoreSolrHome = null;
}
diff --git a/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailGeoSPARQLTest.java b/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailGeoSPARQLTest.java
index 2189f12bfff..c85ebf15edd 100644
--- a/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailGeoSPARQLTest.java
+++ b/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailGeoSPARQLTest.java
@@ -39,7 +39,7 @@ public static void setUpClass() throws Exception {
}
@AfterClass
- public static void tearDownClass() throws Exception {
+ public static void tearDownClass() {
System.setProperty("solr.solr.home", toRestoreSolrHome == null ? "" : toRestoreSolrHome);
toRestoreSolrHome = null;
}
diff --git a/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailIndexedPropertiesTest.java b/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailIndexedPropertiesTest.java
index 65c37e0a7d1..6c3cf54c00c 100644
--- a/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailIndexedPropertiesTest.java
+++ b/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailIndexedPropertiesTest.java
@@ -36,7 +36,7 @@ public static void setUpClass() throws Exception {
}
@AfterClass
- public static void tearDownClass() throws Exception {
+ public static void tearDownClass() {
System.setProperty("solr.solr.home", toRestoreSolrHome == null ? "" : toRestoreSolrHome);
toRestoreSolrHome = null;
}
diff --git a/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailTest.java b/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailTest.java
index 2f286c68434..f6c95d9808a 100644
--- a/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailTest.java
+++ b/compliance/solr/src/test/java/org/eclipse/rdf4j/sail/solr/SolrSailTest.java
@@ -37,7 +37,7 @@ public static void setUpClass() throws Exception {
}
@AfterAll
- public static void tearDownClass() throws Exception {
+ public static void tearDownClass() {
System.setProperty("solr.solr.home", toRestoreSolrHome == null ? "" : toRestoreSolrHome);
toRestoreSolrHome = null;
}
diff --git a/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/ArbitraryLengthPathTest.java b/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/ArbitraryLengthPathTest.java
index 96e48069462..3bc317da732 100644
--- a/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/ArbitraryLengthPathTest.java
+++ b/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/ArbitraryLengthPathTest.java
@@ -35,54 +35,54 @@ public class ArbitraryLengthPathTest {
private RepositoryConnection con;
@BeforeEach
- public void setUp() throws Exception {
+ public void setUp() {
repo = new SailRepository(new MemoryStore());
con = repo.getConnection();
}
@AfterEach
- public void tearDown() throws Exception {
+ public void tearDown() {
con.close();
repo.shutDown();
}
@Test
- public void test10() throws Exception {
+ public void test10() {
populate(10);
String sparql = "ASK { * }";
assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate());
}
@Test
- public void test100() throws Exception {
+ public void test100() {
populate(100);
String sparql = "ASK { * }";
assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate());
}
@Test
- public void test1000() throws Exception {
+ public void test1000() {
populate(1000);
String sparql = "ASK { * }";
assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate());
}
@Test
- public void test10000() throws Exception {
+ public void test10000() {
populate(10000);
String sparql = "ASK { * }";
assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate());
}
@Test
- public void test100000() throws Exception {
+ public void test100000() {
populate(100000);
String sparql = "ASK { * }";
assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate());
}
@Test
- public void testDirection() throws Exception {
+ public void testDirection() {
ValueFactory vf = con.getValueFactory();
con.add(vf.createIRI("urn:test:a"), vf.createIRI("urn:test:rel"), vf.createIRI("urn:test:b"));
con.add(vf.createIRI("urn:test:b"), vf.createIRI("urn:test:rel"), vf.createIRI("urn:test:a"));
@@ -91,7 +91,7 @@ public void testDirection() throws Exception {
}
@Test
- public void testSimilarPatterns() throws Exception {
+ public void testSimilarPatterns() {
ValueFactory vf = con.getValueFactory();
con.add(vf.createIRI("urn:test:a"), RDF.TYPE, vf.createIRI("urn:test:c"));
con.add(vf.createIRI("urn:test:b"), RDF.TYPE, vf.createIRI("urn:test:d"));
diff --git a/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/HTTPSparqlUpdateTest.java b/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/HTTPSparqlUpdateTest.java
index bcddb35ee09..115c3f4bc25 100644
--- a/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/HTTPSparqlUpdateTest.java
+++ b/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/HTTPSparqlUpdateTest.java
@@ -54,7 +54,7 @@ public static void stopServer() throws Exception {
}
@Override
- protected Repository newRepository() throws Exception {
+ protected Repository newRepository() {
return new HTTPRepository(server.getRepositoryUrl(repositoryId));
}
@@ -68,7 +68,7 @@ public void testAutoCommitHandling() {
}
@Test
- public void testBindingsInUpdateTransaction() throws Exception {
+ public void testBindingsInUpdateTransaction() {
// See issue SES-1889
logger.debug("executing test testBindingsInUpdateTransaction");
diff --git a/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/SPARQLServiceEvaluationTest.java b/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/SPARQLServiceEvaluationTest.java
index c21d2c01ad0..503a79b27e7 100644
--- a/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/SPARQLServiceEvaluationTest.java
+++ b/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/SPARQLServiceEvaluationTest.java
@@ -226,7 +226,7 @@ public void tearDown() throws Exception {
* @see #646
*/
@Test
- public void testValuesBindClauseHandling() throws Exception {
+ public void testValuesBindClauseHandling() {
String query = "select * { service <" + getRepositoryUrl(1) + "> { Bind(1 as ?val) . VALUES ?x {1 2} . } }";
try (RepositoryConnection conn = localRepository.getConnection()) {
@@ -566,10 +566,9 @@ private Set readExpectedGraphQueryResult(String resultFile) throws Ex
* @param queryResult
* @param expectedResult
* @param checkOrder
- * @throws Exception
*/
private void compareTupleQueryResults(TupleQueryResult queryResult, TupleQueryResult expectedResult,
- boolean checkOrder) throws Exception {
+ boolean checkOrder) {
// Create MutableTupleQueryResult to be able to re-iterate over the
// results
MutableTupleQueryResult queryResultTable = new MutableTupleQueryResult(queryResult);
@@ -688,9 +687,8 @@ private void compareTupleQueryResults(TupleQueryResult queryResult, TupleQueryRe
*
* @param queryResult
* @param expectedResult
- * @throws Exception
*/
- private void compareGraphs(Set queryResult, Set expectedResult) throws Exception {
+ private void compareGraphs(Set queryResult, Set expectedResult) {
if (!Models.isomorphic(expectedResult, queryResult)) {
// Don't use RepositoryUtil.difference, it reports incorrect diffs
/*
diff --git a/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/manifest/W3CApprovedSPARQL11UpdateTest.java b/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/manifest/W3CApprovedSPARQL11UpdateTest.java
index 1587ba3e4e1..96700874565 100644
--- a/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/manifest/W3CApprovedSPARQL11UpdateTest.java
+++ b/compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/manifest/W3CApprovedSPARQL11UpdateTest.java
@@ -34,7 +34,7 @@ public W3CApprovedSPARQL11UpdateTest(String displayName, String testURI, String
}
@Override
- protected Repository newRepository() throws Exception {
+ protected Repository newRepository() {
SailRepository repo = new SailRepository(new MemoryStore());
return repo;
diff --git a/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/federation/FedXSPARQL11QueryComplianceTest.java b/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/federation/FedXSPARQL11QueryComplianceTest.java
index e6fd1aef390..efb4c30a8bb 100644
--- a/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/federation/FedXSPARQL11QueryComplianceTest.java
+++ b/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/federation/FedXSPARQL11QueryComplianceTest.java
@@ -60,7 +60,7 @@ private void initManager() {
}
@Override
- protected Repository newRepository() throws Exception {
+ protected Repository newRepository() {
initManager();
addMemoryStore("repo1");
@@ -75,7 +75,7 @@ protected Repository newRepository() throws Exception {
return new DatasetRepository(repo);
}
- private void addMemoryStore(String repoId) throws RepositoryConfigException, RepositoryException, IOException {
+ private void addMemoryStore(String repoId) throws RepositoryConfigException, RepositoryException {
RepositoryImplConfig implConfig = new SailRepositoryConfig(new MemoryStoreConfig());
RepositoryConfig config = new RepositoryConfig(repoId, implConfig);
manager.addRepositoryConfig(config);
diff --git a/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/memory/MemorySPARQL11QueryComplianceTest.java b/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/memory/MemorySPARQL11QueryComplianceTest.java
index 8e6dfac2768..4c6728fa658 100644
--- a/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/memory/MemorySPARQL11QueryComplianceTest.java
+++ b/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/memory/MemorySPARQL11QueryComplianceTest.java
@@ -29,7 +29,7 @@ public MemorySPARQL11QueryComplianceTest(String displayName, String testURI, Str
}
@Override
- protected Repository newRepository() throws Exception {
+ protected Repository newRepository() {
return new DatasetRepository(new SailRepository(new MemoryStore()));
}
}
diff --git a/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/memory/MemorySPARQL11UpdateComplianceTest.java b/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/memory/MemorySPARQL11UpdateComplianceTest.java
index 27d7ba9bb65..3df69511d07 100644
--- a/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/memory/MemorySPARQL11UpdateComplianceTest.java
+++ b/compliance/sparql/src/test/java/org/eclipse/rdf4j/sail/memory/MemorySPARQL11UpdateComplianceTest.java
@@ -33,7 +33,7 @@ public MemorySPARQL11UpdateComplianceTest(String displayName, String testURI, St
}
@Override
- protected Repository newRepository() throws Exception {
+ protected Repository newRepository() {
return new SailRepository(new MemoryStore());
}
diff --git a/core/client/pom.xml b/core/client/pom.xml
index 0adb19c758a..dcc6771feb5 100644
--- a/core/client/pom.xml
+++ b/core/client/pom.xml
@@ -216,11 +216,6 @@
rdf4j-common-transaction${project.version}
-
- org.eclipse.rdf4j
- rdf4j-common-util
- ${project.version}
- org.eclipse.rdf4jrdf4j-common-xml
diff --git a/core/collection-factory/api/pom.xml b/core/collection-factory/api/pom.xml
index 464f40e2052..e39337fb961 100644
--- a/core/collection-factory/api/pom.xml
+++ b/core/collection-factory/api/pom.xml
@@ -30,10 +30,6 @@
maven-assembly-plugin
-
- com.github.siom79.japicmp
- japicmp-maven-plugin
-
diff --git a/core/collection-factory/api/src/main/java/org/eclipse/rdf4j/collection/factory/api/CollectionFactory.java b/core/collection-factory/api/src/main/java/org/eclipse/rdf4j/collection/factory/api/CollectionFactory.java
index fb7f581bb22..27e5bdf324d 100644
--- a/core/collection-factory/api/src/main/java/org/eclipse/rdf4j/collection/factory/api/CollectionFactory.java
+++ b/core/collection-factory/api/src/main/java/org/eclipse/rdf4j/collection/factory/api/CollectionFactory.java
@@ -19,7 +19,10 @@
import java.util.Map;
import java.util.Queue;
import java.util.Set;
+import java.util.function.BiConsumer;
import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
import java.util.function.ToIntBiFunction;
import java.util.function.ToIntFunction;
@@ -28,6 +31,8 @@
import org.eclipse.rdf4j.common.exception.RDF4JException;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.query.BindingSet;
+import org.eclipse.rdf4j.query.MutableBindingSet;
+import org.eclipse.rdf4j.query.impl.MapBindingSet;
/**
* A Factory that may generate optimised and/or disk based collections
@@ -61,7 +66,26 @@ public interface CollectionFactory extends AutoCloseable {
/**
* @return a set that may be optimised and/or disk based
*/
- public Set createSetOfBindingSets();
+ public default Set createSetOfBindingSets() {
+ // note the odd lambda returning a lambda
+ Function> gethas = (n) -> (b) -> b.hasBinding(n);
+ Function> getget = (n) -> (b) -> b.getValue(n);
+ Function> getSet = (n) -> (v, b) -> b.setBinding(n, v);
+ return createSetOfBindingSets(MapBindingSet::new, gethas, getget, getSet);
+ }
+
+ /**
+ * Allows optimizations beyond what would otherwise be possible, regarding disk access and storage.
+ *
+ * @param create a supplier that makes bindingsets
+ * @param a supplier used to create prebound hasBinding predicates
+ * @param a supplier used to create prebound getValue functions
+ * @param a supplier used to create prebound setValue functions
+ * @return a set that may be optimised and/or disk based
+ */
+ public Set createSetOfBindingSets(Supplier create,
+ Function> getHas, Function> getget,
+ Function> getSet);
/**
* @return a set that may be optimised and/or disk based for Values
diff --git a/core/collection-factory/api/src/main/java/org/eclipse/rdf4j/collection/factory/impl/DefaultCollectionFactory.java b/core/collection-factory/api/src/main/java/org/eclipse/rdf4j/collection/factory/impl/DefaultCollectionFactory.java
index e22e8587856..87acf1deb2a 100644
--- a/core/collection-factory/api/src/main/java/org/eclipse/rdf4j/collection/factory/impl/DefaultCollectionFactory.java
+++ b/core/collection-factory/api/src/main/java/org/eclipse/rdf4j/collection/factory/impl/DefaultCollectionFactory.java
@@ -19,7 +19,10 @@
import java.util.Map;
import java.util.Queue;
import java.util.Set;
+import java.util.function.BiConsumer;
import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
import java.util.function.ToIntFunction;
import org.eclipse.rdf4j.collection.factory.api.BindingSetKey;
@@ -27,6 +30,7 @@
import org.eclipse.rdf4j.common.exception.RDF4JException;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.query.BindingSet;
+import org.eclipse.rdf4j.query.MutableBindingSet;
/**
* A DefaultCollectionFactory that provides lists/sets/maps using standard common java in memory types
@@ -54,7 +58,9 @@ public Set createValueSet() {
}
@Override
- public Set createSetOfBindingSets() {
+ public Set createSetOfBindingSets(Supplier create,
+ Function> getHas, Function> getget,
+ Function> getSet) {
return new HashSet<>();
}
@@ -97,5 +103,4 @@ public BindingSetKey createBindingSetKey(BindingSet bindingSet, Listorg.mapdbmapdb
+ 1.0.8org.openjdk.jmh
@@ -46,10 +47,6 @@
maven-assembly-plugin
-
- com.github.siom79.japicmp
- japicmp-maven-plugin
-
diff --git a/core/collection-factory/mapdb/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDbCollectionFactory.java b/core/collection-factory/mapdb/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDbCollectionFactory.java
index 3b757a67a40..c77a1a9cf92 100644
--- a/core/collection-factory/mapdb/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDbCollectionFactory.java
+++ b/core/collection-factory/mapdb/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDbCollectionFactory.java
@@ -21,7 +21,10 @@
import java.util.Map;
import java.util.Queue;
import java.util.Set;
+import java.util.function.BiConsumer;
import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
import java.util.function.ToIntFunction;
import org.eclipse.rdf4j.collection.factory.api.BindingSetKey;
@@ -30,6 +33,7 @@
import org.eclipse.rdf4j.common.exception.RDF4JException;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.query.BindingSet;
+import org.eclipse.rdf4j.query.MutableBindingSet;
import org.mapdb.DB;
import org.mapdb.DBMaker;
@@ -89,6 +93,14 @@ public List createValueList() {
return delegate.createValueList();
}
+ @Override
+ public Set createSetOfBindingSets(Supplier create,
+ Function> getHas, Function> getget,
+ Function> getSet) {
+ // No optimizations here
+ return createSetOfBindingSets();
+ }
+
@Override
public Set createSetOfBindingSets() {
if (iterationCacheSyncThreshold > 0) {
diff --git a/core/collection-factory/mapdb/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/benchmark/BindingSetMapBenchmark.java b/core/collection-factory/mapdb/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/benchmark/BindingSetMapBenchmark.java
new file mode 100644
index 00000000000..82abf7012f4
--- /dev/null
+++ b/core/collection-factory/mapdb/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/benchmark/BindingSetMapBenchmark.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.collection.factory.mapdb.benchmark;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.rdf4j.collection.factory.api.CollectionFactory;
+import org.eclipse.rdf4j.collection.factory.mapdb.MapDbCollectionFactory;
+import org.eclipse.rdf4j.model.ValueFactory;
+import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
+import org.eclipse.rdf4j.query.BindingSet;
+import org.eclipse.rdf4j.query.MutableBindingSet;
+import org.eclipse.rdf4j.query.impl.MapBindingSet;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+
+@State(Scope.Benchmark)
+@Warmup(iterations = 5)
+@BenchmarkMode({ Mode.AverageTime })
+@Fork(value = 1, jvmArgs = { "-Xms1G", "-Xmx1G" })
+@Measurement(iterations = 5)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
+public class BindingSetMapBenchmark {
+ private static final ValueFactory vf = SimpleValueFactory.getInstance();
+ @Param(value = { "1000", "10000" })
+ public int size;
+
+ @Param(value = { "1", "129" })
+ public int bsSize;
+
+ @Benchmark
+ public long saveBindingSets() {
+
+ try (CollectionFactory cf = new MapDbCollectionFactory(1000)) {
+ final Set sbs = cf.createSetOfBindingSets();
+ addBindingSetOfSizeX(sbs, bsSize);
+ return sbs.size();
+ }
+ }
+
+ private void addBindingSetOfSizeX(final Set sbs, int bsSize) {
+ for (int i = 0; i < size; i++) {
+ MutableBindingSet bs = new MapBindingSet();
+ for (int j = 0; j < bsSize; j++) {
+ bs.addBinding(Integer.toString(j), vf.createLiteral(i));
+ }
+ sbs.add(bs);
+ }
+ }
+}
diff --git a/core/common/util/pom.xml b/core/collection-factory/mapdb3/pom.xml
similarity index 69%
rename from core/common/util/pom.xml
rename to core/collection-factory/mapdb3/pom.xml
index 119d738a85d..de753e98014 100644
--- a/core/common/util/pom.xml
+++ b/core/collection-factory/mapdb3/pom.xml
@@ -3,22 +3,32 @@
4.0.0org.eclipse.rdf4j
- rdf4j-common
+ rdf4j-collection-factory5.0.0-SNAPSHOT
- rdf4j-common-util
- RDF4J: common utilities
- RDF4J common utility classes
+ rdf4j-collection-factory-mapdb3
+ RDF4J: Collection Factory - Map DB v3 backed
+ Evaluation${project.groupId}
- rdf4j-model-api
+ rdf4j-collection-factory-api
+ ${project.version}
+
+
+ ${project.groupId}
+ rdf4j-model${project.version}org.slf4jslf4j-api
+
+ org.mapdb
+ mapdb
+ 3.0.9
+ org.openjdk.jmhjmh-core
diff --git a/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/BindingSetKeySerializer.java b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/BindingSetKeySerializer.java
new file mode 100644
index 00000000000..3e94235690f
--- /dev/null
+++ b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/BindingSetKeySerializer.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.collection.factory.mapdb;
+
+import java.io.IOException;
+
+import org.eclipse.rdf4j.collection.factory.api.BindingSetKey;
+import org.eclipse.rdf4j.collection.factory.mapdb.MapDb3CollectionFactory.RDF4jMapDB3Exception;
+import org.eclipse.rdf4j.model.Value;
+import org.mapdb.DataInput2;
+import org.mapdb.DataOutput2;
+import org.mapdb.Serializer;
+import org.mapdb.serializer.SerializerBoolean;
+import org.mapdb.serializer.SerializerIntegerPacked;
+
+class BindingSetKeySerializer implements Serializer {
+
+ private final SerializerBoolean sb = new SerializerBoolean();
+ private final SerializerIntegerPacked si = new SerializerIntegerPacked();
+ private final Serializer vs;
+
+ public BindingSetKeySerializer(Serializer vs) {
+ this.vs = vs;
+ }
+
+ @Override
+ public void serialize(DataOutput2 out, BindingSetKey value) throws IOException {
+ if (value == null) {
+ sb.serialize(out, true);
+ } else {
+ sb.serialize(out, false);
+ try {
+ MapDb3BindingSetKey k = (MapDb3BindingSetKey) value;
+ si.serialize(out, k.hashCode());
+ si.serialize(out, k.values.length);
+ for (int i = 0; i < k.values.length; i++) {
+ vs.serialize(out, k.values[i]);
+ }
+ } catch (ClassCastException e) {
+ throw new RDF4jMapDB3Exception("Collection factory overriden in an non conformat way", e);
+ }
+ }
+
+ }
+
+ @Override
+ public BindingSetKey deserialize(DataInput2 input, int available) throws IOException {
+ if (sb.deserialize(input, available)) {
+ return null;
+ } else {
+ int hashCode = si.deserialize(input, available);
+ int length = si.deserialize(input, available);
+ Value[] values = new Value[length];
+ for (int i = 0; i < length; i++) {
+ values[i] = vs.deserialize(input, available);
+ }
+ return new MapDb3BindingSetKey(values, hashCode);
+ }
+ }
+
+}
diff --git a/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/BindingSetSerializer.java b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/BindingSetSerializer.java
new file mode 100644
index 00000000000..25cbcc62186
--- /dev/null
+++ b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/BindingSetSerializer.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.collection.factory.mapdb;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+import org.eclipse.rdf4j.model.Value;
+import org.eclipse.rdf4j.query.BindingSet;
+import org.eclipse.rdf4j.query.MutableBindingSet;
+import org.mapdb.DataInput2;
+import org.mapdb.DataOutput2;
+import org.mapdb.Serializer;
+import org.mapdb.serializer.SerializerBoolean;
+import org.mapdb.serializer.SerializerIntegerPacked;
+
+class BindingSetSerializer implements Serializer {
+
+ // Insertion order is very important
+ private final LinkedHashSet names = new LinkedHashSet();
+ private final List> has = new ArrayList<>();
+ private final List> get = new ArrayList<>();
+ private final List> set = new ArrayList<>();
+ private final Serializer vs;
+ private final SerializerBoolean sb = new SerializerBoolean();
+ private final SerializerIntegerPacked si = new SerializerIntegerPacked();
+ private final Supplier create;
+ private final Function> getHas;
+ private final Function> getGet;
+ private final Function> getSet;
+
+ public BindingSetSerializer(Serializer valueSerializer, Supplier create,
+ Function> getHas, Function> getGet,
+ Function> getSet) {
+ this.vs = valueSerializer;
+ this.create = create;
+ this.getHas = getHas;
+ this.getGet = getGet;
+ this.getSet = getSet;
+ }
+
+ @Override
+ public void serialize(DataOutput2 out, BindingSet bs) throws IOException {
+
+ final Set bindingNames = bs.getBindingNames();
+ if (names.addAll(bindingNames)) {
+ // new name found
+ int i = has.size();
+ final Iterator nameI = names.iterator();
+ // Don't get setters that we already got.
+ while (nameI.hasNext() && i > 0) {
+ i--;
+ }
+ while (nameI.hasNext()) {
+ String name = nameI.next();
+ has.add(getHas.apply(name));
+ get.add(getGet.apply(name));
+ set.add(getSet.apply(name));
+ }
+ }
+ // all binding names where present
+ for (int i = 0; i < has.size(); i++) {
+ if (has.get(i).test(bs)) {
+ sb.serialize(out, true);
+ si.serialize(out, i);
+ vs.serialize(out, get.get(i).apply(bs));
+ }
+ }
+ sb.serialize(out, false); // marks the end
+ }
+
+ @Override
+ public BindingSet deserialize(DataInput2 input, int available) throws IOException {
+ boolean hasMore = sb.deserialize(input, available);
+ MutableBindingSet bs = create.get();
+ while (hasMore) {
+ int nextName = si.deserialize(input, available);
+ Value nextValue = vs.deserialize(input, available);
+ set.get(nextName).accept(nextValue, bs);
+ hasMore = sb.deserialize(input, available);
+ }
+ return bs;
+ }
+
+}
diff --git a/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDb3BindingSetKey.java b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDb3BindingSetKey.java
new file mode 100644
index 00000000000..adde1d26dff
--- /dev/null
+++ b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDb3BindingSetKey.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.collection.factory.mapdb;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.rdf4j.collection.factory.api.BindingSetKey;
+import org.eclipse.rdf4j.model.Value;
+
+class MapDb3BindingSetKey implements BindingSetKey {
+ final Value[] values;
+
+ private final int hash;
+
+ public MapDb3BindingSetKey(List values, int hash) {
+ this.values = values.toArray(new Value[0]);
+ this.hash = hash;
+ }
+
+ public MapDb3BindingSetKey(Value[] values, int hash) {
+ this.values = values;
+ this.hash = hash;
+ }
+
+ @Override
+ public int hashCode() {
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof MapDb3BindingSetKey && other.hashCode() == hash) {
+ return Arrays.deepEquals(values, ((MapDb3BindingSetKey) other).values);
+ }
+ return false;
+ }
+}
diff --git a/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDb3CollectionFactory.java b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDb3CollectionFactory.java
new file mode 100644
index 00000000000..ef1a94956e1
--- /dev/null
+++ b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/MapDb3CollectionFactory.java
@@ -0,0 +1,410 @@
+/*******************************************************************************
+ * Copyright (c) 2022 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.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.collection.factory.mapdb;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.ToIntFunction;
+
+import org.eclipse.rdf4j.collection.factory.api.BindingSetKey;
+import org.eclipse.rdf4j.collection.factory.api.CollectionFactory;
+import org.eclipse.rdf4j.collection.factory.impl.DefaultCollectionFactory;
+import org.eclipse.rdf4j.common.exception.RDF4JException;
+import org.eclipse.rdf4j.model.Value;
+import org.eclipse.rdf4j.query.BindingSet;
+import org.eclipse.rdf4j.query.MutableBindingSet;
+import org.mapdb.DB;
+import org.mapdb.DB.HashMapMaker;
+import org.mapdb.DBException;
+import org.mapdb.DBMaker;
+import org.mapdb.DBMaker.Maker;
+import org.mapdb.HTreeMap;
+import org.mapdb.Serializer;
+import org.mapdb.serializer.SerializerJava;
+
+public class MapDb3CollectionFactory implements CollectionFactory {
+ // The size 16 seems like a nice starting value but others could well
+ // be better.
+ private static final int SWITCH_TO_DISK_BASED_SET_AT_SIZE = 16;
+ protected volatile DB db;
+ protected volatile long colectionId = 0;
+ protected final long iterationCacheSyncThreshold;
+ private final CollectionFactory delegate;
+ // The chances that someone would run a 32bit non "sun" vm are just miniscule
+ // So I am not going to worry about this.
+ private static final boolean ON_32_BIT_VM = "32".equals(System.getProperty("sun.arch.data.model"));
+
+ protected static final class RDF4jMapDB3Exception extends RDF4JException {
+
+ private static final long serialVersionUID = 1L;
+
+ public RDF4jMapDB3Exception(String string, Exception e) {
+ super(string, e);
+ }
+
+ }
+
+ public MapDb3CollectionFactory(long iterationCacheSyncThreshold) {
+ this(iterationCacheSyncThreshold, new DefaultCollectionFactory());
+ }
+
+ public MapDb3CollectionFactory(long iterationCacheSyncThreshold, CollectionFactory delegate) {
+
+ this.iterationCacheSyncThreshold = iterationCacheSyncThreshold;
+ this.delegate = delegate;
+ }
+
+ protected void init() {
+ if (this.db == null) {
+ synchronized (this) {
+ if (this.db == null) {
+ try {
+ final Maker dbmaker = DBMaker.tempFileDB().closeOnJvmShutdown();
+ // On 32 bit machines this may fail to often so guard it.
+ if (!ON_32_BIT_VM) {
+ // mmap is much faster than random access file.
+ dbmaker.fileMmapEnable();
+ }
+ this.db = dbmaker.make();
+ } catch (DBException e) {
+ throw new RDF4jMapDB3Exception("could not initialize temp db", e);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public List createList() {
+ return delegate.createList();
+ }
+
+ @Override
+ public List createValueList() {
+ return delegate.createValueList();
+ }
+
+ @Override
+ public Set createSetOfBindingSets(Supplier create,
+ Function> getHas, Function> getget,
+ Function> getSet) {
+ if (iterationCacheSyncThreshold > 0) {
+ init();
+ Serializer serializer = createBindingSetSerializer(create, getHas, getget, getSet);
+ MemoryTillSizeXSet set = new MemoryTillSizeXSet<>(colectionId++,
+ delegate.createSetOfBindingSets(), serializer);
+ return new CommitingSet<>(set, iterationCacheSyncThreshold, db);
+ } else {
+ return delegate.createSetOfBindingSets();
+ }
+ }
+
+ @Override
+ public Set createSet() {
+ if (iterationCacheSyncThreshold > 0) {
+ init();
+ Serializer serializer = createAnySerializer();
+ MemoryTillSizeXSet set = new MemoryTillSizeXSet(colectionId++, delegate.createSet(), serializer);
+ return new CommitingSet(set, iterationCacheSyncThreshold, db);
+ } else {
+ return delegate.createSet();
+ }
+ }
+
+ @Override
+ public Set createValueSet() {
+ if (iterationCacheSyncThreshold > 0) {
+ init();
+ Serializer serializer = createValueSerializer();
+ Set set = new MemoryTillSizeXSet<>(colectionId++, delegate.createValueSet(), serializer);
+ return new CommitingSet(set, iterationCacheSyncThreshold, db);
+ } else {
+ return delegate.createValueSet();
+ }
+ }
+
+ @Override
+ public Map createMap() {
+ if (iterationCacheSyncThreshold > 0) {
+ init();
+ Serializer keySerializer = createAnySerializer();
+ Serializer valueSerializer = createAnySerializer();
+ HashMapMaker hashMap = db.hashMap(Long.toHexString(colectionId++), keySerializer, valueSerializer);
+ HTreeMap create = hashMap.create();
+ return new CommitingMap<>(create, iterationCacheSyncThreshold, db);
+ } else {
+ return delegate.createMap();
+ }
+ }
+
+ @Override
+ public Map createValueKeyedMap() {
+ if (iterationCacheSyncThreshold > 0) {
+ init();
+ Serializer keySerializer = createValueSerializer();
+ Serializer valueSerializer = createAnySerializer();
+ return new CommitingMap<>(
+ db.hashMap(Long.toHexString(colectionId++), keySerializer, valueSerializer).create(),
+ iterationCacheSyncThreshold, db);
+ } else {
+ return delegate.createValueKeyedMap();
+ }
+ }
+
+ @Override
+ public Queue createQueue() {
+ return delegate.createQueue();
+ }
+
+ @Override
+ public Queue createValueQueue() {
+ return delegate.createValueQueue();
+ }
+
+ @Override
+ public void close() throws RDF4JException {
+ if (db != null) {
+ db.close();
+ }
+ }
+
+ @Override
+ public Map createGroupByMap() {
+ if (iterationCacheSyncThreshold > 0) {
+ init();
+ Serializer keySerializer = createBindingSetKeySerializer();
+ Serializer valueSerializer = createAnySerializer();
+ return new CommitingMap<>(
+ db.hashMap(Long.toHexString(colectionId++), keySerializer, valueSerializer).create(),
+ iterationCacheSyncThreshold, db);
+ } else {
+ return delegate.createGroupByMap();
+ }
+ }
+
+ @Override
+ public final BindingSetKey createBindingSetKey(BindingSet bindingSet, List> getValues,
+ ToIntFunction hashOfBindingSetCalculator) {
+ List values = new ArrayList<>(getValues.size());
+ for (int i = 0; i < getValues.size(); i++) {
+ values.add(getValues.get(i).apply(bindingSet));
+ }
+ return new MapDb3BindingSetKey(values, hashOfBindingSetCalculator.applyAsInt(bindingSet));
+ }
+
+ protected static final class CommitingSet extends AbstractSet {
+ private final Set wrapped;
+ private final long iterationCacheSyncThreshold;
+ private final DB db;
+ private long iterationCount;
+
+ public CommitingSet(Set wrapped, long iterationCacheSyncThreshold, DB db) {
+ super();
+ this.wrapped = wrapped;
+ this.iterationCacheSyncThreshold = iterationCacheSyncThreshold;
+ this.db = db;
+ }
+
+ @Override
+ public boolean add(T e) {
+
+ boolean res = wrapped.add(e);
+ if (iterationCount++ % iterationCacheSyncThreshold == 0) {
+ // write to disk every $iterationCacheSyncThreshold items
+ db.commit();
+ }
+ return res;
+
+ }
+
+ @Override
+ public boolean addAll(Collection extends T> c) {
+ boolean res = wrapped.addAll(c);
+ if (iterationCount + c.size() % iterationCacheSyncThreshold == 0) {
+ // write to disk every $iterationCacheSyncThreshold items
+ db.commit();
+ }
+ return res;
+ }
+
+ @Override
+ public Iterator iterator() {
+ return wrapped.iterator();
+ }
+
+ @Override
+ public int size() {
+ return wrapped.size();
+ }
+ }
+
+ protected static final class CommitingMap extends AbstractMap {
+ private final Map wrapped;
+ private final long iterationCacheSyncThreshold;
+ private final DB db;
+ private long iterationCount;
+
+ public CommitingMap(Map wrapped, long iterationCacheSyncThreshold, DB db) {
+ super();
+ this.wrapped = wrapped;
+ this.iterationCacheSyncThreshold = iterationCacheSyncThreshold;
+ this.db = db;
+ }
+
+ @Override
+ public V put(K k, V v) {
+
+ V res = wrapped.put(k, v);
+ if (iterationCount++ % iterationCacheSyncThreshold == 0) {
+ // write to disk every $iterationCacheSyncThreshold items
+ db.commit();
+ }
+ return res;
+
+ }
+
+ @Override
+ public int size() {
+ return wrapped.size();
+ }
+
+ @Override
+ public Set> entrySet() {
+ return wrapped.entrySet();
+ }
+ }
+
+ /**
+ * Only create a disk based set once the contents are large enough that it starts to pay off.
+ *
+ * @param of the contents of the set.
+ */
+ protected class MemoryTillSizeXSet extends AbstractSet {
+ private Set wrapped;
+ private final long setName;
+ private final Serializer valueSerializer;
+
+ public MemoryTillSizeXSet(long setName, Set wrapped, Serializer valueSerializer) {
+ super();
+ this.setName = setName;
+ this.wrapped = wrapped;
+ this.valueSerializer = valueSerializer;
+ }
+
+ @Override
+ public boolean add(V e) {
+ if (wrapped instanceof HashSet && wrapped.size() > SWITCH_TO_DISK_BASED_SET_AT_SIZE) {
+ Set disk = db.hashSet(Long.toHexString(setName), valueSerializer).create();
+ disk.addAll(wrapped);
+ wrapped = disk;
+ }
+ return wrapped.add(e);
+ }
+
+ @Override
+ public boolean addAll(Collection extends V> arg0) {
+ if (wrapped instanceof HashSet && arg0.size() > SWITCH_TO_DISK_BASED_SET_AT_SIZE) {
+ Set disk = db.hashSet(Long.toHexString(setName), valueSerializer).create();
+ disk.addAll(wrapped);
+ wrapped = disk;
+ }
+ return wrapped.addAll(arg0);
+ }
+
+ @Override
+ public void clear() {
+ wrapped.clear();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return wrapped.contains(o);
+ }
+
+ @Override
+ public boolean containsAll(Collection> arg0) {
+ return wrapped.containsAll(arg0);
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return wrapped.isEmpty();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ return wrapped.remove(o);
+ }
+
+ @Override
+ public boolean retainAll(Collection> c) {
+ return wrapped.retainAll(c);
+ }
+
+ @Override
+ public Object[] toArray() {
+ return wrapped.toArray();
+ }
+
+ @Override
+ public T[] toArray(T[] arg0) {
+ return wrapped.toArray(arg0);
+ }
+
+ @Override
+ public Iterator iterator() {
+ return wrapped.iterator();
+ }
+
+ @Override
+ public int size() {
+ return wrapped.size();
+ }
+
+ }
+
+ /**
+ * These methods should be overriding in case a store can deliver a better serialization protocol.
+ *
+ * @param getGet
+ * @param getHas
+ * @param create
+ */
+ protected Serializer createBindingSetSerializer(Supplier create,
+ Function> getHas, Function> getGet,
+ Function> getSet) {
+ return new BindingSetSerializer(createValueSerializer(), create, getHas, getGet, getSet);
+ }
+
+ protected Serializer createAnySerializer() {
+ return new SerializerJava();
+ }
+
+ protected Serializer createValueSerializer() {
+ return new ValueSerializer();
+ }
+
+ protected final Serializer createBindingSetKeySerializer() {
+ return new BindingSetKeySerializer(createValueSerializer());
+ }
+}
diff --git a/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/ValueSerializer.java b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/ValueSerializer.java
new file mode 100644
index 00000000000..c371b4a1549
--- /dev/null
+++ b/core/collection-factory/mapdb3/src/main/java/org/eclipse/rdf4j/collection/factory/mapdb/ValueSerializer.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.collection.factory.mapdb;
+
+import java.io.IOException;
+import java.util.Optional;
+
+import org.eclipse.rdf4j.model.BNode;
+import org.eclipse.rdf4j.model.IRI;
+import org.eclipse.rdf4j.model.Literal;
+import org.eclipse.rdf4j.model.Resource;
+import org.eclipse.rdf4j.model.Triple;
+import org.eclipse.rdf4j.model.Value;
+import org.eclipse.rdf4j.model.ValueFactory;
+import org.eclipse.rdf4j.model.base.CoreDatatype;
+import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
+import org.mapdb.DataInput2;
+import org.mapdb.DataOutput2;
+import org.mapdb.Serializer;
+import org.mapdb.serializer.SerializerIntegerPacked;
+import org.mapdb.serializer.SerializerString;
+
+/**
+ * A minimally optimized serializer for values.
+ *
+ * @author Jerven Bolleman
+ */
+class ValueSerializer implements Serializer {
+ private static final int IS_NEW_COREDATATYPE = 5;
+ private static final int IS_RDF_DATATYPE = 4;
+ private static final int IS_GEO_DATATYPE = 3;
+ private static final int IS_XSD_DATATYPE = 2;
+ private static final int NOT_COREDATYPE = 1;
+ private static final int IS_LANGUAGE = 0;
+ private static final int IS_BNODE = 0;
+ private static final int IS_IRI = 1;
+ private static final int IS_LITERAL = 2;
+ private static final int IS_TRIPLE = 3;
+ private static final int IS_NULL = 4;
+ private final SerializerIntegerPacked si = new SerializerIntegerPacked();
+ private final SerializerString ss = new SerializerString();
+ private final ValueFactory vf;
+
+ public ValueSerializer() {
+ this(SimpleValueFactory.getInstance());
+ }
+
+ public ValueSerializer(ValueFactory vf) {
+ super();
+ this.vf = vf;
+ }
+
+ @Override
+ public void serialize(DataOutput2 out, Value value) throws IOException {
+ if (value instanceof BNode) {
+ si.serialize(out, IS_BNODE);
+ serializeBNode(out, (BNode) value);
+ } else if (value instanceof IRI) {
+ si.serialize(out, IS_IRI);
+ serializeIRI(out, (IRI) value);
+ } else if (value instanceof Literal) {
+ si.serialize(out, IS_LITERAL);
+ serializeLiteral(out, (Literal) value);
+ } else if (value instanceof Triple) {
+ si.serialize(out, IS_TRIPLE);
+ serializeTriple(out, (Triple) value);
+ } else {
+ si.serialize(out, IS_NULL);
+ }
+ }
+
+ private void serializeBNode(DataOutput2 out, BNode bnode) throws IOException {
+ ss.serialize(out, bnode.getID());
+ }
+
+ private void serializeLiteral(DataOutput2 out, Literal value) throws IOException {
+ final Optional language = value.getLanguage();
+ if (language.isPresent()) {
+ si.serialize(out, IS_LANGUAGE);
+ ss.serialize(out, value.stringValue());
+ ss.serialize(out, language.get());
+ } else {
+ final CoreDatatype cd = value.getCoreDatatype();
+ if (cd == null) {
+ si.serialize(out, NOT_COREDATYPE);
+ serializeIRI(out, value.getDatatype());
+ } else if (cd.isXSDDatatype()) {
+ si.serialize(out, IS_XSD_DATATYPE);
+ si.serialize(out, ((CoreDatatype.XSD) cd).ordinal());
+ // TODO optimize the storage of valid pure int etc.
+ // without needing to parse strings
+ } else if (cd.isGEODatatype()) {
+ si.serialize(out, IS_GEO_DATATYPE);
+ si.serialize(out, ((CoreDatatype.GEO) cd).ordinal());
+ } else if (cd.isRDFDatatype()) {
+ si.serialize(out, IS_RDF_DATATYPE);
+ si.serialize(out, ((CoreDatatype.RDF) cd).ordinal());
+ } else {
+ si.serialize(out, IS_NEW_COREDATATYPE);
+ serializeIRI(out, value.getDatatype());
+ }
+ ss.serialize(out, value.stringValue());
+ }
+ }
+
+ private void serializeIRI(DataOutput2 out, IRI value) throws IOException {
+ ss.serialize(out, value.stringValue());
+ }
+
+ private void serializeTriple(DataOutput2 out, Triple value) throws IOException {
+ serialize(out, value.getSubject());
+ serialize(out, value.getPredicate());
+ serialize(out, value.getObject());
+ }
+
+ @Override
+ public Value deserialize(DataInput2 input, int available) throws IOException {
+ int t = si.deserialize(input, available);
+ switch (t) {
+ case IS_BNODE:
+ return deserializeBnode(input, available);
+ case IS_IRI:
+ return deserializeIRI(input, available);
+ case IS_LITERAL:
+ return deserializeLiteral(input, available);
+ case IS_TRIPLE:
+ return deserializeTriple(input, available);
+ case IS_NULL:
+ default:
+ return null;
+ }
+ }
+
+ private Value deserializeTriple(DataInput2 input, int available) throws IOException {
+ final Resource subj = (Resource) deserialize(input, available);
+ final IRI pred = (IRI) deserialize(input, available);
+ final Value obj = deserialize(input, available);
+ return vf.createTriple(subj, pred, obj);
+ }
+
+ private Value deserializeLiteral(DataInput2 input, int available) throws IOException {
+ int t = si.deserialize(input, available);
+ switch (t) {
+ case IS_LANGUAGE: {
+ String language = ss.deserialize(input, available);
+ String value = ss.deserialize(input, available);
+ return vf.createLiteral(value, language);
+ }
+ case NOT_COREDATYPE: {
+ IRI datatype = deserializeIRI(input, available);
+ String value = ss.deserialize(input, available);
+ return vf.createLiteral(value, datatype);
+ }
+ case IS_XSD_DATATYPE: {
+ CoreDatatype.XSD datatype = CoreDatatype.XSD.values()[si.deserialize(input, available)];
+ String value = ss.deserialize(input, available);
+ return vf.createLiteral(value, datatype);
+ }
+ case IS_GEO_DATATYPE: {
+ CoreDatatype.GEO datatype = CoreDatatype.GEO.values()[si.deserialize(input, available)];
+ String value = ss.deserialize(input, available);
+ return vf.createLiteral(value, datatype);
+ }
+ case IS_RDF_DATATYPE: {
+ CoreDatatype.RDF datatype = CoreDatatype.RDF.values()[si.deserialize(input, available)];
+ String value = ss.deserialize(input, available);
+ return vf.createLiteral(value, datatype);
+ }
+ case IS_NEW_COREDATATYPE: {
+ IRI datatype = deserializeIRI(input, available);
+ String value = ss.deserialize(input, available);
+ return vf.createLiteral(value, datatype);
+ }
+ }
+ return null;
+ }
+
+ private IRI deserializeIRI(DataInput2 input, int available) throws IOException {
+ return vf.createIRI(ss.deserialize(input, available));
+ }
+
+ private BNode deserializeBnode(DataInput2 input, int available) throws IOException {
+ return vf.createBNode(ss.deserialize(input, available));
+ }
+
+}
diff --git a/core/collection-factory/mapdb3/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/BindingSetSerializerTest.java b/core/collection-factory/mapdb3/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/BindingSetSerializerTest.java
new file mode 100644
index 00000000000..bcd3c179ac3
--- /dev/null
+++ b/core/collection-factory/mapdb3/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/BindingSetSerializerTest.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.collection.factory.mapdb;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.io.IOException;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+import org.eclipse.rdf4j.model.Value;
+import org.eclipse.rdf4j.model.ValueFactory;
+import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
+import org.eclipse.rdf4j.query.BindingSet;
+import org.eclipse.rdf4j.query.MutableBindingSet;
+import org.eclipse.rdf4j.query.impl.MapBindingSet;
+import org.junit.jupiter.api.Test;
+import org.mapdb.DataInput2;
+import org.mapdb.DataOutput2;
+
+public class BindingSetSerializerTest {
+ private static final ValueFactory vf = SimpleValueFactory.getInstance();
+
+ @Test
+ void noBinding() throws IOException {
+ BindingSet toSerialize = new MapBindingSet();
+ final BindingSetSerializer valueSerializer = createSerializer();
+ final BindingSet deserialized = serializeDeserialize(toSerialize, valueSerializer);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void oneBinding() throws IOException {
+ MapBindingSet toSerialize = new MapBindingSet();
+ toSerialize.setBinding("a", vf.createLiteral(1));
+ final BindingSetSerializer valueSerializer = createSerializer();
+ final BindingSet deserialized = serializeDeserialize(toSerialize, valueSerializer);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void twoBinding() throws IOException {
+ MapBindingSet toSerialize = new MapBindingSet();
+ toSerialize.setBinding("a", vf.createLiteral(1));
+ toSerialize.setBinding("v", vf.createLiteral(1));
+ final BindingSetSerializer valueSerializer = createSerializer();
+ final BindingSet deserialized = serializeDeserialize(toSerialize, valueSerializer);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void secondBindingIri() throws IOException {
+ final BindingSetSerializer valueSerializer = createSerializer();
+
+ MapBindingSet toSerialize = new MapBindingSet();
+ toSerialize.setBinding("a", vf.createLiteral(1));
+ toSerialize.setBinding("v", vf.createIRI("http://example.org/lala"));
+ BindingSet deserialized = serializeDeserialize(toSerialize, valueSerializer);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void multipleNumbersOfBindingsIri() throws IOException {
+ final BindingSetSerializer valueSerializer = createSerializer();
+
+ MapBindingSet toSerialize = new MapBindingSet();
+ toSerialize.setBinding("a", vf.createLiteral(1));
+ toSerialize.setBinding("v", vf.createIRI("http://example.org/lala"));
+ BindingSet deserialized = serializeDeserialize(toSerialize, valueSerializer);
+ assertEquals(toSerialize, deserialized);
+
+ toSerialize = new MapBindingSet();
+ toSerialize.setBinding("a", vf.createLiteral(2));
+ deserialized = serializeDeserialize(toSerialize, valueSerializer);
+ assertEquals(toSerialize, deserialized);
+
+ toSerialize = new MapBindingSet();
+ toSerialize.setBinding("a", vf.createLiteral(1));
+ toSerialize.setBinding("b", vf.createLiteral(4));
+ toSerialize.setBinding("c", vf.createLiteral(1));
+ deserialized = serializeDeserialize(toSerialize, valueSerializer);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ private BindingSet serializeDeserialize(BindingSet oneInt, BindingSetSerializer valueSerializer)
+ throws IOException {
+
+ final DataOutput2 dataOutput2 = new DataOutput2();
+ valueSerializer.serialize(dataOutput2, oneInt);
+
+ final DataInput2 input = new DataInput2.ByteArray(dataOutput2.copyBytes());
+ BindingSet doneInt = valueSerializer.deserialize(input, 0);
+ return doneInt;
+ }
+
+ private BindingSetSerializer createSerializer() {
+ Function> getHas = (n) -> {
+ return (b) -> b.hasBinding(n);
+ };
+ Function> getGet = (n) -> {
+ return (b) -> b.getValue(n);
+ };
+ Function> getSet = (n) -> {
+ return (v, b) -> b.setBinding(n, v);
+ };
+ final BindingSetSerializer valueSerializer = new BindingSetSerializer(new ValueSerializer(vf),
+ MapBindingSet::new, getHas, getGet, getSet);
+ return valueSerializer;
+ }
+}
diff --git a/core/collection-factory/mapdb3/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/ValueSerializerTest.java b/core/collection-factory/mapdb3/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/ValueSerializerTest.java
new file mode 100644
index 00000000000..46e35e10f03
--- /dev/null
+++ b/core/collection-factory/mapdb3/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/ValueSerializerTest.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.collection.factory.mapdb;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.eclipse.rdf4j.model.IRI;
+import org.eclipse.rdf4j.model.Literal;
+import org.eclipse.rdf4j.model.Value;
+import org.eclipse.rdf4j.model.ValueFactory;
+import org.eclipse.rdf4j.model.base.CoreDatatype;
+import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
+import org.junit.jupiter.api.Test;
+import org.mapdb.DataInput2;
+import org.mapdb.DataOutput2;
+
+public class ValueSerializerTest {
+ private static final ValueFactory vf = SimpleValueFactory.getInstance();
+
+ @Test
+ void literalOneInt() throws IOException {
+ Literal oneInt = vf.createLiteral(1);
+ Value doneInt = serializeDeserialize(oneInt);
+ assertEquals(oneInt, doneInt);
+ }
+
+ @Test
+ void literalOneIntCoreDatatype() throws IOException {
+ Literal oneInt = vf.createLiteral("1", CoreDatatype.XSD.INT);
+ Value doneInt = serializeDeserialize(oneInt);
+ assertEquals(oneInt, doneInt);
+ }
+
+ @Test
+ void literalTwoInt() throws IOException {
+ Literal twoInt = vf.createLiteral(2);
+ Value dTwoInt = serializeDeserialize(twoInt);
+ assertEquals(twoInt, dTwoInt);
+ }
+
+ @Test
+ void literalTwoFloat() throws IOException {
+ Literal toSerialize = vf.createLiteral(2.0f);
+ Value deserialized = serializeDeserialize(toSerialize);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void literalTwoDouble() throws IOException {
+ Literal toSerialize = vf.createLiteral(2.0d);
+ Value deserialized = serializeDeserialize(toSerialize);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void literalTwoBigInteger() throws IOException {
+ Literal toSerialize = vf.createLiteral(BigInteger.valueOf(20000000));
+ Value deserialized = serializeDeserialize(toSerialize);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void literalTwoBigDecimal() throws IOException {
+ Literal toSerialize = vf.createLiteral(BigDecimal.valueOf(20000030.3443));
+ Value deserialized = serializeDeserialize(toSerialize);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void iriExampleOrg() throws IOException {
+ Value toSerialize = vf.createIRI("https://example.org/lala");
+ Value deserialized = serializeDeserialize(toSerialize);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void tripleOfExampleOrg() throws IOException {
+ final IRI iri = vf.createIRI("https://example.org/lala");
+ Value toSerialize = vf.createTriple(iri, iri, iri);
+ Value deserialized = serializeDeserialize(toSerialize);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void bnode() throws IOException {
+ Value toSerialize = vf.createBNode("111");
+ Value deserialized = serializeDeserialize(toSerialize);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ @Test
+ void newCoreDatatype() throws IOException {
+ CoreDatatype n = new CoreDatatype() {
+
+ @Override
+ public IRI getIri() {
+ return vf.createIRI("https://example.org/lala");
+ }
+
+ };
+ Value toSerialize = vf.createLiteral("111", n);
+ Value deserialized = serializeDeserialize(toSerialize);
+ assertEquals(toSerialize, deserialized);
+ }
+
+ private Value serializeDeserialize(Value oneInt) throws IOException {
+ final ValueSerializer valueSerializer = new ValueSerializer(vf);
+ final DataOutput2 dataOutput2 = new DataOutput2();
+ valueSerializer.serialize(dataOutput2, oneInt);
+
+ final DataInput2 input = new DataInput2.ByteArray(dataOutput2.copyBytes());
+ Value doneInt = valueSerializer.deserialize(input, 0);
+ return doneInt;
+ }
+}
diff --git a/core/collection-factory/mapdb3/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/benchmark/BindingSetMapBenchmark.java b/core/collection-factory/mapdb3/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/benchmark/BindingSetMapBenchmark.java
new file mode 100644
index 00000000000..26135eaade5
--- /dev/null
+++ b/core/collection-factory/mapdb3/src/test/java/org/eclipse/rdf4j/collection/factory/mapdb/benchmark/BindingSetMapBenchmark.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2023 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.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.collection.factory.mapdb.benchmark;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.rdf4j.collection.factory.api.CollectionFactory;
+import org.eclipse.rdf4j.collection.factory.mapdb.MapDb3CollectionFactory;
+import org.eclipse.rdf4j.model.ValueFactory;
+import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
+import org.eclipse.rdf4j.query.BindingSet;
+import org.eclipse.rdf4j.query.MutableBindingSet;
+import org.eclipse.rdf4j.query.impl.MapBindingSet;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+
+@State(Scope.Benchmark)
+@Warmup(iterations = 5)
+@BenchmarkMode({ Mode.AverageTime })
+@Fork(value = 1, jvmArgs = { "-Xms1G", "-Xmx1G" })
+@Measurement(iterations = 5)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
+public class BindingSetMapBenchmark {
+ private static final ValueFactory vf = SimpleValueFactory.getInstance();
+ @Param(value = { "1000", "10000" })
+ public int size;
+
+ @Param(value = { "1", "129" })
+ public int bsSize;
+
+ @Benchmark
+ public long saveBindingSets() {
+
+ try (CollectionFactory cf = new MapDb3CollectionFactory(1000)) {
+ final Set sbs = cf.createSetOfBindingSets();
+ addBindingSetOfSizeX(sbs, bsSize);
+ return sbs.size();
+ }
+ }
+
+ private void addBindingSetOfSizeX(final Set sbs, int bsSize) {
+ for (int i = 0; i < size; i++) {
+ MutableBindingSet bs = new MapBindingSet();
+ for (int j = 0; j < bsSize; j++) {
+ bs.addBinding(Integer.toString(j), vf.createLiteral(i));
+ }
+ sbs.add(bs);
+ }
+ }
+}
diff --git a/core/collection-factory/pom.xml b/core/collection-factory/pom.xml
index 830295ba9af..2309b0ce29b 100644
--- a/core/collection-factory/pom.xml
+++ b/core/collection-factory/pom.xml
@@ -11,6 +11,7 @@
apimapdb
+ mapdb3RDF4J: Collection Factory that may be sharedCollection Factories that may be reused for RDF4J
diff --git a/core/common/annotation/pom.xml b/core/common/annotation/pom.xml
index 34f82702201..b3c8df98930 100644
--- a/core/common/annotation/pom.xml
+++ b/core/common/annotation/pom.xml
@@ -14,10 +14,6 @@
maven-assembly-plugin
-
- com.github.siom79.japicmp
- japicmp-maven-plugin
-
diff --git a/core/common/exception/pom.xml b/core/common/exception/pom.xml
index 7956636e262..9b6dd2b2976 100644
--- a/core/common/exception/pom.xml
+++ b/core/common/exception/pom.xml
@@ -26,10 +26,6 @@
maven-assembly-plugin
-
- com.github.siom79.japicmp
- japicmp-maven-plugin
-
diff --git a/core/common/io/pom.xml b/core/common/io/pom.xml
index 54789b47e21..4bbf5246908 100644
--- a/core/common/io/pom.xml
+++ b/core/common/io/pom.xml
@@ -15,11 +15,6 @@
rdf4j-model-api${project.version}
-
- ${project.groupId}
- rdf4j-common-util
- ${project.version}
- org.slf4jslf4j-api
@@ -42,10 +37,6 @@
maven-assembly-plugin
-
- com.github.siom79.japicmp
- japicmp-maven-plugin
-
diff --git a/core/common/io/src/main/java/org/eclipse/rdf4j/common/lang/ObjectUtil.java b/core/common/io/src/main/java/org/eclipse/rdf4j/common/lang/ObjectUtil.java
index a4a10db2582..ef1c6884c18 100644
--- a/core/common/io/src/main/java/org/eclipse/rdf4j/common/lang/ObjectUtil.java
+++ b/core/common/io/src/main/java/org/eclipse/rdf4j/common/lang/ObjectUtil.java
@@ -20,20 +20,6 @@
*/
public class ObjectUtil {
- /**
- * Compares two objects or null references.
- *
- * @param o1 The first object.
- * @param o2 The second object
- * @return true if both objects are null, if the object references are identical, or if the
- * objects are equal according to the {@link Object#equals} method of the first object; false in
- * all other situations.
- */
- @Deprecated(since = "4.0.0", forRemoval = true)
- public static boolean nullEquals(Object o1, Object o2) {
- return Objects.equals(o1, o2);
- }
-
/**
* Returns the hash code of the supplied object, or 0 if a null reference is supplied.
*
diff --git a/core/common/io/src/test/java/org/eclipse/rdf4j/common/net/ParsedIRITest.java b/core/common/io/src/test/java/org/eclipse/rdf4j/common/net/ParsedIRITest.java
index 2fa71a554bd..5c9c9053241 100644
--- a/core/common/io/src/test/java/org/eclipse/rdf4j/common/net/ParsedIRITest.java
+++ b/core/common/io/src/test/java/org/eclipse/rdf4j/common/net/ParsedIRITest.java
@@ -19,7 +19,6 @@
import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
@@ -60,7 +59,7 @@ public void hostWithLeadingDigit() {
}
@Test
- public void testIncorrectIPv4() throws URISyntaxException {
+ public void testIncorrectIPv4() {
assertThrows(URISyntaxException.class, () -> new ParsedIRI("http://127.0.0.256/"));
}
@@ -74,7 +73,7 @@ public void testUnknownSchemeHostProcessing() throws URISyntaxException {
}
@Test
- public void testHttpSchemeHostProcessing() throws URISyntaxException {
+ public void testHttpSchemeHostProcessing() {
assertThrows(URISyntaxException.class, () -> new ParsedIRI("http://385.fwk19480900/test.ttl"));
}
@@ -471,7 +470,7 @@ public void testSubDelimInPath() throws Exception {
}
@Test
- public void testIllegalInPath() throws Exception {
+ public void testIllegalInPath() {
for (char g : ILLEGAL.toCharArray()) {
try {
new ParsedIRI(BASE + g);
@@ -499,7 +498,7 @@ public void testSubDelimsInQuery() throws Exception {
}
@Test
- public void testIllegalInQuery() throws Exception {
+ public void testIllegalInQuery() {
for (char g : ILLEGAL.toCharArray()) {
try {
new ParsedIRI(QUERY + g);
@@ -527,7 +526,7 @@ public void testSubDelimsInFragment() throws Exception {
}
@Test
- public void testIllegalInFragment() throws Exception {
+ public void testIllegalInFragment() {
for (char g : ILLEGAL.toCharArray()) {
try {
new ParsedIRI(FRAGMENT + g);
@@ -538,7 +537,7 @@ public void testIllegalInFragment() throws Exception {
}
}
- private String encode(Character chr) throws UnsupportedEncodingException {
+ private String encode(Character chr) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] source = Character.toString(chr).getBytes(StandardCharsets.UTF_8);
for (byte c : source) {
diff --git a/core/common/io/src/test/java/org/eclipse/rdf4j/common/net/ParsedURITest.java b/core/common/io/src/test/java/org/eclipse/rdf4j/common/net/ParsedURITest.java
index 9fb18fd9474..338066b7433 100644
--- a/core/common/io/src/test/java/org/eclipse/rdf4j/common/net/ParsedURITest.java
+++ b/core/common/io/src/test/java/org/eclipse/rdf4j/common/net/ParsedURITest.java
@@ -15,8 +15,6 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.net.URISyntaxException;
-
import org.junit.jupiter.api.Test;
/**
@@ -86,150 +84,150 @@ public void resolvesAPathAbsoluteUriRelativeToABaseJarUri() {
}
@Test
- public void testRoundTripQueryString() throws Exception {
+ public void testRoundTripQueryString() {
assertRoundTrip(
"http://localhost:8080/callimachus/pipelines/render-html.xpl?result&template=http%3A%2F%2Flocalhost%3A8080%2Fcallimachus%2Fconcept-view.xhtml%3Ftemplate%26realm%3Dhttp%3A%2F%2Flocalhost%3A8080%2F&this=http%3A%2F%2Flocalhost%3A8080%2Fsun&query=view");
}
- private void assertRoundTrip(String uri) throws URISyntaxException {
+ private void assertRoundTrip(String uri) {
assertResolves(uri, "http://example.com/", uri);
}
@Test
- public void testParentFile() throws URISyntaxException {
+ public void testParentFile() {
assertResolves("../dir", "http://example.com/dir/dir/file", "http://example.com/dir/dir");
}
@Test
- public void testRootFile() throws URISyntaxException {
+ public void testRootFile() {
assertResolves("/dir", "http://example.com/dir/dir", "http://example.com/dir");
}
@Test
- public void testFrag() throws URISyntaxException {
+ public void testFrag() {
assertResolves("#frag", "http://example.com/dir/dir/file?qs#frag", "http://example.com/dir/dir/file?qs#frag");
}
@Test
- public void testIdentity() throws URISyntaxException {
+ public void testIdentity() {
assertResolves("", "http://example.com/dir/dir/file?qs", "http://example.com/dir/dir/file?qs");
}
@Test
- public void testOpaque() throws URISyntaxException {
+ public void testOpaque() {
assertResolves("urn:test", "http://example.com/dir/dir/file?qs#frag", "urn:test");
}
@Test
- public void testFragment() throws URISyntaxException {
+ public void testFragment() {
assertResolves("#frag2", "http://example.com/dir/dir/file?qs#frag", "http://example.com/dir/dir/file?qs#frag2");
}
@Test
- public void testQueryString() throws URISyntaxException {
+ public void testQueryString() {
assertResolves("?qs2#frag", "http://example.com/dir/dir/file?qs#frag",
"http://example.com/dir/dir/file?qs2#frag");
}
@Test
- public void testDirectory() throws URISyntaxException {
+ public void testDirectory() {
assertResolves(".", "http://example.com/dir/dir/file?qs#frag", "http://example.com/dir/dir/");
}
@Test
- public void testSameDirectory() throws URISyntaxException {
+ public void testSameDirectory() {
assertResolves("file2?qs#frag", "http://example.com/dir/dir/file?qs#frag",
"http://example.com/dir/dir/file2?qs#frag");
}
@Test
- public void testNestedDirectory() throws URISyntaxException {
+ public void testNestedDirectory() {
assertResolves("nested/file?qs#frag", "http://example.com/dir/dir/file?qs#frag",
"http://example.com/dir/dir/nested/file?qs#frag");
}
@Test
- public void testParentDirectory() throws URISyntaxException {
+ public void testParentDirectory() {
assertResolves("../file?qs#frag", "http://example.com/dir/dir/file?qs#frag",
"http://example.com/dir/file?qs#frag");
}
@Test
- public void testOtherDirectory() throws URISyntaxException {
+ public void testOtherDirectory() {
assertResolves("../dir2/file?qs#frag", "http://example.com/dir/dir/file?qs#frag",
"http://example.com/dir/dir2/file?qs#frag");
}
@Test
- public void testSameAuthority() throws URISyntaxException {
+ public void testSameAuthority() {
assertResolves("/dir2/dir/file?qs#frag", "http://example.com/dir/dir/file?qs#frag",
"http://example.com/dir2/dir/file?qs#frag");
}
@Test
- public void testIdentityDir() throws URISyntaxException {
+ public void testIdentityDir() {
assertResolves("", "http://example.com/dir/dir/", "http://example.com/dir/dir/");
}
@Test
- public void testOpaqueDir() throws URISyntaxException {
+ public void testOpaqueDir() {
assertResolves("urn:test", "http://example.com/dir/dir/", "urn:test");
}
@Test
- public void testFragmentDir() throws URISyntaxException {
+ public void testFragmentDir() {
assertResolves("#frag2", "http://example.com/dir/dir/", "http://example.com/dir/dir/#frag2");
}
@Test
- public void testQueryStringDir() throws URISyntaxException {
+ public void testQueryStringDir() {
assertResolves("?qs2", "http://example.com/dir/dir/", "http://example.com/dir/dir/?qs2");
}
@Test
- public void testDirectoryDir() throws URISyntaxException {
+ public void testDirectoryDir() {
assertResolves("file", "http://example.com/dir/dir/", "http://example.com/dir/dir/file");
}
@Test
- public void testSameDirectoryDir() throws URISyntaxException {
+ public void testSameDirectoryDir() {
assertResolves("file2?qs#frag", "http://example.com/dir/dir/", "http://example.com/dir/dir/file2?qs#frag");
}
@Test
- public void testNestedDirectoryDir() throws URISyntaxException {
+ public void testNestedDirectoryDir() {
assertResolves("nested/", "http://example.com/dir/dir/", "http://example.com/dir/dir/nested/");
}
@Test
- public void testNestedDirectoryFileDir() throws URISyntaxException {
+ public void testNestedDirectoryFileDir() {
assertResolves("nested/file?qs#frag", "http://example.com/dir/dir/",
"http://example.com/dir/dir/nested/file?qs#frag");
}
@Test
- public void testParentDirectoryDir() throws URISyntaxException {
+ public void testParentDirectoryDir() {
assertResolves("../file?qs#frag", "http://example.com/dir/dir/", "http://example.com/dir/file?qs#frag");
}
@Test
- public void testOtherDirectoryDir() throws URISyntaxException {
+ public void testOtherDirectoryDir() {
assertResolves("../dir2/", "http://example.com/dir/dir/", "http://example.com/dir/dir2/");
}
@Test
- public void testOtherDirectoryFileDir() throws URISyntaxException {
+ public void testOtherDirectoryFileDir() {
assertResolves("../dir2/file?qs#frag", "http://example.com/dir/dir/",
"http://example.com/dir/dir2/file?qs#frag");
}
@Test
- public void testSameAuthorityDir() throws URISyntaxException {
+ public void testSameAuthorityDir() {
assertResolves("/dir2/dir/file?qs#frag", "http://example.com/dir/dir/",
"http://example.com/dir2/dir/file?qs#frag");
}
- private void assertResolves(String relative, String base, String absolute) throws URISyntaxException {
+ private void assertResolves(String relative, String base, String absolute) {
assertEquals(absolute, new ParsedURI(base).resolve(relative).toString());
}
diff --git a/core/common/iterator/pom.xml b/core/common/iterator/pom.xml
index 664bce3ecc6..c2e21734002 100644
--- a/core/common/iterator/pom.xml
+++ b/core/common/iterator/pom.xml
@@ -37,10 +37,6 @@
maven-assembly-plugin
-
- com.github.siom79.japicmp
- japicmp-maven-plugin
-
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/AbstractCloseableIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/AbstractCloseableIteration.java
index 7c0162491b9..ab86f83225e 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/AbstractCloseableIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/AbstractCloseableIteration.java
@@ -18,7 +18,7 @@
* Instances of this class is not safe to be accessed from multiple threads at the same time.
*/
@Deprecated(since = "4.1.0")
-public abstract class AbstractCloseableIteration implements CloseableIteration {
+public abstract class AbstractCloseableIteration implements CloseableIteration {
/*-----------*
* Variables *
@@ -46,7 +46,7 @@ public final boolean isClosed() {
* Calls {@link #handleClose()} upon first call and makes sure the resource closures are only executed once.
*/
@Override
- public final void close() throws X {
+ public final void close() {
if (!closed) {
closed = true;
handleClose();
@@ -59,6 +59,6 @@ public final void close() throws X {
*
* @throws X
*/
- protected void handleClose() throws X {
+ protected void handleClose() {
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIteration.java
index a9cf2cf9285..c270ae65115 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIteration.java
@@ -11,13 +11,14 @@
package org.eclipse.rdf4j.common.iteration;
+import java.util.Iterator;
import java.util.stream.Stream;
/**
- * An {@link Iteration} that can be closed to free resources that it is holding. CloseableIterations automatically free
- * their resources when exhausted. If not read until exhaustion or if you want to make sure the iteration is properly
- * closed, any code using the iterator should be placed in a try-with-resources block, closing the iteration
- * automatically, e.g.:
+ * An {@link CloseableIteration} that can be closed to free resources that it is holding. CloseableIterations
+ * automatically free their resources when exhausted. If not read until exhaustion or if you want to make sure the
+ * iteration is properly closed, any code using the iterator should be placed in a try-with-resources block, closing the
+ * iteration automatically, e.g.:
*
*
*
@@ -29,13 +30,13 @@
* }
*
*
- * @deprecated In the future this interface will stop extending {@link Iteration} and instead declare the same interface
- * methods directly. The interface will also stop requiring implementations to automatically close when
- * exhausted, instead making this an optional feature and requiring the user to always call close. This
+ * @deprecated In the future this interface will stop extending {@link CloseableIteration} and instead declare the same
+ * interface methods directly. The interface will also stop requiring implementations to automatically close
+ * when exhausted, instead making this an optional feature and requiring the user to always call close. This
* interface may also be removed.
*/
@Deprecated(since = "4.1.0")
-public interface CloseableIteration extends Iteration, AutoCloseable {
+public interface CloseableIteration extends Iterator, AutoCloseable {
/**
* Convert the results to a Java 8 Stream.
@@ -51,6 +52,6 @@ default Stream stream() {
* invoking this method has no effect.
*/
@Override
- void close() throws X;
+ void close();
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIterationSpliterator.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIterationSpliterator.java
index ea80e62105b..38dc7b3003d 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIterationSpliterator.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIterationSpliterator.java
@@ -19,9 +19,9 @@
/**
* A {@link Spliterator} implementation that wraps a {@link CloseableIteration}.
*/
-class CloseableIterationSpliterator extends Spliterators.AbstractSpliterator {
+class CloseableIterationSpliterator extends Spliterators.AbstractSpliterator {
- private final CloseableIteration iteration;
+ private final CloseableIteration iteration;
/**
* Creates a {@link Spliterator} implementation that wraps the supplied {@link CloseableIteration}. It handles
@@ -30,7 +30,7 @@ class CloseableIterationSpliterator extends Spliterators
*
* @param iteration the iteration to wrap
*/
- public CloseableIterationSpliterator(CloseableIteration iteration) {
+ public CloseableIterationSpliterator(CloseableIteration iteration) {
super(Long.MAX_VALUE, Spliterator.IMMUTABLE | Spliterator.NONNULL);
this.iteration = iteration;
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIteratorIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIteratorIteration.java
index b07d142c225..fa3bb0ad987 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIteratorIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/CloseableIteratorIteration.java
@@ -19,7 +19,7 @@
* An Iteration that can convert an {@link Iterator} to a {@link CloseableIteration}.
*/
@Deprecated(since = "4.1.0")
-public class CloseableIteratorIteration extends AbstractCloseableIteration {
+public class CloseableIteratorIteration extends AbstractCloseableIteration {
private Iterator extends E> iter;
@@ -46,7 +46,7 @@ protected boolean hasIterator() {
}
@Override
- public boolean hasNext() throws X {
+ public boolean hasNext() {
if (isClosed()) {
return false;
}
@@ -59,7 +59,7 @@ public boolean hasNext() throws X {
}
@Override
- public E next() throws X {
+ public E next() {
if (isClosed()) {
throw new NoSuchElementException("Iteration has been closed");
}
@@ -68,7 +68,7 @@ public E next() throws X {
}
@Override
- public void remove() throws X {
+ public void remove() {
if (isClosed()) {
throw new IllegalStateException("Iteration has been closed");
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ConvertingIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ConvertingIteration.java
index eace1cd3e35..6fbf65bc55f 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ConvertingIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ConvertingIteration.java
@@ -19,7 +19,7 @@
* over objects of type T (the target type).
*/
@Deprecated(since = "4.1.0")
-public abstract class ConvertingIteration extends AbstractCloseableIteration {
+public abstract class ConvertingIteration extends AbstractCloseableIteration {
/*-----------*
* Variables *
@@ -28,7 +28,7 @@ public abstract class ConvertingIteration extends Abs
/**
* The source type iteration.
*/
- private final Iteration extends S, ? extends X> iter;
+ private final CloseableIteration extends S> iter;
/*--------------*
* Constructors *
@@ -39,7 +39,7 @@ public abstract class ConvertingIteration extends Abs
*
* @param iter The source type iteration for this ConvertingIteration, must not be null.
*/
- protected ConvertingIteration(Iteration extends S, ? extends X> iter) {
+ protected ConvertingIteration(CloseableIteration extends S> iter) {
this.iter = Objects.requireNonNull(iter, "The iterator was null");
}
@@ -50,16 +50,16 @@ protected ConvertingIteration(Iteration extends S, ? extends X> iter) {
/**
* Converts a source type object to a target type object.
*/
- protected abstract T convert(S sourceObject) throws X;
+ protected abstract T convert(S sourceObject);
/**
* Checks whether the source type iteration contains more elements.
*
* @return true if the source type iteration contains more elements, false otherwise.
- * @throws X
+ *
*/
@Override
- public boolean hasNext() throws X {
+ public boolean hasNext() {
if (isClosed()) {
return false;
}
@@ -73,12 +73,12 @@ public boolean hasNext() throws X {
/**
* Returns the next element from the source type iteration.
*
- * @throws X
+ *
* @throws java.util.NoSuchElementException If all elements have been returned.
* @throws IllegalStateException If the iteration has been closed.
*/
@Override
- public T next() throws X {
+ public T next() {
if (isClosed()) {
throw new NoSuchElementException("The iteration has been closed.");
}
@@ -94,7 +94,7 @@ public T next() throws X {
* {@link #next}.
*/
@Override
- public void remove() throws X {
+ public void remove() {
if (isClosed()) {
throw new IllegalStateException("The iteration has been closed.");
}
@@ -105,11 +105,11 @@ public void remove() throws X {
* Closes this iteration as well as the wrapped iteration if it is a {@link CloseableIteration}.
*/
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
try {
super.handleClose();
} finally {
- Iterations.closeCloseable(iter);
+ iter.close();
}
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DelayedIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DelayedIteration.java
index 715c5cd7a52..012c31fe2ac 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DelayedIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DelayedIteration.java
@@ -20,13 +20,13 @@
* createIteration method, which is called once when the iteration is first needed.
*/
@Deprecated(since = "4.1.0")
-public abstract class DelayedIteration extends AbstractCloseableIteration {
+public abstract class DelayedIteration extends AbstractCloseableIteration {
/*-----------*
* Variables *
*-----------*/
- private Iteration extends E, ? extends X> iter;
+ private CloseableIteration extends E> iter;
/*--------------*
* Constructors *
@@ -47,17 +47,17 @@ protected DelayedIteration() {
* Creates the iteration that should be iterated over. This method is called only once, when the iteration is first
* needed.
*/
- protected abstract Iteration extends E, ? extends X> createIteration() throws X;
+ protected abstract CloseableIteration extends E> createIteration();
/**
* Calls the hasNext method of the underlying iteration.
*/
@Override
- public boolean hasNext() throws X {
+ public boolean hasNext() {
if (isClosed()) {
return false;
}
- Iteration extends E, ? extends X> resultIter = iter;
+ CloseableIteration extends E> resultIter = iter;
if (resultIter == null) {
// Underlying iterator has not yet been initialized
resultIter = iter;
@@ -73,11 +73,11 @@ public boolean hasNext() throws X {
* Calls the next method of the underlying iteration.
*/
@Override
- public E next() throws X {
+ public E next() {
if (isClosed()) {
throw new NoSuchElementException("Iteration has been closed");
}
- Iteration extends E, ? extends X> resultIter = iter;
+ CloseableIteration extends E> resultIter = iter;
if (resultIter == null) {
// Underlying iterator has not yet been initialized
resultIter = iter;
@@ -93,11 +93,11 @@ public E next() throws X {
* Calls the remove method of the underlying iteration.
*/
@Override
- public void remove() throws X {
+ public void remove() {
if (isClosed()) {
throw new IllegalStateException("The iteration has been closed.");
}
- Iteration extends E, ? extends X> resultIter = iter;
+ CloseableIteration extends E> resultIter = iter;
if (resultIter == null) {
throw new IllegalStateException("Underlying iteration was null");
}
@@ -110,13 +110,12 @@ public void remove() throws X {
* {@link CloseableIteration}.
*/
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
try {
super.handleClose();
} finally {
- Iteration extends E, ? extends X> toClose = iter;
- if (toClose != null) {
- Iterations.closeCloseable(toClose);
+ if (iter != null) {
+ iter.close();
}
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DistinctIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DistinctIteration.java
index a66c1c15df9..c065273e45a 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DistinctIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DistinctIteration.java
@@ -19,7 +19,7 @@
* An Iteration that filters any duplicate elements from an underlying iterator.
*/
@Deprecated(since = "4.1.0")
-public class DistinctIteration extends FilterIteration {
+public class DistinctIteration extends FilterIteration {
/*-----------*
* Variables *
@@ -39,13 +39,13 @@ public class DistinctIteration extends FilterIteration iter) {
+ public DistinctIteration(CloseableIteration extends E> iter) {
super(iter);
excludeSet = makeSet();
}
- public DistinctIteration(Iteration extends E, ? extends X> iter, Supplier> setMaker) {
+ public DistinctIteration(CloseableIteration extends E> iter, Supplier> setMaker) {
super(iter);
excludeSet = setMaker.get();
}
@@ -58,7 +58,7 @@ public DistinctIteration(Iteration extends E, ? extends X> iter, Suppliertrue if the specified object hasn't been seen before.
*/
@Override
- protected boolean accept(E object) throws X {
+ protected boolean accept(E object) {
if (inExcludeSet(object)) {
// object has already been returned
return false;
@@ -79,7 +79,7 @@ private boolean inExcludeSet(E object) {
/**
* @param object to put into the set
*/
- protected boolean add(E object) throws X {
+ protected boolean add(E object) {
return excludeSet.add(object);
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DualUnionIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DualUnionIteration.java
index 1a252992ad2..e8db59efdfb 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DualUnionIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/DualUnionIteration.java
@@ -17,24 +17,24 @@
* Provides a bag union of the two provided iterations.
*/
@Deprecated(since = "4.1.0")
-public class DualUnionIteration implements CloseableIteration {
+public class DualUnionIteration implements CloseableIteration {
- private CloseableIteration extends E, X> iteration1;
- private CloseableIteration extends E, X> iteration2;
+ private CloseableIteration extends E> iteration1;
+ private CloseableIteration extends E> iteration2;
private E nextElement;
/**
* Flag indicating whether this iteration has been closed.
*/
private boolean closed = false;
- private DualUnionIteration(CloseableIteration extends E, X> iteration1,
- CloseableIteration extends E, X> iteration2) {
+ private DualUnionIteration(CloseableIteration extends E> iteration1,
+ CloseableIteration extends E> iteration2) {
this.iteration1 = iteration1;
this.iteration2 = iteration2;
}
- public static CloseableIteration extends E, X> getWildcardInstance(
- CloseableIteration extends E, X> leftIteration, CloseableIteration extends E, X> rightIteration) {
+ public static CloseableIteration extends E> getWildcardInstance(
+ CloseableIteration extends E> leftIteration, CloseableIteration extends E> rightIteration) {
if (rightIteration instanceof EmptyIteration) {
return leftIteration;
@@ -45,8 +45,8 @@ public static CloseableIteration extends E, X> getWil
}
}
- public static CloseableIteration getInstance(CloseableIteration leftIteration,
- CloseableIteration rightIteration) {
+ public static CloseableIteration getInstance(CloseableIteration leftIteration,
+ CloseableIteration rightIteration) {
if (rightIteration instanceof EmptyIteration) {
return leftIteration;
@@ -57,7 +57,7 @@ public static CloseableIteration getInstance(Clos
}
}
- public E getNextElement() throws X {
+ public E getNextElement() {
if (iteration1 == null && iteration2 != null) {
if (iteration2.hasNext()) {
return iteration2.next();
@@ -84,7 +84,7 @@ public E getNextElement() throws X {
}
@Override
- public final boolean hasNext() throws X {
+ public final boolean hasNext() {
if (closed) {
return false;
}
@@ -93,7 +93,7 @@ public final boolean hasNext() throws X {
}
@Override
- public final E next() throws X {
+ public final E next() {
if (closed) {
throw new NoSuchElementException("The iteration has been closed.");
}
@@ -113,7 +113,7 @@ public final E next() throws X {
* @return The next element, or null if there are no more results.
* @throws X If there is an issue getting the next element or closing the iteration.
*/
- private E lookAhead() throws X {
+ private E lookAhead() {
if (nextElement == null) {
nextElement = getNextElement();
@@ -133,7 +133,7 @@ public void remove() {
}
@Override
- public final void close() throws X {
+ public final void close() {
if (!closed) {
closed = true;
nextElement = null;
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/EmptyIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/EmptyIteration.java
index e7c452c9ea9..f8c6961e781 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/EmptyIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/EmptyIteration.java
@@ -21,7 +21,7 @@
* CloseableIteration directly.
*/
@Deprecated(since = "4.1.0")
-public final class EmptyIteration extends AbstractCloseableIteration {
+public final class EmptyIteration extends AbstractCloseableIteration {
/*--------------*
* Constructors *
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ExceptionConvertingIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ExceptionConvertingIteration.java
index 29dfc421a5d..de3459baab1 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ExceptionConvertingIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ExceptionConvertingIteration.java
@@ -19,7 +19,8 @@
* Subclasses need to override {@link #convert(Exception)} to do the conversion.
*/
@Deprecated(since = "4.1.0")
-public abstract class ExceptionConvertingIteration extends AbstractCloseableIteration {
+public abstract class ExceptionConvertingIteration
+ extends AbstractCloseableIteration {
/*-----------*
* Variables *
@@ -28,7 +29,7 @@ public abstract class ExceptionConvertingIteration exten
/**
* The underlying Iteration.
*/
- private final Iteration extends E, ? extends Exception> iter;
+ private final CloseableIteration extends E> iter;
/*--------------*
* Constructors *
@@ -40,7 +41,7 @@ public abstract class ExceptionConvertingIteration exten
* @param iter The Iteration that this ExceptionConvertingIteration operates on, must not be
* null.
*/
- protected ExceptionConvertingIteration(Iteration extends E, ? extends Exception> iter) {
+ protected ExceptionConvertingIteration(CloseableIteration extends E> iter) {
this.iter = Objects.requireNonNull(iter, "The iterator was null");
}
@@ -51,7 +52,7 @@ protected ExceptionConvertingIteration(Iteration extends E, ? extends Exceptio
/**
* Converts an exception from the underlying iteration to an exception of type X.
*/
- protected abstract X convert(Exception e);
+ protected abstract X convert(RuntimeException e);
/**
* Checks whether the underlying Iteration contains more elements.
@@ -60,7 +61,7 @@ protected ExceptionConvertingIteration(Iteration extends E, ? extends Exceptio
* @throws X
*/
@Override
- public boolean hasNext() throws X {
+ public boolean hasNext() {
if (isClosed()) {
return false;
}
@@ -70,10 +71,7 @@ public boolean hasNext() throws X {
close();
}
return result;
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
+ } catch (RuntimeException e) {
throw convert(e);
}
}
@@ -86,7 +84,7 @@ public boolean hasNext() throws X {
* @throws IllegalStateException If the Iteration has been closed.
*/
@Override
- public E next() throws X {
+ public E next() {
if (isClosed()) {
throw new NoSuchElementException("The iteration has been closed.");
}
@@ -97,10 +95,7 @@ public E next() throws X {
throw e;
} catch (IllegalStateException e) {
throw e;
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
+ } catch (RuntimeException e) {
throw convert(e);
}
}
@@ -114,7 +109,7 @@ public E next() throws X {
* {@link #next}.
*/
@Override
- public void remove() throws X {
+ public void remove() {
if (isClosed()) {
throw new IllegalStateException("The iteration has been closed.");
}
@@ -122,10 +117,7 @@ public void remove() throws X {
iter.remove();
} catch (UnsupportedOperationException | IllegalStateException e) {
throw e;
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
+ } catch (RuntimeException e) {
throw convert(e);
}
}
@@ -134,16 +126,13 @@ public void remove() throws X {
* Closes this Iteration as well as the wrapped Iteration if it happens to be a {@link CloseableIteration} .
*/
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
try {
super.handleClose();
} finally {
try {
- Iterations.closeCloseable(iter);
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
+ iter.close();
+ } catch (RuntimeException e) {
throw convert(e);
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/FilterIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/FilterIteration.java
index 67cbdc59c9b..e57b758e29a 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/FilterIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/FilterIteration.java
@@ -18,7 +18,7 @@
* must implement the accept method to indicate which objects should be returned.
*/
@Deprecated(since = "4.1.0")
-public abstract class FilterIteration extends IterationWrapper {
+public abstract class FilterIteration extends IterationWrapper {
/*-----------*
* Variables *
@@ -33,7 +33,7 @@ public abstract class FilterIteration extends IterationW
/**
* @param iter
*/
- protected FilterIteration(Iteration extends E, ? extends X> iter) {
+ protected FilterIteration(CloseableIteration extends E> iter) {
super(iter);
}
@@ -42,7 +42,7 @@ protected FilterIteration(Iteration extends E, ? extends X> iter) {
*---------*/
@Override
- public boolean hasNext() throws X {
+ public boolean hasNext() {
if (isClosed()) {
return false;
}
@@ -56,7 +56,7 @@ public boolean hasNext() throws X {
}
@Override
- public E next() throws X {
+ public E next() {
if (isClosed()) {
throw new NoSuchElementException("The iteration has been closed.");
}
@@ -73,7 +73,7 @@ public E next() throws X {
}
}
- private void findNextElement() throws X {
+ private void findNextElement() {
try {
while (!isClosed() && nextElement == null && super.hasNext()) {
E candidate = super.next();
@@ -97,10 +97,10 @@ private void findNextElement() throws X {
* @return true if the object should be returned, false otherwise.
* @throws X
*/
- protected abstract boolean accept(E object) throws X;
+ protected abstract boolean accept(E object);
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
try {
super.handleClose();
} finally {
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/InterruptTask.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/InterruptTask.java
index 5db2fc53447..51c958f1a5d 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/InterruptTask.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/InterruptTask.java
@@ -18,17 +18,17 @@
*
* @author Jeen Broekstra
*/
-class InterruptTask extends TimerTask {
+class InterruptTask extends TimerTask {
- private final WeakReference> iterationRef;
+ private final WeakReference> iterationRef;
- public InterruptTask(TimeLimitIteration iteration) {
+ public InterruptTask(TimeLimitIteration iteration) {
this.iterationRef = new WeakReference<>(iteration);
}
@Override
public void run() {
- TimeLimitIteration iteration = iterationRef.get();
+ TimeLimitIteration iteration = iterationRef.get();
if (iteration != null) {
iteration.interrupt();
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IntersectIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IntersectIteration.java
index dda74c1f478..55b495908b8 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IntersectIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IntersectIteration.java
@@ -23,13 +23,13 @@
* bit more overhead as it adds a second hash table lookup.
*/
@Deprecated(since = "4.1.0")
-public class IntersectIteration extends FilterIteration {
+public class IntersectIteration extends FilterIteration {
/*-----------*
* Variables *
*-----------*/
- protected final Iteration extends E, ? extends X> arg2;
+ protected final CloseableIteration extends E> arg2;
private final boolean distinct;
@@ -50,11 +50,11 @@ public class IntersectIteration extends FilterIteration<
* @param arg1 An Iteration containing the first set of elements.
* @param arg2 An Iteration containing the second set of elements.
*/
- public IntersectIteration(Iteration extends E, ? extends X> arg1, Iteration extends E, ? extends X> arg2) {
+ public IntersectIteration(CloseableIteration extends E> arg1, CloseableIteration extends E> arg2) {
this(arg1, arg2, false);
}
- public IntersectIteration(Iteration extends E, ? extends X> arg1, Iteration extends E, ? extends X> arg2,
+ public IntersectIteration(CloseableIteration extends E> arg1, CloseableIteration extends E> arg2,
Supplier> setMaker) {
this(arg1, arg2, false, setMaker);
}
@@ -66,7 +66,7 @@ public IntersectIteration(Iteration extends E, ? extends X> arg1, Iteration
* @param arg2 An Iteration containing the second set of elements.
* @param distinct Flag indicating whether duplicate elements should be filtered from the result.
*/
- public IntersectIteration(Iteration extends E, ? extends X> arg1, Iteration extends E, ? extends X> arg2,
+ public IntersectIteration(CloseableIteration extends E> arg1, CloseableIteration extends E> arg2,
boolean distinct) {
super(arg1);
@@ -85,7 +85,7 @@ public IntersectIteration(Iteration extends E, ? extends X> arg1, Iteration
* @param arg2 An Iteration containing the second set of elements.
* @param distinct Flag indicating whether duplicate elements should be filtered from the result.
*/
- public IntersectIteration(Iteration extends E, ? extends X> arg1, Iteration extends E, ? extends X> arg2,
+ public IntersectIteration(CloseableIteration extends E> arg1, CloseableIteration extends E> arg2,
boolean distinct, Supplier> setMaker) {
super(arg1);
@@ -105,7 +105,7 @@ public IntersectIteration(Iteration extends E, ? extends X> arg1, Iteration
* Returns true if the object is in the set of elements of the second argument.
*/
@Override
- protected boolean accept(E object) throws X {
+ protected boolean accept(E object) {
if (!initialized) {
// Build set of elements-to-include from second argument
includeSet = Iterations.asSet(arg2);
@@ -128,7 +128,7 @@ protected boolean accept(E object) throws X {
}
// this method does not seem to "addSecondSet" since the second set seems to be ignored
- public Set addSecondSet(Iteration extends E, ? extends X> arg2, Set set) throws X {
+ public Set addSecondSet(CloseableIteration extends E> arg2, Set set) {
return Iterations.addAll(arg2, setMaker.get());
}
@@ -145,11 +145,13 @@ protected Set makeSet() {
}
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
try {
super.handleClose();
} finally {
- Iterations.closeCloseable(arg2);
+ if (arg2 != null) {
+ arg2.close();
+ }
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/Iteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/Iteration.java
deleted file mode 100644
index 0768f40662a..00000000000
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/Iteration.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others.
- *
- * 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.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *******************************************************************************/
-
-package org.eclipse.rdf4j.common.iteration;
-
-import java.util.NoSuchElementException;
-import java.util.stream.Stream;
-
-/**
- * An Iteration is a typed Iterator-like object that can throw (typed) Exceptions while iterating. This is used in cases
- * where the iteration is lazy and evaluates over a (remote) connection, for example accessing a database. In such cases
- * an error can occur at any time and needs to be communicated through a checked exception, something
- * {@link java.util.Iterator} can not do (it can only throw {@link RuntimeException}s.
- *
- * @param Object type of objects contained in the iteration.
- * @param Exception type that is thrown when a problem occurs during iteration.
- * @author jeen
- * @author Herko ter Horst
- * @see java.util.Iterator
- * @deprecated For performance and simplification the Iteration interface is deprecated and will be removed in 5.0.0.
- * Use CloseableIteration instead, even if your iteration doesn't require AutoCloseable.
- */
-@Deprecated(since = "4.1.0", forRemoval = true)
-public interface Iteration {
-
- /**
- * Returns true if the iteration has more elements. (In other words, returns true if
- * {@link #next} would return an element rather than throwing a NoSuchElementException.)
- *
- * @return true if the iteration has more elements.
- * @throws X
- */
- boolean hasNext() throws X;
-
- /**
- * Returns the next element in the iteration.
- *
- * @return the next element in the iteration.
- * @throws NoSuchElementException if the iteration has no more elements or if it has been closed.
- */
- E next() throws X;
-
- /**
- * Removes from the underlying collection the last element returned by the iteration (optional operation). This
- * method can be called only once per call to next.
- *
- * @throws UnsupportedOperationException if the remove operation is not supported by this Iteration.
- * @throws IllegalStateException If the Iteration has been closed, or if next() has not yet been
- * called, or remove() has already been called after the last call
- * to next().
- */
- void remove() throws X;
-
- /**
- * Convert the results to a Java 8 Stream. If this iteration implements CloseableIteration it should be closed (by
- * calling Stream#close() or using try-with-resource) if it is not fully consumed.
- *
- * @return stream
- */
- default Stream stream() {
- return Iterations.stream(this);
- }
-}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IterationSpliterator.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IterationSpliterator.java
index 65ec8eee032..c4ef42ca008 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IterationSpliterator.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IterationSpliterator.java
@@ -16,25 +16,25 @@
import java.util.function.Consumer;
/**
- * A {@link Spliterator} implementation that wraps an {@link Iteration}. It handles occurrence of checked exceptions by
- * wrapping them in RuntimeExceptions, and in addition ensures that the wrapped Iteration is closed when exhausted (if
- * it's a {@link CloseableIteration}).
+ * A {@link Spliterator} implementation that wraps an {@link CloseableIteration}. It handles occurrence of checked
+ * exceptions by wrapping them in RuntimeExceptions, and in addition ensures that the wrapped Iteration is closed when
+ * exhausted (if it's a {@link CloseableIteration}).
*
* @author Jeen Broekstra
*/
@Deprecated(since = "4.1.0")
public class IterationSpliterator extends Spliterators.AbstractSpliterator {
- private final Iteration iteration;
+ private final CloseableIteration iteration;
/**
- * Creates a {@link Spliterator} implementation that wraps the supplied {@link Iteration}. It handles occurrence of
- * checked exceptions by wrapping them in RuntimeExceptions, and in addition ensures that the wrapped Iteration is
- * closed when exhausted (if it's a {@link CloseableIteration}).
+ * Creates a {@link Spliterator} implementation that wraps the supplied {@link CloseableIteration}. It handles
+ * occurrence of checked exceptions by wrapping them in RuntimeExceptions, and in addition ensures that the wrapped
+ * Iteration is closed when exhausted (if it's a {@link CloseableIteration}).
*
* @param iteration the iteration to wrap
*/
- public IterationSpliterator(final Iteration iteration) {
+ public IterationSpliterator(final CloseableIteration iteration) {
super(Long.MAX_VALUE, Spliterator.IMMUTABLE | Spliterator.NONNULL);
this.iteration = iteration;
}
@@ -54,18 +54,11 @@ public boolean tryAdvance(Consumer super T> action) {
return true;
}
return false;
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
- if (e instanceof RuntimeException) {
- throw (RuntimeException) e;
- }
- throw new RuntimeException(e);
} finally {
if (needsToBeClosed) {
try {
- Iterations.closeCloseable(iteration);
+ if (iteration != null)
+ iteration.close();
} catch (Exception ignored) {
}
}
@@ -79,17 +72,10 @@ public void forEachRemaining(final Consumer super T> action) {
while (iteration.hasNext()) {
action.accept(iteration.next());
}
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
- if (e instanceof RuntimeException) {
- throw (RuntimeException) e;
- }
- throw new RuntimeException(e);
} finally {
try {
- Iterations.closeCloseable(iteration);
+ if (iteration != null)
+ iteration.close();
} catch (Exception ignored) {
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IterationWrapper.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IterationWrapper.java
index 4c3243e0833..504acb4a8f4 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IterationWrapper.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IterationWrapper.java
@@ -19,7 +19,7 @@
* IterationWrapper should override some of these methods and may also provide additional methods and fields.
*/
@Deprecated(since = "4.1.0")
-public class IterationWrapper extends AbstractCloseableIteration {
+public class IterationWrapper extends AbstractCloseableIteration {
/*-----------*
* Variables *
@@ -31,7 +31,7 @@ public class IterationWrapper extends AbstractCloseableI
* @deprecated This will be changed to private, possibly with an accessor in future. Do not rely on it.
*/
@Deprecated(since = "4.1.0")
- protected final Iteration extends E, ? extends X> wrappedIter;
+ protected final CloseableIteration extends E> wrappedIter;
/*--------------*
* Constructors *
@@ -42,7 +42,7 @@ public class IterationWrapper extends AbstractCloseableI
*
* @param iter The wrapped Iteration for this IterationWrapper, must not be null.
*/
- protected IterationWrapper(Iteration extends E, ? extends X> iter) {
+ protected IterationWrapper(CloseableIteration extends E> iter) {
assert iter != null;
wrappedIter = iter;
}
@@ -57,7 +57,7 @@ protected IterationWrapper(Iteration extends E, ? extends X> iter) {
* @return true if the wrapped Iteration contains more elements, false otherwise.
*/
@Override
- public boolean hasNext() throws X {
+ public boolean hasNext() {
if (isClosed()) {
return false;
} else if (Thread.currentThread().isInterrupted()) {
@@ -77,7 +77,7 @@ public boolean hasNext() throws X {
* @throws java.util.NoSuchElementException If all elements have been returned or it has been closed.
*/
@Override
- public E next() throws X {
+ public E next() {
if (isClosed()) {
throw new NoSuchElementException("The iteration has been closed.");
} else if (Thread.currentThread().isInterrupted()) {
@@ -101,7 +101,7 @@ public E next() throws X {
* {@link #next}.
*/
@Override
- public void remove() throws X {
+ public void remove() {
if (isClosed()) {
throw new IllegalStateException("The iteration has been closed.");
} else if (Thread.currentThread().isInterrupted()) {
@@ -120,11 +120,11 @@ public void remove() throws X {
* Closes this Iteration and also closes the wrapped Iteration if it is a {@link CloseableIteration}.
*/
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
try {
super.handleClose();
} finally {
- Iterations.closeCloseable(wrappedIter);
+ wrappedIter.close();
}
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/Iterations.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/Iterations.java
index 14d5ea67611..28562e8246e 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/Iterations.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/Iterations.java
@@ -15,7 +15,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Set;
-import java.util.Spliterator;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -28,28 +27,13 @@
@Deprecated(since = "4.1.0")
public class Iterations {
- /**
- * Get a List containing all elements obtained from the specified iteration.
- *
- * @param iter the iteration to get the elements from
- * @return a List containing all elements obtained from the specified iteration.
- */
- @Deprecated(since = "4.1.0", forRemoval = true)
- public static List asList(Iteration extends E, X> iter) throws X {
- // stream.collect is slightly slower than addAll for lists
- List list = new ArrayList<>();
-
- // addAll closes the iteration
- return addAll(iter, list);
- }
-
/**
* Get a List containing all elements obtained from the specified iteration.
*
* @param iter the {@link CloseableIteration} to get the elements from
* @return a List containing all elements obtained from the specified iteration.
*/
- public static List asList(CloseableIteration extends E, X> iter) throws X {
+ public static List asList(CloseableIteration extends E> iter) {
try (iter) {
// stream.collect is slightly slower than addAll for lists
List list = new ArrayList<>();
@@ -59,54 +43,18 @@ public static List asList(CloseableIteration exten
}
}
- /**
- * Get a Set containing all elements obtained from the specified iteration.
- *
- * @param iter the iteration to get the elements from
- * @return a Set containing all elements obtained from the specified iteration.
- */
- @Deprecated(since = "4.1.0", forRemoval = true)
- public static Set asSet(Iteration extends E, X> iter) throws X {
- try (Stream extends E> stream = iter.stream()) {
- return stream.collect(Collectors.toSet());
- }
- }
-
/**
* Get a Set containing all elements obtained from the specified iteration.
*
* @param iter the {@link CloseableIteration} to get the elements from
* @return a Set containing all elements obtained from the specified iteration.
*/
- public static Set asSet(CloseableIteration extends E, X> iter) throws X {
+ public static Set asSet(CloseableIteration extends E> iter) {
try (Stream extends E> stream = iter.stream()) {
return stream.collect(Collectors.toSet());
}
}
- /**
- * Adds all elements from the supplied iteration to the specified collection. If the supplied iteration is an
- * instance of {@link CloseableIteration} it is automatically closed after consumption.
- *
- * @param iter An iteration containing elements to add to the container. If the iteration is an instance of
- * {@link CloseableIteration} it is automatically closed after consumption.
- * @param collection The collection to add the elements to.
- * @return The collection object that was supplied to this method.
- */
- @Deprecated(since = "4.1.0", forRemoval = true)
- public static > C addAll(Iteration extends E, X> iter,
- C collection) throws X {
- try {
- while (iter.hasNext()) {
- collection.add(iter.next());
- }
- } finally {
- closeCloseable(iter);
- }
-
- return collection;
- }
-
/**
* Adds all elements from the supplied {@link CloseableIteration} to the specified collection then closes the
* {@link CloseableIteration}.
@@ -115,40 +63,15 @@ public static > C addAll(Iterati
* @param collection The collection to add the elements to.
* @return The collection object that was supplied to this method.
*/
- public static > C addAll(CloseableIteration extends E, X> iter,
- C collection) throws X {
+ public static > C addAll(CloseableIteration extends E> iter,
+ C collection) {
try (iter) {
while (iter.hasNext()) {
collection.add(iter.next());
}
- return collection;
}
- }
-
- /**
- * Get a sequential {@link Stream} with the supplied {@link Iteration} as its source. If the source iteration is a
- * {@link CloseableIteration}, it will be automatically closed by the stream when done. Any checked exceptions
- * thrown at any point during stream processing will be propagated wrapped in a {@link RuntimeException}.
- *
- * @param iteration a source {@link Iteration} for the stream.
- * @return a sequential {@link Stream} object which can be used to process the data from the source iteration.
- */
- @Deprecated(since = "4.1.0", forRemoval = true)
- public static Stream stream(Iteration iteration) {
- Spliterator spliterator = new IterationSpliterator<>(iteration);
- return StreamSupport.stream(spliterator, false).onClose(() -> {
- try {
- Iterations.closeCloseable(iteration);
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
- throw new RuntimeException(e);
- }
- });
+ return collection;
}
/**
@@ -159,7 +82,7 @@ public static Stream stream(Iteration iteration)
* @param iteration a source {@link CloseableIteration} for the stream.
* @return a sequential {@link Stream} object which can be used to process the data from the source iteration.
*/
- public static Stream stream(CloseableIteration iteration) {
+ public static Stream stream(CloseableIteration iteration) {
return StreamSupport
.stream(new CloseableIterationSpliterator<>(iteration), false)
.onClose(() -> {
@@ -176,34 +99,6 @@ public static Stream stream(CloseableIteration it
});
}
- /**
- * Closes the supplied iteration if it is an instance of {@link CloseableIteration}, otherwise the request is
- * ignored.
- *
- * @param iteration The iteration that should be closed.
- */
- @Deprecated(since = "4.1.0", forRemoval = true)
- public static void closeCloseable(Iteration, X> iteration) throws X {
- if (iteration instanceof CloseableIteration, ?>) {
- ((CloseableIteration, X>) iteration).close();
- }
- }
-
- /**
- * Converts an iteration to a string by concatenating all of the string representations of objects in the Iteration,
- * divided by a separator.
- *
- * @param iteration An iteration over arbitrary objects that are expected to implement {@link Object#toString()}.
- * @param separator The separator to insert between the object strings.
- * @return A String representation of the objects provided by the supplied iteration.
- */
- @Deprecated(since = "4.1.0", forRemoval = true)
- public static String toString(Iteration, X> iteration, String separator) throws X {
- StringBuilder sb = new StringBuilder();
- toString(iteration, separator, sb);
- return sb.toString();
- }
-
/**
* Converts a {@link CloseableIteration} to a string by concatenating all the string representations of objects in
* the iteration, divided by a separator.
@@ -213,7 +108,7 @@ public static String toString(Iteration, X> iteration, S
* @param separator The separator to insert between the object strings.
* @return A String representation of the objects provided by the supplied iteration.
*/
- public static String toString(CloseableIteration, X> iteration, String separator) throws X {
+ public static String toString(CloseableIteration> iteration, String separator) {
try (iteration) {
StringBuilder sb = new StringBuilder();
toString(iteration, separator, sb);
@@ -221,27 +116,6 @@ public static String toString(CloseableIteration, X> ite
}
}
- /**
- * Converts an iteration to a string by concatenating all the string representations of objects in the Iteration,
- * divided by a separator.
- *
- * @param iteration An iteration over arbitrary objects that are expected to implement {@link Object#toString()}.
- * @param separator The separator to insert between the object strings.
- * @param sb A StringBuilder to append the iteration string to.
- */
- @Deprecated(since = "4.1.0", forRemoval = true)
- public static void toString(Iteration, X> iteration, String separator, StringBuilder sb)
- throws X {
- while (iteration.hasNext()) {
- sb.append(iteration.next());
-
- if (iteration.hasNext()) {
- sb.append(separator);
- }
- }
-
- }
-
/**
* Converts a {@link CloseableIteration} to a string by concatenating all the string representations of objects in
* the iteration, divided by a separator.
@@ -251,7 +125,7 @@ public static void toString(Iteration, X> iteration, Str
* @param separator The separator to insert between the object strings.
* @param sb A StringBuilder to append the iteration string to.
*/
- public static void toString(CloseableIteration, X> iteration, String separator,
+ public static void toString(CloseableIteration> iteration, String separator,
StringBuilder sb)
throws X {
try (iteration) {
@@ -273,25 +147,8 @@ public static void toString(CloseableIteration, X> itera
* @param setMaker the Supplier that constructs a new set
* @return a Set containing all elements obtained from the specified iteration.
*/
- @Deprecated(since = "4.1.0", forRemoval = true)
- public static Set asSet(Iteration extends E, ? extends X> iteration,
- Supplier> setMaker) throws X {
- Set set = setMaker.get();
- while (iteration.hasNext()) {
- set.add(iteration.next());
- }
- return set;
- }
-
- /**
- * Get a Set containing all elements obtained from the specified iteration.
- *
- * @param iteration the iteration to get the elements from
- * @param setMaker the Supplier that constructs a new set
- * @return a Set containing all elements obtained from the specified iteration.
- */
- public static Set asSet(CloseableIteration extends E, ? extends X> iteration,
- Supplier> setMaker) throws X {
+ public static Set asSet(CloseableIteration extends E> iteration,
+ Supplier> setMaker) {
Set set = setMaker.get();
while (iteration.hasNext()) {
set.add(iteration.next());
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IteratorIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IteratorIteration.java
index 0fab8146c31..9a5e45e6b46 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IteratorIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IteratorIteration.java
@@ -14,10 +14,10 @@
import java.util.Iterator;
/**
- * An Iteration that can convert an {@link Iterator} to a {@link Iteration}.
+ * An Iteration that can convert an {@link Iterator} to a {@link CloseableIteration}.
*/
@Deprecated(since = "4.1.0")
-public class IteratorIteration implements Iteration {
+public class IteratorIteration implements CloseableIteration {
private final Iterator extends E> iter;
@@ -40,4 +40,9 @@ public E next() {
public void remove() {
iter.remove();
}
+
+ @Override
+ public void close() {
+
+ }
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/LimitIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/LimitIteration.java
index 164e4b3c8d0..e3280077856 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/LimitIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/LimitIteration.java
@@ -18,7 +18,7 @@
* class returns the first limit elements from the underlying Iteration and drops the rest.
*/
@Deprecated(since = "4.1.0")
-public class LimitIteration extends IterationWrapper {
+public class LimitIteration extends IterationWrapper {
/*-----------*
* Variables *
@@ -44,7 +44,7 @@ public class LimitIteration extends IterationWrappernull.
* @param limit The number of query answers to return, must be >= 0.
*/
- public LimitIteration(Iteration extends E, X> iter, long limit) {
+ public LimitIteration(CloseableIteration extends E> iter, long limit) {
super(iter);
assert iter != null;
@@ -59,7 +59,7 @@ public LimitIteration(Iteration extends E, X> iter, long limit) {
*---------*/
@Override
- public boolean hasNext() throws X {
+ public boolean hasNext() {
if (isClosed()) {
return false;
}
@@ -72,7 +72,7 @@ public boolean hasNext() throws X {
}
@Override
- public E next() throws X {
+ public E next() {
if (isClosed()) {
throw new NoSuchElementException("The iteration has been closed.");
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/LookAheadIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/LookAheadIteration.java
index f860ed3f0c2..03b14dbed0b 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/LookAheadIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/LookAheadIteration.java
@@ -19,7 +19,7 @@
* the java.util.Iteration interface.
*/
@Deprecated(since = "4.1.0")
-public abstract class LookAheadIteration extends AbstractCloseableIteration {
+public abstract class LookAheadIteration extends AbstractCloseableIteration {
/*-----------*
* Variables *
@@ -43,10 +43,10 @@ protected LookAheadIteration() {
*
* @return The next element, or null if no more elements are available.
*/
- protected abstract E getNextElement() throws X;
+ protected abstract E getNextElement();
@Override
- public final boolean hasNext() throws X {
+ public final boolean hasNext() {
if (isClosed()) {
return false;
}
@@ -55,7 +55,7 @@ public final boolean hasNext() throws X {
}
@Override
- public final E next() throws X {
+ public final E next() {
if (isClosed()) {
throw new NoSuchElementException("The iteration has been closed.");
}
@@ -75,7 +75,7 @@ public final E next() throws X {
* @return The next element, or null if there are no more results.
* @throws X If there is an issue getting the next element or closing the iteration.
*/
- private E lookAhead() throws X {
+ private E lookAhead() {
if (nextElement == null) {
nextElement = getNextElement();
@@ -95,7 +95,7 @@ public void remove() {
}
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
nextElement = null;
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/MinusIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/MinusIteration.java
index 13058e3749c..1df41bdddbc 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/MinusIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/MinusIteration.java
@@ -23,13 +23,13 @@
* bit more overhead as it adds a second hash table lookup.
*/
@Deprecated(since = "4.1.0")
-public class MinusIteration extends FilterIteration {
+public class MinusIteration extends FilterIteration {
/*-----------*
* Variables *
*-----------*/
- private final Iteration extends E, X> rightArg;
+ private final CloseableIteration extends E> rightArg;
private final boolean distinct;
@@ -50,7 +50,7 @@ public class MinusIteration extends FilterIteration leftArg, Iteration extends E, X> rightArg) {
+ public MinusIteration(CloseableIteration extends E> leftArg, CloseableIteration extends E> rightArg) {
this(leftArg, rightArg, false);
}
@@ -62,7 +62,8 @@ public MinusIteration(Iteration extends E, X> leftArg, Iteration extends E,
* @param rightArg An Iteration containing the set of elements that should be filtered from the main set.
* @param distinct Flag indicating whether duplicate elements should be filtered from the result.
*/
- public MinusIteration(Iteration extends E, X> leftArg, Iteration extends E, X> rightArg, boolean distinct) {
+ public MinusIteration(CloseableIteration extends E> leftArg, CloseableIteration extends E> rightArg,
+ boolean distinct) {
super(leftArg);
assert rightArg != null;
@@ -81,7 +82,8 @@ public MinusIteration(Iteration extends E, X> leftArg, Iteration extends E,
* @param rightArg An Iteration containing the set of elements that should be filtered from the main set.
* @param distinct Flag indicating whether duplicate elements should be filtered from the result.
*/
- public MinusIteration(Iteration extends E, X> leftArg, Iteration extends E, X> rightArg, boolean distinct,
+ public MinusIteration(CloseableIteration extends E> leftArg, CloseableIteration extends E> rightArg,
+ boolean distinct,
Supplier> setMaker) {
super(leftArg);
@@ -98,7 +100,7 @@ public MinusIteration(Iteration extends E, X> leftArg, Iteration extends E,
// implements LookAheadIteration.getNextElement()
@Override
- protected boolean accept(E object) throws X {
+ protected boolean accept(E object) {
if (!initialized) {
// Build set of elements-to-exclude from right argument
excludeSet = Iterations.asSet(rightArg);
@@ -121,11 +123,12 @@ protected boolean accept(E object) throws X {
}
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
try {
super.handleClose();
} finally {
- Iterations.closeCloseable(rightArg);
+ if (rightArg != null)
+ rightArg.close();
}
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/OffsetIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/OffsetIteration.java
index 95122f1974b..66be1546ff4 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/OffsetIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/OffsetIteration.java
@@ -15,7 +15,7 @@
* An Iteration that skips the first offset elements from an underlying Iteration.
*/
@Deprecated(since = "4.1.0")
-public class OffsetIteration extends FilterIteration {
+public class OffsetIteration extends FilterIteration {
/*-----------*
* Variables *
@@ -41,7 +41,7 @@ public class OffsetIteration extends FilterIterationnull.
* @param offset The number of elements to skip, must be larger than or equal to 0.
*/
- public OffsetIteration(Iteration extends E, X> iter, long offset) {
+ public OffsetIteration(CloseableIteration extends E> iter, long offset) {
super(iter);
assert offset >= 0;
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/QueueIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/QueueIteration.java
index 87a51e129d5..b3b11a59ea0 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/QueueIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/QueueIteration.java
@@ -25,7 +25,7 @@
* @author James Leigh
*/
@Deprecated(since = "4.1.0")
-public abstract class QueueIteration extends LookAheadIteration {
+public abstract class QueueIteration extends LookAheadIteration {
private final AtomicBoolean done = new AtomicBoolean(false);
@@ -44,36 +44,6 @@ protected QueueIteration(int capacity) {
this(capacity, false);
}
- /**
- * Creates an QueueIteration with the given (fixed) capacity and default access policy.
- *
- * @param capacity the capacity of this queue
- * @deprecated WeakReference is no longer supported as a way to automatically close this iteration. The recommended
- * approach to automatically closing an iteration on garbage collection is to use a
- * {@link java.lang.ref.Cleaner}.
- */
- @Deprecated(since = "4.1.2", forRemoval = true)
- protected QueueIteration(int capacity, WeakReference> callerRef) {
- this(capacity, false, callerRef);
- }
-
- /**
- * Creates an QueueIteration with the given (fixed) capacity and the specified access policy.
- *
- * @param capacity the capacity of this queue
- * @param fair if true then queue accesses for threads blocked on insertion or removal, are processed
- * in FIFO order; if false the access order is unspecified.
- * @deprecated WeakReference is no longer supported as a way to automatically close this iteration. The recommended
- * approach to automatically closing an iteration on garbage collection is to use a
- * {@link java.lang.ref.Cleaner}.
- */
- @Deprecated(since = "4.1.2", forRemoval = true)
- protected QueueIteration(int capacity, boolean fair, WeakReference> callerRef) {
- super();
- assert callerRef == null;
- this.queue = new ArrayBlockingQueue<>(capacity, fair);
- }
-
/**
* Creates an QueueIteration with the given (fixed) capacity and the specified access policy.
*
@@ -86,23 +56,6 @@ protected QueueIteration(int capacity, boolean fair) {
this.queue = new ArrayBlockingQueue<>(capacity, fair);
}
- /**
- * Creates an QueueIteration with the given {@link BlockingQueue} as its backing queue.
- * It may not be threadsafe to modify or access the given {@link BlockingQueue} from other locations. This method
- * only enables the default {@link ArrayBlockingQueue} to be overridden.
- *
- * @param queue A BlockingQueue that is not used in other locations, but will be used as the backing Queue
- * implementation for this cursor.
- * @deprecated WeakReference is no longer supported as a way to automatically close this iteration. The recommended
- * approach to automatically closing an iteration on garbage collection is to use a
- * {@link java.lang.ref.Cleaner}.
- */
- @Deprecated(since = "4.1.2", forRemoval = true)
- protected QueueIteration(BlockingQueue queue, WeakReference> callerRef) {
- assert callerRef == null;
- this.queue = queue;
- }
-
/**
* Creates an QueueIteration with the given {@link BlockingQueue} as its backing queue.
* It may not be threadsafe to modify or access the given {@link BlockingQueue} from other locations. This method
@@ -165,7 +118,7 @@ public void done() {
* Returns the next item in the queue, which may be null, or throws an exception.
*/
@Override
- public E getNextElement() throws T {
+ public E getNextElement() {
if (isClosed()) {
return null;
}
@@ -202,7 +155,7 @@ public E getNextElement() throws T {
}
@Override
- public void handleClose() throws T {
+ public void handleClose() {
try {
super.handleClose();
} finally {
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ReducedIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ReducedIteration.java
index 17aa702f3eb..5e62199dfc4 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ReducedIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/ReducedIteration.java
@@ -16,11 +16,11 @@
* @author Arjohn Kampman
*/
@Deprecated(since = "4.1.0")
-public class ReducedIteration extends FilterIteration {
+public class ReducedIteration extends FilterIteration {
private E previousObject;
- public ReducedIteration(Iteration extends E, ? extends X> delegate) {
+ public ReducedIteration(CloseableIteration extends E> delegate) {
super(delegate);
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/SilentIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/SilentIteration.java
index dab6af1d70c..36b9d03d0c8 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/SilentIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/SilentIteration.java
@@ -22,22 +22,19 @@
* @author Jeen Broekstra
*/
@Deprecated(since = "4.1.0")
-public class SilentIteration extends IterationWrapper {
+public class SilentIteration extends IterationWrapper {
private static final Logger logger = LoggerFactory.getLogger(SilentIteration.class);
- public SilentIteration(CloseableIteration iter) {
+ public SilentIteration(CloseableIteration iter) {
super(iter);
}
@Override
- public boolean hasNext() throws E {
+ public boolean hasNext() {
try {
return super.hasNext();
} catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
if (logger.isTraceEnabled()) {
logger.trace("Suppressed error in SILENT iteration: " + e.getMessage(), e);
}
@@ -46,16 +43,13 @@ public boolean hasNext() throws E {
}
@Override
- public T next() throws E {
+ public T next() {
try {
return super.next();
} catch (NoSuchElementException e) {
// pass through
throw e;
} catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
if (logger.isTraceEnabled()) {
logger.trace("Converted error in SILENT iteration: " + e.getMessage(), e);
}
@@ -64,13 +58,10 @@ public T next() throws E {
}
@Override
- protected void handleClose() throws E {
+ protected void handleClose() {
try {
super.handleClose();
} catch (Exception e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
if (logger.isTraceEnabled()) {
logger.trace("Suppressed error in SILENT iteration: " + e.getMessage(), e);
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/SingletonIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/SingletonIteration.java
index 53e99a6ebb5..154551cfffa 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/SingletonIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/SingletonIteration.java
@@ -17,7 +17,7 @@
* An Iteration that contains exactly one element.
*/
@Deprecated(since = "4.1.0")
-public class SingletonIteration extends AbstractCloseableIteration {
+public class SingletonIteration extends AbstractCloseableIteration {
/*-----------*
* Variables *
@@ -46,7 +46,7 @@ public boolean hasNext() {
}
@Override
- public E next() throws X {
+ public E next() {
E result = value;
value = null;
if (result == null) {
@@ -62,7 +62,7 @@ public void remove() {
}
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
value = null;
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/TimeLimitIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/TimeLimitIteration.java
index 760fcf5f476..f7f3a043383 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/TimeLimitIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/TimeLimitIteration.java
@@ -21,17 +21,17 @@
* @author Arjohn Kampman
*/
@Deprecated(since = "4.1.0")
-public abstract class TimeLimitIteration extends IterationWrapper {
+public abstract class TimeLimitIteration extends IterationWrapper {
private static final Timer timer = new Timer("TimeLimitIteration", true);
private final Logger logger = LoggerFactory.getLogger(this.getClass());
- private final InterruptTask interruptTask;
+ private final InterruptTask interruptTask;
private final AtomicBoolean isInterrupted = new AtomicBoolean(false);
- protected TimeLimitIteration(Iteration extends E, ? extends X> iter, long timeLimit) {
+ protected TimeLimitIteration(CloseableIteration extends E> iter, long timeLimit) {
super(iter);
assert timeLimit > 0 : "time limit must be a positive number, is: " + timeLimit;
@@ -42,7 +42,7 @@ protected TimeLimitIteration(Iteration extends E, ? extends X> iter, long time
}
@Override
- public boolean hasNext() throws X {
+ public boolean hasNext() {
checkInterrupted();
if (isClosed()) {
return false;
@@ -60,7 +60,7 @@ public boolean hasNext() throws X {
}
@Override
- public E next() throws X {
+ public E next() {
checkInterrupted();
if (isClosed()) {
throw new NoSuchElementException("The iteration has been closed.");
@@ -76,7 +76,7 @@ public E next() throws X {
}
@Override
- public void remove() throws X {
+ public void remove() {
checkInterrupted();
if (isClosed()) {
throw new IllegalStateException("The iteration has been closed.");
@@ -92,7 +92,7 @@ public void remove() throws X {
}
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
try {
interruptTask.cancel();
} finally {
@@ -100,7 +100,7 @@ protected void handleClose() throws X {
}
}
- private void checkInterrupted() throws X {
+ private void checkInterrupted() {
if (isInterrupted.get()) {
try {
throwInterruptedException();
@@ -121,9 +121,8 @@ private void checkInterrupted() throws X {
* If the iteration is interrupted by its time limit, this method is called to generate and throw the appropriate
* exception.
*
- * @throws X The generic class of exceptions thrown by this method.
*/
- protected abstract void throwInterruptedException() throws X;
+ protected abstract void throwInterruptedException();
/**
* Users of this class must call this method to interrupt the execution at the next available point. It does not
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/UnionIteration.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/UnionIteration.java
index db2aecbc685..334cfa0ad7a 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/UnionIteration.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/UnionIteration.java
@@ -22,15 +22,15 @@
* UnionIteration does not filter duplicate objects.
*/
@Deprecated(since = "4.1.0")
-public class UnionIteration extends LookAheadIteration {
+public class UnionIteration extends LookAheadIteration {
/*-----------*
* Variables *
*-----------*/
- private final Iterator extends Iteration extends E, X>> argIter;
+ private final Iterator extends CloseableIteration extends E>> argIter;
- private Iteration extends E, X> currentIter;
+ private CloseableIteration extends E> currentIter;
/*--------------*
* Constructors *
@@ -42,7 +42,7 @@ public class UnionIteration extends LookAheadIteration... args) {
+ public UnionIteration(CloseableIteration extends E>... args) {
this(Arrays.asList(args));
}
@@ -51,7 +51,7 @@ public UnionIteration(Iteration extends E, X>... args) {
*
* @param args The Iterations containing the elements to iterate over.
*/
- public UnionIteration(Iterable extends Iteration extends E, X>> args) {
+ public UnionIteration(Iterable extends CloseableIteration extends E>> args) {
argIter = args.iterator();
// Initialize with empty iteration
@@ -63,20 +63,22 @@ public UnionIteration(Iterable extends Iteration extends E, X>> args) {
*--------------*/
@Override
- protected E getNextElement() throws X {
+ protected E getNextElement() {
if (isClosed()) {
return null;
}
while (true) {
- Iteration extends E, X> nextCurrentIter = currentIter;
+ CloseableIteration extends E> nextCurrentIter = currentIter;
if (nextCurrentIter != null && nextCurrentIter.hasNext()) {
return nextCurrentIter.next();
}
// Current Iteration exhausted, continue with the next one
- Iterations.closeCloseable(nextCurrentIter);
+ if (nextCurrentIter != null) {
+ nextCurrentIter.close();
+ }
if (argIter.hasNext()) {
currentIter = argIter.next();
@@ -88,7 +90,7 @@ protected E getNextElement() throws X {
}
@Override
- protected void handleClose() throws X {
+ protected void handleClose() {
try {
// Close this iteration, this will prevent lookAhead() from calling
// getNextElement() again
@@ -98,11 +100,11 @@ protected void handleClose() throws X {
List collectedExceptions = new ArrayList<>();
while (argIter.hasNext()) {
try {
- Iterations.closeCloseable(argIter.next());
- } catch (Throwable e) {
- if (e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
+ CloseableIteration extends E> next = argIter.next();
+ if (next != null) {
+ next.close();
}
+ } catch (Throwable e) {
collectedExceptions.add(e);
}
}
@@ -110,7 +112,9 @@ protected void handleClose() throws X {
throw new UndeclaredThrowableException(collectedExceptions.get(0));
}
} finally {
- Iterations.closeCloseable(currentIter);
+ if (currentIter != null) {
+ currentIter.close();
+ }
}
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/CloseableIterationIterator.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/CloseableIterationIterator.java
index 45458ddbe5e..8aa4d36c618 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/CloseableIterationIterator.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/CloseableIterationIterator.java
@@ -11,11 +11,9 @@
package org.eclipse.rdf4j.common.iterator;
import java.io.Closeable;
-import java.io.IOException;
import java.util.Iterator;
import org.eclipse.rdf4j.common.iteration.CloseableIteration;
-import org.eclipse.rdf4j.common.iteration.Iteration;
/**
* Wraps a {@link CloseableIteration} as an {@link Iterator}.
@@ -24,33 +22,9 @@
*/
public class CloseableIterationIterator implements Iterator, Closeable {
- private final CloseableIteration extends E, ? extends RuntimeException> iteration;
+ private final CloseableIteration extends E> iteration;
- @Deprecated(since = "4.1.0", forRemoval = true)
- public CloseableIterationIterator(Iteration extends E, ? extends RuntimeException> iteration) {
- this.iteration = new CloseableIteration<>() {
- @Override
- public boolean hasNext() throws RuntimeException {
- return iteration.hasNext();
- }
-
- @Override
- public E next() throws RuntimeException {
- return iteration.next();
- }
-
- @Override
- public void remove() throws RuntimeException {
- iteration.remove();
- }
-
- @Override
- public void close() throws RuntimeException {
- }
- };
- }
-
- public CloseableIterationIterator(CloseableIteration extends E, ? extends RuntimeException> iteration) {
+ public CloseableIterationIterator(CloseableIteration extends E> iteration) {
this.iteration = iteration;
}
@@ -58,11 +32,8 @@ public CloseableIterationIterator(CloseableIteration extends E, ? extends Runt
public boolean hasNext() {
boolean hasMore = iteration.hasNext();
if (!hasMore) {
- try {
- close();
- } catch (IOException ioe) {
- // ignore
- }
+ close();
+
}
return hasMore;
}
@@ -78,7 +49,7 @@ public void remove() {
}
@Override
- public void close() throws IOException {
+ public void close() {
iteration.close();
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/Iterators.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/Iterators.java
deleted file mode 100644
index d622ff4ff92..00000000000
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/Iterators.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others.
- *
- * 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.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *******************************************************************************/
-
-package org.eclipse.rdf4j.common.iterator;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * This class consists exclusively of static methods that operate on or return iterators. It is the Iterator-equivalent
- * of {@link Collections}.
- *
- * @deprecated use Commons Collections or Guava instead.
- */
-@Deprecated(since = "4.1.0", forRemoval = true)
-public class Iterators {
-
- /**
- * Get a List containing all elements obtained from the specified iterator.
- *
- * @param iter the iterator to get the elements from
- * @return a List containing all elements obtained from the specified iterator.
- */
- public static List asList(Iterator extends E> iter) {
- List result = new ArrayList<>();
- addAll(iter, result);
- return result;
- }
-
- /**
- * Adds all elements from the supplied iterator to the specified collection.
- *
- * @param iter An iterator containing elements to add to the container.
- * @param collection The collection to add the elements to.
- * @return The collection object that was supplied to this method.
- */
- public static > C addAll(Iterator extends E> iter, C collection) {
- while (iter.hasNext()) {
- collection.add(iter.next());
- }
-
- return collection;
- }
-
- /**
- * Converts an iterator to a string by concatenating all of the string representations of objects in the iterator,
- * divided by a separator.
- *
- * @param iter An iterator over arbitrary objects that are expected to implement {@link Object#toString()}.
- * @param separator The separator to insert between the object strings.
- * @return A String representation of the objects provided by the supplied iterator.
- */
- public static String toString(Iterator> iter, String separator) {
- StringBuilder sb = new StringBuilder();
- toString(iter, separator, sb);
- return sb.toString();
- }
-
- /**
- * Converts an iterator to a string by concatenating all of the string representations of objects in the iterator,
- * divided by a separator.
- *
- * @param iter An iterator over arbitrary objects that are expected to implement {@link Object#toString()}.
- * @param separator The separator to insert between the object strings.
- * @param sb A StringBuilder to append the iterator string to.
- */
- public static void toString(Iterator> iter, String separator, StringBuilder sb) {
- while (iter.hasNext()) {
- sb.append(iter.next());
-
- if (iter.hasNext()) {
- sb.append(separator);
- }
- }
- }
-
- /**
- * Closes the given iterator if it implements {@link java.io.Closeable} else do nothing.
- *
- * @param iter The iterator to close.
- * @throws IOException If an underlying I/O error occurs.
- */
- public static void close(Iterator> iter) throws IOException {
- if (iter instanceof Closeable) {
- ((Closeable) iter).close();
- }
- }
-
- /**
- * Closes the given iterator, swallowing any IOExceptions, if it implements {@link java.io.Closeable} else do
- * nothing.
- *
- * @param iter The iterator to close.
- */
- public static void closeSilently(Iterator> iter) {
- if (iter instanceof Closeable) {
- try {
- ((Closeable) iter).close();
- } catch (IOException ioe) {
- // ignore
- }
- }
- }
-}
diff --git a/core/common/iterator/src/test/java/org/eclipse/rdf4j/common/iteration/AutoClosingIterationTest.java b/core/common/iterator/src/test/java/org/eclipse/rdf4j/common/iteration/AutoClosingIterationTest.java
index 92f403d7927..6b14d982e53 100644
--- a/core/common/iterator/src/test/java/org/eclipse/rdf4j/common/iteration/AutoClosingIterationTest.java
+++ b/core/common/iterator/src/test/java/org/eclipse/rdf4j/common/iteration/AutoClosingIterationTest.java
@@ -57,7 +57,7 @@ public void testClosingStreamWithAssertionError() {
}
@Test
- public void testClosingStreamWithAssertionErrorFinally() throws Exception {
+ public void testClosingStreamWithAssertionErrorFinally() {
CloseableIterationForTesting iterator = getIterator(Arrays.asList("a", "b", "c"));
@@ -81,7 +81,7 @@ private CloseableIterationForTesting getIterator(List list) {
return new CloseableIterationForTesting(list);
}
- static class CloseableIterationForTesting implements CloseableIteration {
+ static class CloseableIterationForTesting implements CloseableIteration {
public boolean closed = false;
Iterator iterator;
@@ -91,22 +91,22 @@ public CloseableIterationForTesting(List list) {
}
@Override
- public void close() throws Exception {
+ public void close() {
closed = true;
}
@Override
- public boolean hasNext() throws Exception {
+ public boolean hasNext() {
return iterator.hasNext();
}
@Override
- public String next() throws Exception {
+ public String next() {
return iterator.next();
}
@Override
- public void remove() throws Exception {
+ public void remove() {
}
}
diff --git a/core/common/iterator/src/test/java/org/eclipse/rdf4j/common/iteration/SilentIterationTest.java b/core/common/iterator/src/test/java/org/eclipse/rdf4j/common/iteration/SilentIterationTest.java
index cfbe7bdbf40..93fa033deb1 100644
--- a/core/common/iterator/src/test/java/org/eclipse/rdf4j/common/iteration/SilentIterationTest.java
+++ b/core/common/iterator/src/test/java/org/eclipse/rdf4j/common/iteration/SilentIterationTest.java
@@ -26,19 +26,19 @@
public class SilentIterationTest {
@Mock
- private CloseableIteration