diff --git a/compliance/pom.xml b/compliance/pom.xml
index f1f901ce146..103007f58ae 100644
--- a/compliance/pom.xml
+++ b/compliance/pom.xml
@@ -13,7 +13,6 @@
rio
model
sparql
- shacl
lucene
solr
elasticsearch
diff --git a/compliance/shacl/pom.xml b/compliance/shacl/pom.xml
deleted file mode 100644
index 3cb2f1e81a0..00000000000
--- a/compliance/shacl/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
- 4.0.0
-
- org.eclipse.rdf4j
- rdf4j-compliance
- 5.0.0-SNAPSHOT
-
- rdf4j-shacl-compliance
- RDF4J: SHACL compliance tests
- Tests for the SHACL constraint language implementation
-
-
- ${project.groupId}
- rdf4j-shacl-testsuite
- ${project.version}
-
-
- ${project.groupId}
- rdf4j-shacl
- ${project.version}
-
-
-
diff --git a/compliance/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/SHACLComplianceTest.java b/compliance/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/SHACLComplianceTest.java
deleted file mode 100644
index 5afeaf08d6b..00000000000
--- a/compliance/shacl/src/test/java/org/eclipse/rdf4j/sail/shacl/SHACLComplianceTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2018 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.sail.shacl;
-
-import org.eclipse.rdf4j.model.Model;
-import org.eclipse.rdf4j.sail.Sail;
-import org.eclipse.rdf4j.sail.memory.MemoryStore;
-import org.eclipse.rdf4j.testsuite.shacl.manifest.AbstractSHACLTest;
-import org.eclipse.rdf4j.testsuite.shacl.manifest.SHACLManifestTestSuiteFactory;
-import org.eclipse.rdf4j.testsuite.shacl.manifest.SHACLManifestTestSuiteFactory.TestFactory;
-
-import junit.framework.TestSuite;
-
-/**
- * Tests the SHACL implementation against the w3c test suite
- *
- * @author James Leigh
- * @deprecated This test suite is not maintained. Use {@see org.eclipse.rdf4j.sail.shacl.W3cComplianceTest} instead. We
- * may un-deprecate this suite in the future.
- */
-@Deprecated
-public class SHACLComplianceTest extends AbstractSHACLTest {
-
- // set this to true to run all tests!
- final static boolean RUN_ALL = false;
-
- public static TestSuite suite() throws Exception {
- String[] ignoredDirectories = { "targets", "sparql", "complex", "misc", "node", "path", "validation-reports",
- "property" };
- if (RUN_ALL) {
- ignoredDirectories = new String[0];
- }
-
- return new SHACLManifestTestSuiteFactory().createTestSuite(new TestFactory() {
-
- @Override
- public AbstractSHACLTest createSHACLTest(String testURI, String label, Model shapesGraph, Model dataGraph,
- boolean failure, boolean conforms) {
- return new SHACLComplianceTest(testURI, label, shapesGraph, dataGraph, failure, conforms);
- }
-
- @Override
- public String getName() {
- return SHACLComplianceTest.class.getName();
- }
-
- }, true, true, false, ignoredDirectories);
- }
-
- public SHACLComplianceTest(String testURI, String label, Model shapesGraph, Model dataGraph, boolean failure,
- boolean conforms) {
- super(testURI, label, shapesGraph, dataGraph, failure, conforms);
- }
-
- @Override
- protected Sail newSail() {
- return new ShaclSail(new MemoryStore());
- }
-
-}
diff --git a/core/common/io/src/main/java/org/eclipse/rdf4j/common/net/ParsedURI.java b/core/common/io/src/main/java/org/eclipse/rdf4j/common/net/ParsedURI.java
deleted file mode 100644
index 62490eba926..00000000000
--- a/core/common/io/src/main/java/org/eclipse/rdf4j/common/net/ParsedURI.java
+++ /dev/null
@@ -1,548 +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.net;
-
-import java.util.LinkedList;
-import java.util.StringTokenizer;
-
-/**
- * A replacement for Java's own URI: java.net.URI. Java's implementation is quite buggy in that it doesn't resolve
- * relative URIs correctly.
- *
- * Note: this implementation is not guaranteed to handle ipv6 addresses correctly (yet).
- *
- * @deprecated use {@link ParsedIRI} instead
- */
-@Deprecated(since = "2.3")
-public class ParsedURI implements java.lang.Cloneable {
-
- /*
- * // Tesing method public static void main(String[] args) throws Exception { URI baseURI = new URI(args[0]);
- * baseURI.normalize(); URI uri = null; for (int i = 0; i < 100; i++) { uri = baseURI.resolve(args[1]); } try {
- * Thread.sleep(1000); } catch (Exception e) {} long startTime = System.currentTimeMillis(); for (int i = 0; i <
- * 100; i++) { uri = baseURI.resolve(args[1]); } long endTime = System.currentTimeMillis();
- * System.out.println(args[0] + " was parsed as:"); System.out.println("scheme = " + uri.getScheme());
- * System.out.println("schemeSpecificPart = " + uri.getSchemeSpecificPart()); System.out.println("authority = " +
- * uri.getAuthority()); System.out.println("path = " + uri.getPath()); System.out.println("query = " +
- * uri.getQuery()); System.out.println("fragment = " + uri.getFragment()); System.out.println("full URI = " +
- * uri.toString()); System.out.println(" parsed 100 times in " + (endTime-startTime) + "ms"); }
- */
-
- /*-----------*
- * Variables *
- *-----------*/
-
- // For all URIs:
- private String _scheme;
-
- private String _schemeSpecificPart;
-
- private String _fragment;
-
- // For hierarchical URIs:
- private String _authority;
-
- private String _path;
-
- private String _query;
-
- /*--------------*
- * Constructors *
- *--------------*/
-
- public ParsedURI(String uriSpec) {
- _parse(uriSpec);
- }
-
- public ParsedURI(String scheme, String schemeSpecificPart, String fragment) {
- _scheme = scheme;
- _schemeSpecificPart = schemeSpecificPart;
- _fragment = fragment;
- }
-
- public ParsedURI(String scheme, String authority, String path, String query, String fragment) {
- _scheme = scheme;
- _authority = authority;
- _path = path;
- _query = query;
- _fragment = fragment;
- }
-
- /*-----------------------*
- * Public access methods *
- *-----------------------*/
-
- public boolean isHierarchical() {
- return _path != null;
- }
-
- public boolean isOpaque() {
- return _path == null;
- }
-
- public boolean isAbsolute() {
- return _scheme != null;
- }
-
- public boolean isRelative() {
- return _scheme == null;
- }
-
- /**
- * Checks whether this URI is a relative URI that references itself (i.e. it only contains an anchor).
- */
- public boolean isSelfReference() {
- return _scheme == null && _authority == null && _query == null && _path.length() == 0;
- }
-
- public String getScheme() {
- return _scheme;
- }
-
- public String getSchemeSpecificPart() {
- return _schemeSpecificPart;
- }
-
- public String getAuthority() {
- return _authority;
- }
-
- public String getPath() {
- return _path;
- }
-
- public String getQuery() {
- return _query;
- }
-
- public String getFragment() {
- return _fragment;
- }
-
- /*------------------------------*
- * Methods for normalizing URIs *
- *------------------------------*/
-
- /**
- * Normalizes the path of this URI if it has one. Normalizing a path means that any unnecessary '.' and '..'
- * segments are removed. For example, the URI http://server.com/a/b/../c/./d would be normalized to
- * http://server.com/a/c/d. A URI doens't have a path if it is opaque.
- */
- public void normalize() {
- if (_path == null) {
- return;
- }
-
- // Remove any '.' segments:
-
- _path = _path.replace("/./", "/");
-
- if (_path.startsWith("./")) {
- // Remove both characters
- _path = _path.substring(2);
- }
-
- if (_path.endsWith("/.")) {
- // Remove only the last dot, not the slash!
- _path = _path.substring(0, _path.length() - 1);
- }
-
- if (_path.indexOf("/../") == -1 && !_path.endsWith("/..")) {
- // There are no '..' segments that can be removed. We're done and
- // don't have to execute the time-consuming code following this
- // if-statement
- return;
- }
-
- // Split the path into its segments
-
- LinkedList segments = new LinkedList<>();
-
- StringTokenizer st = new StringTokenizer(_path, "/");
-
- while (st.hasMoreTokens()) {
- segments.add(st.nextToken());
- }
-
- boolean lastSegmentRemoved = false;
-
- // Remove all unnecessary '..' segments
-
- int i = 1;
- while (i < segments.size()) {
- String segment = segments.get(i);
-
- if (segment.equals("..")) {
- String prevSegment = segments.get(i - 1);
-
- if (prevSegment.equals("..")) {
- // two consecutive '..' segments at position i-1 and i,
- // continue at i + 2
- i += 2;
- } else {
- // Bingo! Remove these two segments...
- if (i == segments.size() - 1) {
- lastSegmentRemoved = true;
- }
-
- segments.remove(i);
- segments.remove(i - 1);
-
- // ...and continue at position (i + 1 - 2) == (i - 1)...
-
- // ...but only if i > 1, position 0 does not need to be
- // checked.
-
- if (i > 1) {
- i--;
- }
- }
- } else {
- // Not a '..' segment, check next
- i++;
- }
- }
-
- // Construct the normalized path
-
- StringBuilder newPath = new StringBuilder(_path.length());
-
- if (_path.startsWith("/")) {
- newPath.append('/');
- }
-
- int segmentCount = segments.size();
- for (i = 0; i < segmentCount - 1; i++) {
- newPath.append(segments.get(i));
- newPath.append('/');
- }
-
- if (segmentCount > 0) {
- String lastSegment = segments.get(segmentCount - 1);
- newPath.append(lastSegment);
-
- if (_path.endsWith("/") || lastSegmentRemoved) {
- newPath.append('/');
- }
- }
-
- _path = newPath.toString();
- }
-
- /**
- * Resolves a relative URI using this URI as the base URI.
- */
- public ParsedURI resolve(String relURISpec) {
- // This algorithm is based on the algorithm specified in chapter 5 of
- // RFC 2396: URI Generic Syntax. See http://www.ietf.org/rfc/rfc2396.txt
-
- // RFC, step 1:
- ParsedURI relURI = new ParsedURI(relURISpec);
-
- return this.resolve(relURI);
- }
-
- /**
- * Resolves a relative URI using this URI as the base URI.
- */
- public ParsedURI resolve(ParsedURI relURI) {
- // This algorithm is based on the algorithm specified in chapter 5 of
- // RFC 2396: URI Generic Syntax. See http://www.ietf.org/rfc/rfc2396.txt
-
- // RFC, step 3:
- if (relURI.isAbsolute()) {
- return relURI;
- }
-
- // relURI._scheme == null
-
- // RFC, step 2:
- if (relURI._authority == null && relURI._query == null && relURI._path.length() == 0) {
- // Reference to this URI
- ParsedURI result = (ParsedURI) this.clone();
-
- // Inherit any fragment identifier from relURI
- result._fragment = relURI._fragment;
-
- return result;
- }
-
- // We can start combining the URIs
- String scheme, authority, path, query, fragment;
- boolean normalizeURI = false;
-
- scheme = this._scheme;
- query = relURI._query;
- fragment = relURI._fragment;
-
- // RFC, step 4:
- if (relURI._authority != null) {
- authority = relURI._authority;
- path = relURI._path;
- } else {
- authority = this._authority;
-
- // RFC, step 5:
- if (relURI._path.startsWith("/")) {
- path = relURI._path;
- } else if (relURI._path.length() == 0) {
- path = this._path;
- } else {
- // RFC, step 6:
- path = this._path;
-
- if (path == null) {
- path = "/";
- } else {
- if (!path.endsWith("/")) {
- // Remove the last segment of the path. Note: if
- // lastSlashIdx is -1, the path will become empty,
- // which is fixed later.
- int lastSlashIdx = path.lastIndexOf('/');
- path = path.substring(0, lastSlashIdx + 1);
- }
-
- if (path.length() == 0) {
- // No path means: start at root.
- path = "/";
- }
- }
-
- // Append the path of the relative URI
- path += relURI._path;
-
- // Path needs to be normalized.
- normalizeURI = true;
- }
- }
-
- ParsedURI result = new ParsedURI(scheme, authority, path, query, fragment);
-
- if (normalizeURI) {
- result.normalize();
- }
-
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(64);
-
- if (_scheme != null) {
- sb.append(_scheme);
- if (!isJarScheme(_scheme)) {
- sb.append(':');
- }
- }
-
- if (isOpaque()) {
- // Opaque URI
- if (_schemeSpecificPart != null) {
- sb.append(_schemeSpecificPart);
- }
- } else {
- // Hierachical URI
- if (_authority != null) {
- sb.append("//");
- sb.append(_authority);
- }
-
- sb.append(_path);
-
- if (_query != null) {
- sb.append('?');
- sb.append(_query);
- }
- }
-
- if (_fragment != null) {
- sb.append('#');
- sb.append(_fragment);
- }
-
- return sb.toString();
- }
-
- // Overrides Object.clone()
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- throw new RuntimeException(e);
- }
- }
-
- /*--------------------------*
- * Methods for parsing URIs *
- *--------------------------*/
-
- private static boolean isJarScheme(String s) {
- return (s.length() > 4 && s.substring(0, 4).equalsIgnoreCase("jar:"));
- }
-
- private void _parse(String uri) {
- if (isJarScheme(uri)) {
- // uriString is e.g.
- // jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class
- // Treat the part up to and including the exclamation mark as the
- // scheme and
- // the rest as the path to enable 'correct' resolving of relative URIs
- int idx = uri.indexOf('!');
- if (idx != -1) {
- String scheme = uri.substring(0, idx + 1);
- String path = uri.substring(idx + 1);
-
- _scheme = scheme;
- _authority = null;
- _path = path;
- _query = null;
- _fragment = null;
-
- return;
- }
- }
-
- if (_parseScheme(uri)) {
- // A scheme was found; _scheme and _schemeSpecificPart are now set
- if (_schemeSpecificPart.startsWith("/")) {
- // Hierachical URI
- String rest = _schemeSpecificPart;
- rest = _parseAuthority(rest);
- rest = _parsePath(rest);
- rest = _parseQuery(rest);
- _parseFragment(rest);
- } else {
- // Opaque URI
- String rest = _schemeSpecificPart;
- rest = _parseOpaquePart(rest);
- _parseFragment(rest);
- }
- } else {
- // No scheme was found
- String rest = uri;
- rest = _parseAuthority(rest);
- rest = _parsePath(rest);
- rest = _parseQuery(rest);
- _parseFragment(rest);
- }
- }
-
- private boolean _parseScheme(String uri) {
- // Query cannot contain a ':', '/', '?' or '#' character
-
- // Try to find the scheme in the URI
- char c = 0;
- int i = 0;
-
- for (; i < uri.length(); i++) {
- c = uri.charAt(i);
- if (c == ':' || c == '/' || c == '?' || c == '#') {
- // c is equal to one of the illegal chars
- break;
- }
- }
-
- if (c == ':' && i > 0) {
- // We've found a scheme
- _scheme = uri.substring(0, i);
- _schemeSpecificPart = uri.substring(i + 1);
- return true;
- }
-
- // No scheme found, uri is relative
- return false;
- }
-
- private String _parseAuthority(String s) {
- // Query cannot contain a '/', '?' or '#' character
-
- if (s.startsWith("//")) {
- // Authority present, could be empty though.
- int i = 2;
- for (; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c == '/' || c == '?' || c == '#') {
- // c is equal to one of the illegal chars
- break;
- }
- }
-
- _authority = s.substring(2, i);
- return s.substring(i);
- }
-
- return s;
- }
-
- private String _parsePath(String s) {
- // Query cannot contain a '?' or '#' character
-
- int i = 0;
- for (; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c == '?' || c == '#') {
- // c is equal to one of the illegal chars
- break;
- }
- }
-
- _path = s.substring(0, i);
-
- return s.substring(i);
- }
-
- private String _parseQuery(String s) {
- // Query must start with a '?' and cannot contain a '#' character
-
- if (s.startsWith("?")) {
- int i = 1;
- for (; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c == '#') {
- // c is equal to one of the illegal chars
- break;
- }
- }
-
- _query = s.substring(1, i);
- return s.substring(i);
- } else {
- return s;
- }
- }
-
- private String _parseOpaquePart(String s) {
- // Opaque part cannot contain a '#' character
-
- int i = 0;
- for (; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c == '#') {
- // c is equal to one of the illegal chars
- break;
- }
- }
-
- _schemeSpecificPart = s.substring(0, i);
-
- return s.substring(i);
- }
-
- private void _parseFragment(String s) {
- // Fragment must start with a '#'
- if (s.startsWith("#")) {
- _fragment = s.substring(1);
- }
- }
-}
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
deleted file mode 100644
index 338066b7433..00000000000
--- a/core/common/io/src/test/java/org/eclipse/rdf4j/common/net/ParsedURITest.java
+++ /dev/null
@@ -1,234 +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.net;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.junit.jupiter.api.Test;
-
-/**
- * @author Joseph Walton
- * @author James Leigh
- */
-public class ParsedURITest {
-
- @Test
- public void absoluteHttpUriIsDescribedCorrectly() {
- ParsedURI uri = new ParsedURI("http://example.test/");
- assertTrue(uri.isAbsolute());
- assertTrue(uri.isHierarchical());
- assertEquals("http", uri.getScheme());
- assertFalse(uri.isOpaque());
- }
-
- @Test
- public void uriReferenceIsDescribedCorrectly() {
- ParsedURI uri = new ParsedURI("/path");
- assertFalse(uri.isAbsolute());
- assertTrue(uri.isHierarchical());
- assertNull(uri.getScheme());
- assertFalse(uri.isOpaque());
- }
-
- @Test
- public void jarUrisAppearAsAbsoluteAndHierarchical() {
- ParsedURI uri = new ParsedURI("jar:http://example.test/bar/baz.jar!/COM/foo/Quux.class");
- assertTrue(uri.isAbsolute());
- assertTrue(uri.isHierarchical());
- assertFalse(uri.isOpaque());
- assertEquals("/COM/foo/Quux.class", uri.getPath());
-
- uri.normalize();
- assertEquals("/COM/foo/Quux.class", uri.getPath());
- }
-
- @Test
- public void jarUriWithHttpStringifiesToOriginalForm() {
- ParsedURI uri = new ParsedURI("jar:http://example.test/bar/baz.jar!/COM/foo/Quux.class");
- assertEquals("jar:http://example.test/bar/baz.jar!/COM/foo/Quux.class", uri.toString());
- }
-
- @Test
- public void jarUriWithFileStringifiesToOriginalForm() {
- ParsedURI uri = new ParsedURI("jar:file:///some-file.jar!/another-file");
- assertEquals("jar:file:///some-file.jar!/another-file", uri.toString());
- }
-
- @Test
- public void resolvesAnAbsoluteUriRelativeToABaseJarUri() {
- ParsedURI uri = new ParsedURI("jar:file:///some-file.jar!/some-nested-file");
- assertEquals("http://example.test/", uri.resolve("http://example.test/").toString());
- }
-
- @Test
- public void resolvesAPathRelativeUriRelativeToABaseJarUri() {
- ParsedURI uri = new ParsedURI("jar:file:///some-file.jar!/some-nested-file");
- assertEquals("jar:file:///some-file.jar!/another-file", uri.resolve("another-file").toString());
- }
-
- @Test
- public void resolvesAPathAbsoluteUriRelativeToABaseJarUri() {
- ParsedURI uri = new ParsedURI("jar:file:///some-file.jar!/nested-directory/some-nested-file");
- assertEquals("jar:file:///some-file.jar!/another-file", uri.resolve("/another-file").toString());
- }
-
- @Test
- 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) {
- assertResolves(uri, "http://example.com/", uri);
- }
-
- @Test
- public void testParentFile() {
- assertResolves("../dir", "http://example.com/dir/dir/file", "http://example.com/dir/dir");
- }
-
- @Test
- public void testRootFile() {
- assertResolves("/dir", "http://example.com/dir/dir", "http://example.com/dir");
- }
-
- @Test
- 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() {
- assertResolves("", "http://example.com/dir/dir/file?qs", "http://example.com/dir/dir/file?qs");
- }
-
- @Test
- public void testOpaque() {
- assertResolves("urn:test", "http://example.com/dir/dir/file?qs#frag", "urn:test");
- }
-
- @Test
- 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() {
- assertResolves("?qs2#frag", "http://example.com/dir/dir/file?qs#frag",
- "http://example.com/dir/dir/file?qs2#frag");
- }
-
- @Test
- public void testDirectory() {
- assertResolves(".", "http://example.com/dir/dir/file?qs#frag", "http://example.com/dir/dir/");
- }
-
- @Test
- 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() {
- 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() {
- assertResolves("../file?qs#frag", "http://example.com/dir/dir/file?qs#frag",
- "http://example.com/dir/file?qs#frag");
- }
-
- @Test
- 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() {
- 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() {
- assertResolves("", "http://example.com/dir/dir/", "http://example.com/dir/dir/");
- }
-
- @Test
- public void testOpaqueDir() {
- assertResolves("urn:test", "http://example.com/dir/dir/", "urn:test");
- }
-
- @Test
- public void testFragmentDir() {
- assertResolves("#frag2", "http://example.com/dir/dir/", "http://example.com/dir/dir/#frag2");
- }
-
- @Test
- public void testQueryStringDir() {
- assertResolves("?qs2", "http://example.com/dir/dir/", "http://example.com/dir/dir/?qs2");
- }
-
- @Test
- public void testDirectoryDir() {
- assertResolves("file", "http://example.com/dir/dir/", "http://example.com/dir/dir/file");
- }
-
- @Test
- public void testSameDirectoryDir() {
- assertResolves("file2?qs#frag", "http://example.com/dir/dir/", "http://example.com/dir/dir/file2?qs#frag");
- }
-
- @Test
- public void testNestedDirectoryDir() {
- assertResolves("nested/", "http://example.com/dir/dir/", "http://example.com/dir/dir/nested/");
- }
-
- @Test
- 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() {
- assertResolves("../file?qs#frag", "http://example.com/dir/dir/", "http://example.com/dir/file?qs#frag");
- }
-
- @Test
- public void testOtherDirectoryDir() {
- assertResolves("../dir2/", "http://example.com/dir/dir/", "http://example.com/dir/dir2/");
- }
-
- @Test
- 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() {
- 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) {
- assertEquals(absolute, new ParsedURI(base).resolve(relative).toString());
- }
-
-}
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 ab86f83225e..dacca523479 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
@@ -17,7 +17,6 @@
*
* 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 {
/*-----------*
@@ -56,9 +55,6 @@ public final void close() {
/**
* Called by {@link #close} when it is called for the first time. This method is only called once on each iteration.
* By default, this method does nothing.
- *
- * @throws X
*/
- protected void handleClose() {
- }
+ abstract protected void handleClose();
}
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/AbstractCloseableIteratorIteration.java
similarity index 53%
rename from core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IteratorIteration.java
rename to core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/AbstractCloseableIteratorIteration.java
index 9a5e45e6b46..28b3609296d 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/AbstractCloseableIteratorIteration.java
@@ -12,37 +12,62 @@
package org.eclipse.rdf4j.common.iteration;
import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Objects;
/**
* An Iteration that can convert an {@link Iterator} to a {@link CloseableIteration}.
*/
-@Deprecated(since = "4.1.0")
-public class IteratorIteration implements CloseableIteration {
+public abstract class AbstractCloseableIteratorIteration extends AbstractCloseableIteration {
- private final Iterator extends E> iter;
+ private Iterator extends E> iter;
- public IteratorIteration(Iterator extends E> iter) {
- assert iter != null;
- this.iter = iter;
+ public AbstractCloseableIteratorIteration() {
}
+ protected abstract Iterator extends E> getIterator();
+
@Override
public boolean hasNext() {
- return iter.hasNext();
+ if (isClosed()) {
+ return false;
+ }
+
+ if (iter == null) {
+ iter = getIterator();
+ }
+
+ boolean result = iter.hasNext();
+ if (!result) {
+ close();
+ }
+ return result;
}
@Override
public E next() {
+ if (isClosed()) {
+ throw new NoSuchElementException("Iteration has been closed");
+ }
+
+ if (iter == null) {
+ iter = getIterator();
+ }
+
return iter.next();
}
@Override
public void remove() {
- iter.remove();
- }
+ if (isClosed()) {
+ throw new IllegalStateException("Iteration has been closed");
+ }
- @Override
- public void close() {
+ if (iter == null) {
+ iter = getIterator();
+ }
+ iter.remove();
}
+
}
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 c270ae65115..15890fe2aa7 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
@@ -30,12 +30,7 @@
* }
*
*
- * @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 Iterator, AutoCloseable {
/**
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 fa3bb0ad987..a54f33b1b9f 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
@@ -18,33 +18,21 @@
/**
* 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 implements CloseableIteration {
private Iterator extends E> iter;
-
/**
- * Creates an uninitialized CloseableIteratorIteration, needs to be initialized by calling
- * {@link #setIterator(Iterator)} before it can be used.
+ * Flag indicating whether this iteration has been closed.
*/
- public CloseableIteratorIteration() {
- }
+ private boolean closed = false;
/**
* Creates a CloseableIteratorIteration that wraps the supplied iterator.
*/
public CloseableIteratorIteration(Iterator extends E> iter) {
- setIterator(iter);
- }
-
- protected void setIterator(Iterator extends E> iter) {
this.iter = Objects.requireNonNull(iter, "Iterator was null");
}
- protected boolean hasIterator() {
- return iter != null;
- }
-
@Override
public boolean hasNext() {
if (isClosed()) {
@@ -75,4 +63,28 @@ public void remove() {
iter.remove();
}
+
+ protected void handleClose() {
+
+ }
+
+ /**
+ * Checks whether this CloseableIteration has been closed.
+ *
+ * @return true if the CloseableIteration has been closed, false otherwise.
+ */
+ public final boolean isClosed() {
+ return closed;
+ }
+
+ /**
+ * Calls {@link #handleClose()} upon first call and makes sure the resource closures are only executed once.
+ */
+ @Override
+ public final void close() {
+ if (!closed) {
+ closed = true;
+ handleClose();
+ }
+ }
}
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 6fbf65bc55f..403dc343c25 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
@@ -18,7 +18,6 @@
* A CloseableIteration that converts an iteration over objects of type S (the source type) to an iteration
* over objects of type T (the target type).
*/
-@Deprecated(since = "4.1.0")
public abstract class ConvertingIteration extends AbstractCloseableIteration {
/*-----------*
@@ -59,7 +58,7 @@ protected ConvertingIteration(CloseableIteration extends S> iter) {
*
*/
@Override
- public boolean hasNext() {
+ public final boolean hasNext() {
if (isClosed()) {
return false;
}
@@ -78,7 +77,7 @@ public boolean hasNext() {
* @throws IllegalStateException If the iteration has been closed.
*/
@Override
- public T next() {
+ public final T next() {
if (isClosed()) {
throw new NoSuchElementException("The iteration has been closed.");
}
@@ -94,7 +93,7 @@ public T next() {
* {@link #next}.
*/
@Override
- public void remove() {
+ public final void remove() {
if (isClosed()) {
throw new IllegalStateException("The iteration has been closed.");
}
@@ -106,10 +105,6 @@ public void remove() {
*/
@Override
protected void handleClose() {
- try {
- super.handleClose();
- } finally {
- iter.close();
- }
+ 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 012c31fe2ac..f7cd118b943 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
@@ -19,7 +19,6 @@
* or where a created iteration consumes scarce resources like JDBC-connections or memory. Subclasses must implement the
* createIteration method, which is called once when the iteration is first needed.
*/
-@Deprecated(since = "4.1.0")
public abstract class DelayedIteration extends AbstractCloseableIteration {
/*-----------*
@@ -60,10 +59,7 @@ public boolean hasNext() {
CloseableIteration extends E> resultIter = iter;
if (resultIter == null) {
// Underlying iterator has not yet been initialized
- resultIter = iter;
- if (resultIter == null) {
- resultIter = iter = createIteration();
- }
+ resultIter = iter = createIteration();
}
return resultIter.hasNext();
@@ -80,10 +76,8 @@ public E next() {
CloseableIteration extends E> resultIter = iter;
if (resultIter == null) {
// Underlying iterator has not yet been initialized
- resultIter = iter;
- if (resultIter == null) {
- resultIter = iter = createIteration();
- }
+ resultIter = iter = createIteration();
+
}
return resultIter.next();
@@ -111,12 +105,8 @@ public void remove() {
*/
@Override
protected void handleClose() {
- try {
- super.handleClose();
- } finally {
- if (iter != null) {
- iter.close();
- }
+ 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 c065273e45a..7dcb2c8d325 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
@@ -18,7 +18,6 @@
/**
* An Iteration that filters any duplicate elements from an underlying iterator.
*/
-@Deprecated(since = "4.1.0")
public class DistinctIteration extends FilterIteration {
/*-----------*
@@ -68,6 +67,11 @@ protected boolean accept(E object) {
}
}
+ @Override
+ protected void handleClose() {
+
+ }
+
/**
* @param object
* @return true if the object is in the excludeSet
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 e8db59efdfb..e581e85a59a 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
@@ -16,7 +16,6 @@
/**
* Provides a bag union of the two provided iterations.
*/
-@Deprecated(since = "4.1.0")
public class DualUnionIteration implements CloseableIteration {
private CloseableIteration extends E> iteration1;
@@ -111,7 +110,6 @@ public final E next() {
* Fetches the next element if it hasn't been fetched yet and stores it in {@link #nextElement}.
*
* @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() {
if (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 f8c6961e781..e2efccf8dbd 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
@@ -12,6 +12,7 @@
package org.eclipse.rdf4j.common.iteration;
import java.util.NoSuchElementException;
+import java.util.function.Consumer;
import java.util.stream.Stream;
/**
@@ -20,23 +21,11 @@
* @implNote In the future this class will stop extending AbstractCloseableIteration and instead implement
* CloseableIteration directly.
*/
-@Deprecated(since = "4.1.0")
-public final class EmptyIteration extends AbstractCloseableIteration {
+public final class EmptyIteration implements CloseableIteration {
- /*--------------*
- * Constructors *
- *--------------*/
-
- /**
- * Creates a new EmptyIteration.
- */
public EmptyIteration() {
}
- /*---------*
- * Methods *
- *---------*/
-
@Override
public boolean hasNext() {
return false;
@@ -57,4 +46,13 @@ public Stream stream() {
return Stream.empty();
}
+ @Override
+ public void close() {
+
+ }
+
+ @Override
+ public void forEachRemaining(Consumer super E> action) {
+ }
+
}
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 de3459baab1..590edca7b21 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
@@ -58,7 +58,6 @@ protected ExceptionConvertingIteration(CloseableIteration extends E> iter) {
* Checks whether the underlying Iteration contains more elements.
*
* @return true if the underlying Iteration contains more elements, false otherwise.
- * @throws X
*/
@Override
public boolean hasNext() {
@@ -79,7 +78,6 @@ public boolean hasNext() {
/**
* Returns the next element from the wrapped Iteration.
*
- * @throws X
* @throws java.util.NoSuchElementException If all elements have been returned.
* @throws IllegalStateException If the Iteration has been closed.
*/
@@ -128,13 +126,9 @@ public void remove() {
@Override
protected void handleClose() {
try {
- super.handleClose();
- } finally {
- try {
- iter.close();
- } catch (RuntimeException e) {
- throw convert(e);
- }
+ 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 e57b758e29a..6147109d73a 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
@@ -17,14 +17,23 @@
* A CloseableIteration that wraps another Iteration, applying a filter on the objects that are returned. Subclasses
* 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 implements CloseableIteration {
+ /**
+ * The wrapped Iteration.
+ *
+ * @deprecated This will be changed to private, possibly with an accessor in future. Do not rely on it.
+ */
+ private final CloseableIteration extends E> wrappedIter;
/*-----------*
* Variables *
*-----------*/
private E nextElement;
+ /**
+ * Flag indicating whether this iteration has been closed.
+ */
+ private boolean closed = false;
/*--------------*
* Constructors *
@@ -34,7 +43,8 @@ public abstract class FilterIteration extends IterationWrapper {
* @param iter
*/
protected FilterIteration(CloseableIteration extends E> iter) {
- super(iter);
+ assert iter != null;
+ this.wrappedIter = iter;
}
/*---------*
@@ -74,9 +84,36 @@ public E next() {
}
private void findNextElement() {
+ if (nextElement != null) {
+ return;
+ }
+
try {
- while (!isClosed() && nextElement == null && super.hasNext()) {
- E candidate = super.next();
+ if (!isClosed()) {
+ if (Thread.currentThread().isInterrupted()) {
+ close();
+ return;
+ } else {
+ boolean result = wrappedIter.hasNext();
+ if (!result) {
+ close();
+ return;
+ }
+ }
+ }
+ while (nextElement == null && wrappedIter.hasNext()) {
+ E result;
+ if (Thread.currentThread().isInterrupted()) {
+ close();
+ return;
+ }
+ try {
+ result = wrappedIter.next();
+ } catch (NoSuchElementException e) {
+ close();
+ throw e;
+ }
+ E candidate = result;
if (accept(candidate)) {
nextElement = candidate;
@@ -95,16 +132,54 @@ private void findNextElement() {
*
* @param object The object to be tested.
* @return true if the object should be returned, false otherwise.
- * @throws X
*/
protected abstract boolean accept(E object);
+ /**
+ * Removes the last element that has been returned from the wrapped Iteration.
+ *
+ * @throws UnsupportedOperationException If the wrapped Iteration does not support the remove operation.
+ * @throws IllegalStateException if the Iteration has been closed, or if {@link #next} has not yet been
+ * called, or {@link #remove} has already been called after the last call to
+ * {@link #next}.
+ */
@Override
- protected void handleClose() {
+ public void remove() {
+ if (isClosed()) {
+ throw new IllegalStateException("The iteration has been closed.");
+ } else if (Thread.currentThread().isInterrupted()) {
+ close();
+ throw new IllegalStateException("The iteration has been interrupted.");
+ }
try {
- super.handleClose();
- } finally {
- nextElement = null;
+ wrappedIter.remove();
+ } catch (IllegalStateException e) {
+ close();
+ throw e;
+ }
+ }
+
+ private boolean isClosed() {
+ return closed;
+ }
+
+ /**
+ * Closes this Iteration and also closes the wrapped Iteration if it is a {@link CloseableIteration}.
+ */
+ abstract protected void handleClose();
+
+ /**
+ * Calls {@link #handleClose()} upon first call and makes sure the resource closures are only executed once.
+ */
+ @Override
+ public final void close() {
+ if (!closed) {
+ closed = true;
+ try {
+ wrappedIter.close();
+ } finally {
+ handleClose();
+ }
}
}
}
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 55b495908b8..5e912086c85 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
@@ -22,7 +22,6 @@
* Note that duplicates can also be filtered by wrapping this Iteration in a {@link DistinctIteration}, but that has a
* bit more overhead as it adds a second hash table lookup.
*/
-@Deprecated(since = "4.1.0")
public class IntersectIteration extends FilterIteration {
/*-----------*
@@ -127,11 +126,6 @@ protected boolean accept(E object) {
return false;
}
- // this method does not seem to "addSecondSet" since the second set seems to be ignored
- public Set addSecondSet(CloseableIteration extends E> arg2, Set set) {
- return Iterations.addAll(arg2, setMaker.get());
- }
-
protected boolean removeFromIncludeSet(E object) {
return includeSet.remove(object);
}
@@ -146,19 +140,9 @@ protected Set makeSet() {
@Override
protected void handleClose() {
- try {
- super.handleClose();
- } finally {
- if (arg2 != null) {
- arg2.close();
- }
+ if (arg2 != null) {
+ arg2.close();
}
}
- protected long clearIncludeSet() {
- long size = includeSet.size();
- includeSet.clear();
- return size;
- }
-
}
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
deleted file mode 100644
index c4ef42ca008..00000000000
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IterationSpliterator.java
+++ /dev/null
@@ -1,83 +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.Objects;
-import java.util.Spliterator;
-import java.util.Spliterators;
-import java.util.function.Consumer;
-
-/**
- * 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 CloseableIteration iteration;
-
- /**
- * 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 CloseableIteration iteration) {
- super(Long.MAX_VALUE, Spliterator.IMMUTABLE | Spliterator.NONNULL);
- this.iteration = iteration;
- }
-
- @Override
- public boolean tryAdvance(Consumer super T> action) {
- Objects.requireNonNull(action, "action may not be null");
-
- // we start by assuming that we need to close the iteration, in case an error occurs
- // this could be handled in the catch part, but then we would need to catch throwable...which is not recommended
- boolean needsToBeClosed = true;
- try {
- if (iteration.hasNext()) {
- action.accept(iteration.next());
- // since the iteration might have more elements we don't need to close it
- needsToBeClosed = false;
- return true;
- }
- return false;
- } finally {
- if (needsToBeClosed) {
- try {
- if (iteration != null)
- iteration.close();
- } catch (Exception ignored) {
- }
- }
- }
- }
-
- @Override
- public void forEachRemaining(final Consumer super T> action) {
- Objects.requireNonNull(action, "action may not be null");
- try {
- while (iteration.hasNext()) {
- action.accept(iteration.next());
- }
- } finally {
- try {
- 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 504acb4a8f4..9f51bcf4387 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
@@ -121,10 +121,6 @@ public void remove() {
*/
@Override
protected void handleClose() {
- try {
- super.handleClose();
- } finally {
- wrappedIter.close();
- }
+ 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 28562e8246e..85184886f60 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
@@ -23,34 +23,34 @@
/**
* This class consists exclusively of static methods that operate on or return Iterations. It is the
* Iteration-equivalent of java.util.Collections.
+ *
*/
-@Deprecated(since = "4.1.0")
public class Iterations {
/**
* Get a List containing all elements obtained from the specified iteration.
*
- * @param iter the {@link CloseableIteration} to get the elements from
+ * @param iteration 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> iter) {
- try (iter) {
+ public static List asList(CloseableIteration extends E> iteration) {
+ try (iteration) {
// stream.collect is slightly slower than addAll for lists
List list = new ArrayList<>();
// addAll closes the iteration
- return addAll(iter, list);
+ return addAll(iteration, list);
}
}
/**
* Get a Set containing all elements obtained from the specified iteration.
*
- * @param iter the {@link CloseableIteration} to get the elements from
+ * @param iteration 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> iter) {
- try (Stream extends E> stream = iter.stream()) {
+ public static Set asSet(CloseableIteration extends E> iteration) {
+ try (Stream extends E> stream = iteration.stream()) {
return stream.collect(Collectors.toSet());
}
}
@@ -59,15 +59,14 @@ public static Set asSet(CloseableIteration extends
* Adds all elements from the supplied {@link CloseableIteration} to the specified collection then closes the
* {@link CloseableIteration}.
*
- * @param iter A {@link CloseableIteration} containing elements to add to the container.
+ * @param iteration A {@link CloseableIteration} 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(CloseableIteration extends E> iter,
- C collection) {
- try (iter) {
- while (iter.hasNext()) {
- collection.add(iter.next());
+ public static > C addAll(CloseableIteration extends E> iteration, C collection) {
+ try (iteration) {
+ while (iteration.hasNext()) {
+ collection.add(iteration.next());
}
}
@@ -108,7 +107,7 @@ public static Stream stream(CloseableIteration iteration) {
* @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> iteration, String separator) {
+ public static String toString(CloseableIteration> iteration, String separator) {
try (iteration) {
StringBuilder sb = new StringBuilder();
toString(iteration, separator, sb);
@@ -125,9 +124,7 @@ public static String toString(CloseableIteration> iterat
* @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> iteration, String separator,
- StringBuilder sb)
- throws X {
+ public static void toString(CloseableIteration> iteration, String separator, StringBuilder sb) {
try (iteration) {
while (iteration.hasNext()) {
sb.append(iteration.next());
@@ -147,13 +144,15 @@ public static void toString(CloseableIteration> iteratio
* @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> iteration,
+ public static Set asSet(CloseableIteration extends E> iteration,
Supplier> setMaker) {
- Set set = setMaker.get();
- while (iteration.hasNext()) {
- set.add(iteration.next());
+ try (iteration) {
+ Set set = setMaker.get();
+ while (iteration.hasNext()) {
+ set.add(iteration.next());
+ }
+ return set;
}
- return set;
}
}
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 e3280077856..ee4c22e46f9 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
@@ -17,7 +17,6 @@
* An Iteration that limits the amount of elements that it returns from an underlying Iteration to a fixed amount. This
* class returns the first limit elements from the underlying Iteration and drops the rest.
*/
-@Deprecated(since = "4.1.0")
public class LimitIteration extends IterationWrapper {
/*-----------*
@@ -47,7 +46,6 @@ public class LimitIteration extends IterationWrapper {
public LimitIteration(CloseableIteration extends E> iter, long limit) {
super(iter);
- assert iter != null;
assert limit >= 0;
this.limit = limit;
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 03b14dbed0b..7e7b114f4bf 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
@@ -18,7 +18,6 @@
* super class for Iterations that have no easy way to tell if there are any more results, but still should implement
* the java.util.Iteration interface.
*/
-@Deprecated(since = "4.1.0")
public abstract class LookAheadIteration extends AbstractCloseableIteration {
/*-----------*
@@ -73,7 +72,6 @@ public final E next() {
* Fetches the next element if it hasn't been fetched yet and stores it in {@link #nextElement}.
*
* @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() {
if (nextElement == null) {
@@ -94,8 +92,4 @@ public void remove() {
throw new UnsupportedOperationException();
}
- @Override
- 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 1df41bdddbc..596fee80495 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
@@ -22,7 +22,6 @@
* Note that duplicates can also be filtered by wrapping this Iteration in a {@link DistinctIteration}, but that has a
* bit more overhead as it adds a second hash table lookup.
*/
-@Deprecated(since = "4.1.0")
public class MinusIteration extends FilterIteration {
/*-----------*
@@ -124,11 +123,8 @@ protected boolean accept(E object) {
@Override
protected void handleClose() {
- try {
- super.handleClose();
- } finally {
- if (rightArg != null)
- rightArg.close();
+ 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 66be1546ff4..b509358b44d 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
@@ -14,7 +14,6 @@
/**
* An Iteration that skips the first offset elements from an underlying Iteration.
*/
-@Deprecated(since = "4.1.0")
public class OffsetIteration extends FilterIteration {
/*-----------*
@@ -66,4 +65,9 @@ protected boolean accept(E object) {
return true;
}
}
+
+ @Override
+ protected void handleClose() {
+
+ }
}
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 b3b11a59ea0..789d361adba 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
@@ -24,7 +24,6 @@
*
* @author James Leigh
*/
-@Deprecated(since = "4.1.0")
public abstract class QueueIteration extends LookAheadIteration {
private final AtomicBoolean done = new AtomicBoolean(false);
@@ -156,15 +155,11 @@ public E getNextElement() {
@Override
public void handleClose() {
- try {
- super.handleClose();
- } finally {
- done.set(true);
- do {
- queue.clear(); // ensure extra room is available
- } while (!queue.offer(afterLast));
- checkException();
- }
+ done.set(true);
+ do {
+ queue.clear(); // ensure extra room is available
+ } while (!queue.offer(afterLast));
+ checkException();
}
public void checkException() throws T {
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 5e62199dfc4..be6b0f2ebc8 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
@@ -15,7 +15,6 @@
*
* @author Arjohn Kampman
*/
-@Deprecated(since = "4.1.0")
public class ReducedIteration extends FilterIteration {
private E previousObject;
@@ -33,4 +32,9 @@ protected boolean accept(E nextObject) {
return true;
}
}
+
+ @Override
+ protected void handleClose() {
+
+ }
}
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 36b9d03d0c8..cc2d6e0b613 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
@@ -21,7 +21,6 @@
*
* @author Jeen Broekstra
*/
-@Deprecated(since = "4.1.0")
public class SilentIteration extends IterationWrapper {
private static final Logger logger = LoggerFactory.getLogger(SilentIteration.class);
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 154551cfffa..00827c392ff 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
@@ -16,19 +16,10 @@
/**
* An Iteration that contains exactly one element.
*/
-@Deprecated(since = "4.1.0")
public class SingletonIteration extends AbstractCloseableIteration {
- /*-----------*
- * Variables *
- *-----------*/
-
private E value;
- /*--------------*
- * Constructors *
- *--------------*/
-
/**
* Creates a new EmptyIteration.
*/
@@ -36,10 +27,6 @@ public SingletonIteration(E value) {
this.value = value;
}
- /*---------*
- * Methods *
- *---------*/
-
@Override
public boolean hasNext() {
return 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 f7f3a043383..da0f542223d 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
@@ -20,7 +20,6 @@
/**
* @author Arjohn Kampman
*/
-@Deprecated(since = "4.1.0")
public abstract class TimeLimitIteration extends IterationWrapper {
private static final Timer timer = new Timer("TimeLimitIteration", true);
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 334cfa0ad7a..164fb493199 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
@@ -21,7 +21,6 @@
* An Iteration that returns the bag union of the results of a number of Iterations. 'Bag union' means that the
* UnionIteration does not filter duplicate objects.
*/
-@Deprecated(since = "4.1.0")
public class UnionIteration extends LookAheadIteration {
/*-----------*
@@ -92,30 +91,25 @@ protected E getNextElement() {
@Override
protected void handleClose() {
try {
- // Close this iteration, this will prevent lookAhead() from calling
- // getNextElement() again
- super.handleClose();
- } finally {
- try {
- List collectedExceptions = new ArrayList<>();
- while (argIter.hasNext()) {
- try {
- CloseableIteration extends E> next = argIter.next();
- if (next != null) {
- next.close();
- }
- } catch (Throwable e) {
- collectedExceptions.add(e);
+ List collectedExceptions = new ArrayList<>();
+ while (argIter.hasNext()) {
+ try {
+ CloseableIteration extends E> next = argIter.next();
+ if (next != null) {
+ next.close();
}
+ } catch (Throwable e) {
+ collectedExceptions.add(e);
}
- if (!collectedExceptions.isEmpty()) {
- throw new UndeclaredThrowableException(collectedExceptions.get(0));
- }
- } finally {
- if (currentIter != null) {
- currentIter.close();
- }
+ }
+ if (!collectedExceptions.isEmpty()) {
+ throw new UndeclaredThrowableException(collectedExceptions.get(0));
+ }
+ } finally {
+ if (currentIter != null) {
+ currentIter.close();
}
}
+
}
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/AbstractCloseableIterator.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/AbstractCloseableIterator.java
index 709f2c8e6cf..bce3545c700 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/AbstractCloseableIterator.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/AbstractCloseableIterator.java
@@ -58,8 +58,6 @@ public final void close() throws IOException {
/**
* Called by {@link #close} when it is called for the first time. This method is only called once on each iteration.
* By default, this method does nothing.
- *
- * @throws X
*/
protected void handleClose() throws IOException {
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/FilterIterator.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/FilterIterator.java
index 190a0a47eea..4d60284b9b3 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/FilterIterator.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/FilterIterator.java
@@ -70,7 +70,6 @@ public void remove() {
*
* @param object The object to be tested.
* @return true if the object should be returned, false otherwise.
- * @throws X
*/
protected abstract boolean accept(E object);
}
diff --git a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/LookAheadIterator.java b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/LookAheadIterator.java
index 026b3ac724a..155155b9128 100644
--- a/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/LookAheadIterator.java
+++ b/core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iterator/LookAheadIterator.java
@@ -74,8 +74,6 @@ public final E next() {
/**
* Fetches the next element if it hasn't been fetched yet and stores it in {@link #nextElement}.
- *
- * @throws X
*/
private void lookAhead() {
if (nextElement == null && !isClosed()) {
diff --git a/core/common/text/src/main/java/org/eclipse/rdf4j/common/text/StringUtil.java b/core/common/text/src/main/java/org/eclipse/rdf4j/common/text/StringUtil.java
index 298a7f8ede4..442b648478f 100644
--- a/core/common/text/src/main/java/org/eclipse/rdf4j/common/text/StringUtil.java
+++ b/core/common/text/src/main/java/org/eclipse/rdf4j/common/text/StringUtil.java
@@ -24,58 +24,6 @@ public class StringUtil {
Arrays.sort(IRI_DONT_ESCAPE);
}
- /**
- * Substitute String "old" by String "new" in String "text" everywhere. This is a static util function that I could
- * not place anywhere more appropriate. The name of this function is from the good-old awk time.
- *
- * @param olds The String to be substituted.
- * @param news The String is the new content.
- * @param text The String in which the substitution is done.
- * @return The result String containing the substitutions; if no substitutions were made, the result is 'text'.
- * @deprecated use {@link String#replace(CharSequence, CharSequence) instead}.
- */
- @Deprecated(since = "4.0.0")
- public static String gsub(String olds, String news, String text) {
- if (olds == null || olds.length() == 0) {
- // Nothing to substitute.
- return text;
- }
- if (text == null) {
- return null;
- }
-
- // Search for any occurences of 'olds'.
- int oldsIndex = text.indexOf(olds);
- if (oldsIndex == -1) {
- // Nothing to substitute.
- return text;
- }
-
- // We're going to do some substitutions.
- StringBuilder buf = new StringBuilder(text.length());
- int prevIndex = 0;
-
- while (oldsIndex >= 0) {
- // First, add the text between the previous and the current
- // occurence.
- buf.append(text.substring(prevIndex, oldsIndex));
-
- // Then add the substition pattern
- buf.append(news);
-
- // Remember the index for the next loop.
- prevIndex = oldsIndex + olds.length();
-
- // Search for the next occurence.
- oldsIndex = text.indexOf(olds, prevIndex);
- }
-
- // Add the part after the last occurence.
- buf.append(text.substring(prevIndex));
-
- return buf.toString();
- }
-
private static String hex(int c) {
return Integer.toHexString(c).toUpperCase(Locale.US);
}
diff --git a/core/model-vocabulary/src/main/java/org/eclipse/rdf4j/model/vocabulary/XSD.java b/core/model-vocabulary/src/main/java/org/eclipse/rdf4j/model/vocabulary/XSD.java
index e2921be26d6..1562549b02e 100644
--- a/core/model-vocabulary/src/main/java/org/eclipse/rdf4j/model/vocabulary/XSD.java
+++ b/core/model-vocabulary/src/main/java/org/eclipse/rdf4j/model/vocabulary/XSD.java
@@ -193,216 +193,4 @@ public class XSD {
/** http://www.w3.org/2001/XMLSchema#yearMonthDuration */
public final static IRI YEARMONTHDURATION = CoreDatatype.XSD.YEARMONTHDURATION.getIri();
- private static IRI create(String localName) {
- return Vocabularies.createIRI(org.eclipse.rdf4j.model.vocabulary.XSD.NAMESPACE, localName);
- }
-
- @Deprecated(since = "5.0.0", forRemoval = true)
- public enum Datatype {
-
- DURATION(CoreDatatype.XSD.DURATION.getIri(), true, true, false, false, false, false, false),
- DATETIME(CoreDatatype.XSD.DATETIME.getIri(), true, false, false, false, false, false, true),
- DATETIMESTAMP(CoreDatatype.XSD.DATETIMESTAMP.getIri(), false, false, false, true, false, false, true),
- DAYTIMEDURATION(CoreDatatype.XSD.DAYTIMEDURATION.getIri(), false, true, false, true, false, false, false),
- TIME(CoreDatatype.XSD.TIME.getIri(), true, false, false, false, false, false, true),
- DATE(CoreDatatype.XSD.DATE.getIri(), true, false, false, false, false, false, true),
- GYEARMONTH(CoreDatatype.XSD.GYEARMONTH.getIri(), true, false, false, false, false, false, true),
- GYEAR(CoreDatatype.XSD.GYEAR.getIri(), true, false, false, false, false, false, true),
- GMONTHDAY(CoreDatatype.XSD.GMONTHDAY.getIri(), true, false, false, false, false, false, true),
- GDAY(CoreDatatype.XSD.GDAY.getIri(), true, false, false, false, false, false, true),
- GMONTH(CoreDatatype.XSD.GMONTH.getIri(), true, false, false, false, false, false, true),
- STRING(CoreDatatype.XSD.STRING.getIri(), true, false, false, false, false, false, false),
- BOOLEAN(CoreDatatype.XSD.BOOLEAN.getIri(), true, false, false, false, false, false, false),
- BASE64BINARY(CoreDatatype.XSD.BASE64BINARY.getIri(), true, false, false, false, false, false, false),
- HEXBINARY(CoreDatatype.XSD.HEXBINARY.getIri(), true, false, false, false, false, false, false),
- FLOAT(CoreDatatype.XSD.FLOAT.getIri(), true, false, false, false, false, true, false),
- DECIMAL(CoreDatatype.XSD.DECIMAL.getIri(), true, false, false, false, true, false, false),
- DOUBLE(CoreDatatype.XSD.DOUBLE.getIri(), true, false, false, false, false, true, false),
- ANYURI(CoreDatatype.XSD.ANYURI.getIri(), true, false, false, false, false, false, false),
- QNAME(CoreDatatype.XSD.QNAME.getIri(), true, false, false, false, false, false, false),
- NOTATION(CoreDatatype.XSD.NOTATION.getIri(), true, false, false, false, false, false, false),
- NORMALIZEDSTRING(CoreDatatype.XSD.NORMALIZEDSTRING.getIri(), false, false, false, true, false, false, false),
- TOKEN(CoreDatatype.XSD.TOKEN.getIri(), false, false, false, true, false, false, false),
- LANGUAGE(CoreDatatype.XSD.LANGUAGE.getIri(), false, false, false, true, false, false, false),
- NMTOKEN(CoreDatatype.XSD.NMTOKEN.getIri(), false, false, false, true, false, false, false),
- NMTOKENS(CoreDatatype.XSD.NMTOKENS.getIri(), false, false, false, true, false, false, false),
- NAME(CoreDatatype.XSD.NAME.getIri(), false, false, false, true, false, false, false),
- NCNAME(CoreDatatype.XSD.NCNAME.getIri(), false, false, false, true, false, false, false),
- ID(CoreDatatype.XSD.ID.getIri(), false, false, false, true, false, false, false),
- IDREF(CoreDatatype.XSD.IDREF.getIri(), false, false, false, true, false, false, false),
- IDREFS(CoreDatatype.XSD.IDREFS.getIri(), false, false, false, true, false, false, false),
- ENTITY(CoreDatatype.XSD.ENTITY.getIri(), false, false, false, true, false, false, false),
- ENTITIES(CoreDatatype.XSD.ENTITIES.getIri(), false, false, false, true, false, false, false),
- INTEGER(CoreDatatype.XSD.INTEGER.getIri(), false, false, true, true, true, false, false),
- LONG(CoreDatatype.XSD.LONG.getIri(), false, false, true, true, true, false, false),
- INT(CoreDatatype.XSD.INT.getIri(), false, false, true, true, true, false, false),
- SHORT(CoreDatatype.XSD.SHORT.getIri(), false, false, true, true, true, false, false),
- BYTE(CoreDatatype.XSD.BYTE.getIri(), false, false, true, true, true, false, false),
- NON_POSITIVE_INTEGER(CoreDatatype.XSD.NON_POSITIVE_INTEGER.getIri(), false, false, true, true, true, false,
- false),
- NEGATIVE_INTEGER(CoreDatatype.XSD.NEGATIVE_INTEGER.getIri(), false, false, true, true, true, false, false),
- NON_NEGATIVE_INTEGER(CoreDatatype.XSD.NON_NEGATIVE_INTEGER.getIri(), false, false, true, true, true, false,
- false),
- POSITIVE_INTEGER(CoreDatatype.XSD.POSITIVE_INTEGER.getIri(), false, false, true, true, true, false, false),
- UNSIGNED_LONG(CoreDatatype.XSD.UNSIGNED_LONG.getIri(), false, false, true, true, true, false, false),
- UNSIGNED_INT(CoreDatatype.XSD.UNSIGNED_INT.getIri(), false, false, true, true, true, false, false),
- UNSIGNED_SHORT(CoreDatatype.XSD.UNSIGNED_SHORT.getIri(), false, false, true, true, true, false, false),
- UNSIGNED_BYTE(CoreDatatype.XSD.UNSIGNED_BYTE.getIri(), false, false, true, true, true, false, false),
- YEARMONTHDURATION(CoreDatatype.XSD.YEARMONTHDURATION.getIri(), false, true, false, true, false, false, false);
-
- private final IRI iri;
- private final boolean primitive;
- private final boolean duration;
- private final boolean integer;
- private final boolean derived;
- private final boolean decimal;
- private final boolean floatingPoint;
- private final boolean calendar;
- private final CoreDatatype.XSD coreDatatype;
-
- Datatype(IRI iri, boolean primitive, boolean duration, boolean integer, boolean derived, boolean decimal,
- boolean floatingPoint, boolean calendar) {
- this.iri = iri;
- this.primitive = primitive;
- this.duration = duration;
- this.integer = integer;
- this.derived = derived;
- this.decimal = decimal;
- this.floatingPoint = floatingPoint;
- this.calendar = calendar;
- this.coreDatatype = CoreDatatype.from(iri).asXSDDatatype().orElseThrow();
- }
-
- /**
- * Checks whether the supplied datatype is a primitive XML Schema datatype.
- *
- * @return true if the datatype is a primitive type
- */
- public boolean isPrimitiveDatatype() {
- return primitive;
- }
-
- /**
- * Checks whether the supplied datatype is a derived XML Schema datatype.
- *
- * @return true if the datatype is a derived type
- */
- public boolean isDerivedDatatype() {
- return derived;
- }
-
- /**
- * Checks whether the supplied datatype is a built-in XML Schema datatype.
- *
- * @return true if it is a primitive or derived XML Schema type
- */
- public boolean isBuiltInDatatype() {
- return isPrimitiveDatatype() || isDerivedDatatype();
- }
-
- /**
- * Checks whether the supplied datatype is a numeric datatype, i.e.if it is equal to xsd:float, xsd:double,
- * xsd:decimal or one of the datatypes derived from xsd:decimal.
- *
- * @return true of it is a decimal or floating point type
- */
- public boolean isNumericDatatype() {
- return isDecimalDatatype() || isFloatingPointDatatype();
- }
-
- /**
- * Checks whether the supplied datatype is equal to xsd:decimal or one of the built-in datatypes that is derived
- * from xsd:decimal.
- *
- * @return true if it is a decimal datatype
- */
- public boolean isDecimalDatatype() {
- return decimal;
- }
-
- /**
- * Checks whether the supplied datatype is equal to xsd:integer or one of the built-in datatypes that is derived
- * from xsd:integer.
- *
- * @return true if it is an integer type
- */
- public boolean isIntegerDatatype() {
- return integer;
- }
-
- /**
- * Checks whether the supplied datatype is equal to xsd:float or xsd:double.
- *
- * @return true if it is a floating point type
- */
- public boolean isFloatingPointDatatype() {
- return floatingPoint;
- }
-
- /**
- * Checks whether the supplied datatype is equal to xsd:dateTime, xsd:date, xsd:time, xsd:gYearMonth,
- * xsd:gMonthDay, xsd:gYear, xsd:gMonth or xsd:gDay.These are the primitive datatypes that represent dates
- * and/or times.
- *
- * @return true if it is a calendar type
- * @see XMLGregorianCalendar
- */
- public boolean isCalendarDatatype() {
- return calendar;
- }
-
- /**
- * Checks whether the supplied datatype is equal to xsd:duration, xsd:dayTimeDuration, xsd:yearMonthDuration.
- * These are the datatypes that represents durations.
- *
- * @return true if it is a duration type
- * @see Duration
- */
- public boolean isDurationDatatype() {
- return duration;
- }
-
- /**
- * Checks whether the supplied datatype is ordered.The values of an ordered datatype can be compared to each
- * other using operators like < and >.
- *
- * @return true if the datatype is ordered
- */
- public boolean isOrderedDatatype() {
- return isNumericDatatype() || isCalendarDatatype();
- }
-
- public IRI getIri() {
- return iri;
- }
-
- public CoreDatatype getCoreDatatype() {
- return coreDatatype;
- }
-
- private static final Map> reverseLookup = new HashMap<>();
-
- private static final Map> reverseLookupXSDDatatype = new EnumMap<>(
- CoreDatatype.XSD.class);
-
- static {
- for (Datatype value : Datatype.values()) {
- reverseLookup.put(value.iri, Optional.of(value));
- reverseLookupXSDDatatype.put(value.coreDatatype, Optional.of(value));
- }
- }
-
- public static Optional from(IRI datatype) {
- return reverseLookup.getOrDefault(datatype, Optional.empty());
- }
-
- public static Optional from(CoreDatatype.XSD datatype) {
- if (datatype == null) {
- return Optional.empty();
- }
- return reverseLookupXSDDatatype.getOrDefault(datatype, Optional.empty());
- }
-
- }
-
}
diff --git a/core/model/src/main/java/org/eclipse/rdf4j/model/util/Literals.java b/core/model/src/main/java/org/eclipse/rdf4j/model/util/Literals.java
index 5d540d79390..02c39595441 100644
--- a/core/model/src/main/java/org/eclipse/rdf4j/model/util/Literals.java
+++ b/core/model/src/main/java/org/eclipse/rdf4j/model/util/Literals.java
@@ -57,11 +57,6 @@ public static String getLabel(Value v, String fallback) {
return v instanceof Literal ? getLabel((Literal) v, fallback) : fallback;
}
- @Deprecated(since = "5.0.0", forRemoval = true)
- public static String getLabel(Optional v, String fallback) {
- return v != null ? getLabel(v.orElseGet(null), fallback) : fallback;
- }
-
/**
* Gets the byte value of the supplied literal. The fallback value is returned in case {@link Literal#byteValue()}
* throws a {@link NumberFormatException}.
diff --git a/core/model/src/test/java/org/eclipse/rdf4j/model/util/LiteralsTest.java b/core/model/src/test/java/org/eclipse/rdf4j/model/util/LiteralsTest.java
index 13af1ffa324..aada20f5ddb 100644
--- a/core/model/src/test/java/org/eclipse/rdf4j/model/util/LiteralsTest.java
+++ b/core/model/src/test/java/org/eclipse/rdf4j/model/util/LiteralsTest.java
@@ -877,33 +877,4 @@ public void testCanCreateLiteralObjectObject() {
}
- /**
- * Test method for {@link org.eclipse.rdf4j.model.util.Literals#getLabel(Optional, String)}} .
- */
- @Test
- public void testGetLabelForOptional() {
-
- Literal lit = vf.createLiteral(1.0);
- model.add(foo, bar, lit);
-
- Optional result = Models.object(model);
- String label = Literals.getLabel(result, "fallback");
- assertNotNull(label);
- assertTrue(label.equals("1.0"));
- }
-
- /**
- * Test method for {@link org.eclipse.rdf4j.model.util.Literals#getLabel(Optional, String)}} .
- */
- @Test
- public void testGetLabelForOptionalInFallback() {
-
- Literal lit = vf.createLiteral(1.0);
- model.add(foo, bar, lit);
-
- Optional result = Models.object(model);
- String label = Literals.getLabel((Optional) null, "fallback");
- assertNotNull(label);
- assertTrue(label.equals("fallback"));
- }
}
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/QueryResultUtil.java b/core/query/src/main/java/org/eclipse/rdf4j/query/QueryResultUtil.java
deleted file mode 100644
index 3790e4cfb4c..00000000000
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/QueryResultUtil.java
+++ /dev/null
@@ -1,20 +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.query;
-
-/**
- * @author Jeen Broekstra
- * @deprecated Use {@link QueryResults} instead.
- */
-@Deprecated(since = "2.0")
-public class QueryResultUtil extends QueryResults {
-
-}
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/QueryResults.java b/core/query/src/main/java/org/eclipse/rdf4j/query/QueryResults.java
index 90448a63c1f..89ade8c1499 100644
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/QueryResults.java
+++ b/core/query/src/main/java/org/eclipse/rdf4j/query/QueryResults.java
@@ -12,7 +12,6 @@
import java.io.InputStream;
import java.lang.ref.Cleaner;
-import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -72,9 +71,10 @@ public class QueryResults extends Iterations {
* @param iteration the source iteration to get the statements from.
* @return a {@link Model} containing all statements obtained from the specified source iteration.
*/
- public static Model asModel(CloseableIteration extends Statement> iteration)
- throws QueryEvaluationException {
- return asModel(iteration, new DynamicModelFactory());
+ public static Model asModel(CloseableIteration extends Statement> iteration) throws QueryEvaluationException {
+ try (iteration) {
+ return asModel(iteration, new DynamicModelFactory());
+ }
}
/**
@@ -84,12 +84,13 @@ public static Model asModel(CloseableIteration extends Statement> iteration)
* @param modelFactory the ModelFactory used to instantiate the model that gets returned.
* @return a {@link Model} containing all statements obtained from the specified source iteration.
*/
- public static Model asModel(CloseableIteration extends Statement> iteration,
- ModelFactory modelFactory)
+ public static Model asModel(CloseableIteration extends Statement> iteration, ModelFactory modelFactory)
throws QueryEvaluationException {
- Model model = modelFactory.createEmptyModel();
- addAll(iteration, model);
- return model;
+ try (iteration) {
+ Model model = modelFactory.createEmptyModel();
+ addAll(iteration, model);
+ return model;
+ }
}
/**
@@ -99,11 +100,13 @@ public static Model asModel(CloseableIteration extends Statement> iteration,
* @return a List containing all elements obtained from the specified query result.
*/
public static List asList(QueryResult queryResult) throws QueryEvaluationException {
- // stream.collect is slightly slower than addAll for lists
- List list = new ArrayList<>();
+ try (queryResult) {
+ // stream.collect is slightly slower than addAll for lists
+ List list = new ArrayList<>();
- // addAll closes the iteration
- return addAll(queryResult, list);
+ // addAll closes the iteration
+ return addAll(queryResult, list);
+ }
}
/**
@@ -242,13 +245,10 @@ public static GraphQueryResult limitResults(GraphQueryResult queryResult, long l
* @param baseURI The base URI for the RDF document.
* @param format The {@link RDFFormat} of the RDF document.
* @return A {@link GraphQueryResult} that parses in the background, and must be closed to prevent resource leaks.
- * @deprecated WeakReference> callerReference argument will be removed
*/
- @Deprecated(since = "4.1.2")
- public static GraphQueryResult parseGraphBackground(InputStream in, String baseURI, RDFFormat format,
- WeakReference> callerReference)
+ public static GraphQueryResult parseGraphBackground(InputStream in, String baseURI, RDFFormat format)
throws UnsupportedRDFormatException {
- return parseGraphBackground(in, baseURI, Rio.createParser(format), callerReference);
+ return parseGraphBackground(in, baseURI, Rio.createParser(format));
}
/**
@@ -261,12 +261,8 @@ public static GraphQueryResult parseGraphBackground(InputStream in, String baseU
* @param baseURI The base URI for the RDF document.
* @param parser The {@link RDFParser}.
* @return A {@link GraphQueryResult} that parses in the background, and must be closed to prevent resource leaks.
- * @deprecated WeakReference> callerReference argument will be removed
*/
- @Deprecated(since = "4.1.2")
- public static GraphQueryResult parseGraphBackground(InputStream in, String baseURI, RDFParser parser,
- WeakReference> callerReference) {
- assert callerReference == null;
+ public static GraphQueryResult parseGraphBackground(InputStream in, String baseURI, RDFParser parser) {
RDFFormat format = parser.getRDFFormat();
BackgroundGraphResult result = new BackgroundGraphResult(
new QueueCursor<>(new LinkedBlockingQueue<>(1)),
@@ -346,27 +342,32 @@ public static void report(GraphQueryResult graphQueryResult, RDFHandler rdfHandl
* @throws QueryEvaluationException
*/
public static boolean equals(TupleQueryResult tqr1, TupleQueryResult tqr2) throws QueryEvaluationException {
- List list1 = Iterations.asList(tqr1);
- List list2 = Iterations.asList(tqr2);
+ try (tqr1; tqr2) {
+ List list1 = Iterations.asList(tqr1);
+ List list2 = Iterations.asList(tqr2);
- // Compare the number of statements in both sets
- if (list1.size() != list2.size()) {
- return false;
- }
+ // Compare the number of statements in both sets
+ if (list1.size() != list2.size()) {
+ return false;
+ }
- return matchBindingSets(list1, list2);
+ return matchBindingSets(list1, list2);
+ }
}
public static boolean isSubset(TupleQueryResult tqr1, TupleQueryResult tqr2) throws QueryEvaluationException {
- List list1 = Iterations.asList(tqr1);
- List list2 = Iterations.asList(tqr2);
+ try (tqr1; tqr2) {
- // Compare the number of statements in both sets
- if (list1.size() > list2.size()) {
- return false;
- }
+ List list1 = Iterations.asList(tqr1);
+ List list2 = Iterations.asList(tqr2);
- return matchBindingSets(list1, list2);
+ // Compare the number of statements in both sets
+ if (list1.size() > list2.size()) {
+ return false;
+ }
+
+ return matchBindingSets(list1, list2);
+ }
}
/**
@@ -380,10 +381,12 @@ public static boolean isSubset(TupleQueryResult tqr1, TupleQueryResult tqr2) thr
* @see Models#isomorphic(Iterable, Iterable)
*/
public static boolean equals(GraphQueryResult result1, GraphQueryResult result2) throws QueryEvaluationException {
- Set extends Statement> graph1 = Iterations.asSet(result1);
- Set extends Statement> graph2 = Iterations.asSet(result2);
+ try (result1; result2) {
+ Set extends Statement> graph1 = Iterations.asSet(result1);
+ Set extends Statement> graph2 = Iterations.asSet(result2);
- return Models.isomorphic(graph1, graph2);
+ return Models.isomorphic(graph1, graph2);
+ }
}
private static boolean matchBindingSets(List extends BindingSet> queryResult1,
@@ -543,14 +546,13 @@ public static boolean bindingSetsCompatible(BindingSet bs1, BindingSet bs2) {
Set bs2BindingNames = bs2.getBindingNames();
- for (String bindingName : bs1BindingNames) {
-
- if (bs2BindingNames.contains(bindingName)) {
- Value value1 = bs1.getValue(bindingName);
+ for (Binding binding : bs1) {
+ if (bs2BindingNames.contains(binding.getName())) {
+ Value value1 = binding.getValue();
// if a variable is unbound in one set it is compatible
if (value1 != null) {
- Value value2 = bs2.getValue(bindingName);
+ Value value2 = bs2.getValue(binding.getName());
// if a variable is unbound in one set it is compatible
if (value2 != null && !value1.equals(value2)) {
@@ -559,6 +561,7 @@ public static boolean bindingSetsCompatible(BindingSet bs1, BindingSet bs2) {
}
}
+
}
return true;
@@ -619,11 +622,7 @@ public void remove() throws QueryEvaluationException {
@Override
public void handleClose() throws QueryEvaluationException {
- try {
- super.handleClose();
- } finally {
- filter.close();
- }
+ filter.close();
}
@Override
@@ -687,11 +686,7 @@ public void remove() throws QueryEvaluationException {
@Override
public void handleClose() throws QueryEvaluationException {
- try {
- super.handleClose();
- } finally {
- filter.close();
- }
+ filter.close();
}
@Override
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/TupleQueryResultHandlerBase.java b/core/query/src/main/java/org/eclipse/rdf4j/query/TupleQueryResultHandlerBase.java
deleted file mode 100644
index 95485024e55..00000000000
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/TupleQueryResultHandlerBase.java
+++ /dev/null
@@ -1,20 +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.query;
-
-/**
- * @author Jeen Broekstra
- * @deprecated since 2.0. Use {@link AbstractTupleQueryResultHandler} instead.
- */
-@Deprecated(since = "2.0")
-public class TupleQueryResultHandlerBase extends AbstractTupleQueryResultHandler {
-
-}
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/BackgroundGraphResult.java b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/BackgroundGraphResult.java
index 9ad807c32f6..79bd055f6e6 100644
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/BackgroundGraphResult.java
+++ b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/BackgroundGraphResult.java
@@ -31,7 +31,6 @@
*
* @author James Leigh
*/
-@Deprecated(since = "4.1.0")
public class BackgroundGraphResult extends IterationWrapper
implements GraphQueryResult, Runnable, RDFHandler {
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/BindingImpl.java b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/BindingImpl.java
deleted file mode 100644
index fc0460d7a07..00000000000
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/BindingImpl.java
+++ /dev/null
@@ -1,28 +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.query.impl;
-
-import org.eclipse.rdf4j.model.Value;
-
-/**
- * @author Jeen Broekstra
- * @deprecated Use {@link SimpleBinding} instead.
- */
-@Deprecated(since = "2.0")
-public class BindingImpl extends SimpleBinding {
-
- private static final long serialVersionUID = 1L;
-
- public BindingImpl(String name, Value value) {
- super(name, value);
- }
-
-}
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/DatasetImpl.java b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/DatasetImpl.java
deleted file mode 100644
index cf818fd3fed..00000000000
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/DatasetImpl.java
+++ /dev/null
@@ -1,22 +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.query.impl;
-
-/**
- * @author Jeen Broekstra
- * @deprecated Use {@link SimpleDataset} instead.
- */
-@Deprecated(since = "2.0")
-public class DatasetImpl extends SimpleDataset {
-
- private static final long serialVersionUID = 1L;
-
-}
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/GraphQueryResultImpl.java b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/GraphQueryResultImpl.java
deleted file mode 100644
index da47c3418cb..00000000000
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/GraphQueryResultImpl.java
+++ /dev/null
@@ -1,30 +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.query.impl;
-
-import java.util.Map;
-
-import org.eclipse.rdf4j.common.iteration.CloseableIteration;
-import org.eclipse.rdf4j.model.Statement;
-
-/**
- * @author Jeen Broekstra
- * @deprecated since 2.0. Use {@link IteratingGraphQueryResult} instead.
- */
-@Deprecated(since = "2.0")
-public class GraphQueryResultImpl extends IteratingGraphQueryResult {
-
- public GraphQueryResultImpl(Map namespaces,
- CloseableIteration extends Statement> statementIter) {
- super(namespaces, statementIter);
- }
-
-}
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/IteratingGraphQueryResult.java b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/IteratingGraphQueryResult.java
index f1348f5271c..9b2e2bbb653 100644
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/IteratingGraphQueryResult.java
+++ b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/IteratingGraphQueryResult.java
@@ -26,7 +26,6 @@
* @author Arjohn Kampman
* @author Jeen Broekstra
*/
-@Deprecated(since = "4.1.0")
public class IteratingGraphQueryResult extends IterationWrapper
implements GraphQueryResult {
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/IteratingTupleQueryResult.java b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/IteratingTupleQueryResult.java
index 4b59aafe843..4a2794b8bc7 100644
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/IteratingTupleQueryResult.java
+++ b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/IteratingTupleQueryResult.java
@@ -24,7 +24,6 @@
/**
* An iterating implementation of the {@link TupleQueryResult} interface.
*/
-@Deprecated(since = "4.1.0")
public class IteratingTupleQueryResult extends IterationWrapper
implements TupleQueryResult {
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/TupleQueryResultImpl.java b/core/query/src/main/java/org/eclipse/rdf4j/query/impl/TupleQueryResultImpl.java
deleted file mode 100644
index b800e419f65..00000000000
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/impl/TupleQueryResultImpl.java
+++ /dev/null
@@ -1,30 +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.query.impl;
-
-import java.util.List;
-
-import org.eclipse.rdf4j.common.iteration.CloseableIteration;
-import org.eclipse.rdf4j.query.BindingSet;
-
-/**
- * @author Jeen Broekstra
- * @deprecated Use {@link IteratingTupleQueryResult} instead.
- */
-@Deprecated(since = "2.0")
-public class TupleQueryResultImpl extends IteratingTupleQueryResult {
-
- public TupleQueryResultImpl(List bindingNames,
- CloseableIteration extends BindingSet> bindingSetIter) {
- super(bindingNames, bindingSetIter);
- }
-
-}
diff --git a/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/FilterIterationTest.java b/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/FilterIterationTest.java
index a8f8615c5b2..a5753d79cd3 100644
--- a/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/FilterIterationTest.java
+++ b/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/FilterIterationTest.java
@@ -16,13 +16,18 @@ public class FilterIterationTest extends CloseableIterationTest {
@Override
protected CloseableIteration createTestIteration() {
- return new FilterIteration(createStringList1Iteration()) {
+ return new FilterIteration<>(createStringList1Iteration()) {
@Override
protected boolean accept(String object) {
return "3".equals(object);
}
+ @Override
+ protected void handleClose() {
+
+ }
+
};
}
diff --git a/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/IteratorIterationTest.java b/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/IteratorIterationTest.java
deleted file mode 100644
index ffecef51861..00000000000
--- a/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/IteratorIterationTest.java
+++ /dev/null
@@ -1,24 +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;
-
-public class IteratorIterationTest extends IterationTest {
-
- @Override
- protected CloseableIteration createTestIteration() {
- return new IteratorIteration<>(stringList1.iterator());
- }
-
- @Override
- protected int getTestIterationSize() {
- return stringList1.size();
- }
-}
diff --git a/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/LookAheadIterationTest.java b/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/LookAheadIterationTest.java
index 2afb16e3640..bbbc938f616 100644
--- a/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/LookAheadIterationTest.java
+++ b/core/query/src/test/java/org/eclipse/rdf4j/common/iteration/LookAheadIterationTest.java
@@ -18,7 +18,12 @@ public class LookAheadIterationTest extends CloseableIterationTest {
protected CloseableIteration createTestIteration() {
final Iterator iter = stringList1.iterator();
- return new LookAheadIteration() {
+ return new LookAheadIteration<>() {
+
+ @Override
+ protected void handleClose() {
+
+ }
@Override
protected String getNextElement() {
diff --git a/core/query/src/test/java/org/eclipse/rdf4j/query/QueryResultsTest.java b/core/query/src/test/java/org/eclipse/rdf4j/query/QueryResultsTest.java
index 23035e7128f..1b93ee48eab 100644
--- a/core/query/src/test/java/org/eclipse/rdf4j/query/QueryResultsTest.java
+++ b/core/query/src/test/java/org/eclipse/rdf4j/query/QueryResultsTest.java
@@ -258,6 +258,10 @@ public Map getNamespaces() throws QueryEvaluationException {
return null;
}
+ @Override
+ protected void handleClose() {
+
+ }
}
@Test
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/ArrayBindingSet.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/ArrayBindingSet.java
index 242cb73a71b..a7b665cb9c2 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/ArrayBindingSet.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/ArrayBindingSet.java
@@ -46,6 +46,7 @@ public class ArrayBindingSet extends AbstractBindingSet implements MutableBindin
// Creating a LinkedHashSet is expensive, so we should cache the binding names set
private Set bindingNamesSetCache;
+ private boolean empty;
private final boolean[] whichBindingsHaveBeenSet;
@@ -62,6 +63,7 @@ public ArrayBindingSet(String... names) {
this.bindingNames = names;
this.values = new Value[names.length];
this.whichBindingsHaveBeenSet = new boolean[names.length];
+ this.empty = true;
}
public ArrayBindingSet(BindingSet toCopy, Set names, String[] namesArray) {
@@ -77,14 +79,17 @@ public ArrayBindingSet(BindingSet toCopy, Set names, String[] namesArray
this.whichBindingsHaveBeenSet[i] = true;
}
}
+ this.empty = toCopy.isEmpty();
}
public ArrayBindingSet(ArrayBindingSet toCopy, String... names) {
this.bindingNames = names;
+
this.values = Arrays.copyOf(toCopy.values, toCopy.values.length);
this.whichBindingsHaveBeenSet = Arrays.copyOf(toCopy.whichBindingsHaveBeenSet,
toCopy.whichBindingsHaveBeenSet.length);
+ this.empty = toCopy.empty;
}
/**
@@ -105,6 +110,7 @@ public BiConsumer getDirectSetBinding(String bindingName
return (v, a) -> {
a.values[index] = v;
a.whichBindingsHaveBeenSet[index] = true;
+ a.empty = false;
a.clearCache();
};
}
@@ -120,6 +126,7 @@ public BiConsumer getDirectAddBinding(String bindingName
assert !a.whichBindingsHaveBeenSet[index] : "variable already bound: " + bindingName;
a.values[index] = v;
a.whichBindingsHaveBeenSet[index] = true;
+ a.empty = false;
a.clearCache();
};
@@ -244,6 +251,9 @@ public Iterator iterator() {
@Override
public int size() {
+ if (empty) {
+ return 0;
+ }
int size = 0;
for (boolean value : whichBindingsHaveBeenSet) {
@@ -364,20 +374,25 @@ public void setBinding(String name, Value value) {
this.values[index] = value;
this.whichBindingsHaveBeenSet[index] = value != null;
+ if (value == null) {
+ this.empty = true;
+ for (boolean b : whichBindingsHaveBeenSet) {
+ if (b) {
+ this.empty = false;
+ break;
+ }
+ }
+ }
clearCache();
}
@Override
public boolean isEmpty() {
- for (int index = 0; index < values.length; index++) {
- if (whichBindingsHaveBeenSet[index]) {
- return false;
- }
- }
- return true;
+ return empty;
}
private void clearCache() {
bindingNamesSetCache = null;
}
+
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/QueryEvaluationStep.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/QueryEvaluationStep.java
index 59c3662b90f..2fef22f46ab 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/QueryEvaluationStep.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/QueryEvaluationStep.java
@@ -25,13 +25,15 @@
*/
@FunctionalInterface
public interface QueryEvaluationStep {
+
+ EmptyIteration EMPTY_ITERATION = new EmptyIteration<>();
+ QueryEvaluationStep EMPTY = bindings -> EMPTY_ITERATION;
+
/**
* Utility class that removes code duplication and makes a precompiled QueryEvaluationStep available as an iteration
* that may be created and used later.
*/
- @Deprecated(since = "4.1.0", forRemoval = true)
- class DelayedEvaluationIteration
- extends DelayedIteration {
+ class DelayedEvaluationIteration extends DelayedIteration {
private final QueryEvaluationStep arg;
private final BindingSet bs;
@@ -47,9 +49,6 @@ protected CloseableIteration extends BindingSet> createIteration()
}
}
- EmptyIteration EMPTY_ITERATION = new EmptyIteration<>();
- QueryEvaluationStep EMPTY = bindings -> EMPTY_ITERATION;
-
CloseableIteration evaluate(BindingSet bindings);
/**
@@ -64,7 +63,7 @@ static QueryEvaluationStep minimal(EvaluationStrategy strategy, TupleExpr expr)
}
static QueryEvaluationStep empty() {
- return bs -> new EmptyIteration<>();
+ return EMPTY;
}
/**
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/DefaultEvaluationStrategy.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/DefaultEvaluationStrategy.java
index ee50f83d191..dffc3cc2a26 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/DefaultEvaluationStrategy.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/DefaultEvaluationStrategy.java
@@ -23,7 +23,6 @@
import org.eclipse.rdf4j.collection.factory.impl.DefaultCollectionFactory;
import org.eclipse.rdf4j.common.iteration.CloseableIteration;
import org.eclipse.rdf4j.common.iteration.DistinctIteration;
-import org.eclipse.rdf4j.common.iteration.EmptyIteration;
import org.eclipse.rdf4j.common.iteration.IterationWrapper;
import org.eclipse.rdf4j.common.iteration.LookAheadIteration;
import org.eclipse.rdf4j.common.iteration.ReducedIteration;
@@ -250,11 +249,7 @@ public BindingSet getNextElement() throws QueryEvaluationException {
@Override
protected void handleClose() throws QueryEvaluationException {
- try {
- super.handleClose();
- } finally {
- iter.close();
- }
+ iter.close();
}
};
}
@@ -396,7 +391,7 @@ public CloseableIteration evaluate(TupleExpr expr, BindingSet bindin
} else if (expr instanceof SingletonSet) {
result = precompile(expr).evaluate(bindings);
} else if (expr instanceof EmptySet) {
- result = new EmptyIteration<>();
+ result = QueryEvaluationStep.EMPTY_ITERATION;
} else if (expr instanceof ZeroLengthPath) {
result = precompile(expr).evaluate(bindings);
} else if (expr instanceof ArbitraryLengthPath) {
@@ -628,13 +623,13 @@ protected QueryEvaluationStep prepare(Filter node, QueryEvaluationContext contex
// If we have a failed compilation we always return false.
// Which means empty. so let's short circuit that.
// ves = new QueryValueEvaluationStep.ConstantQueryValueEvaluationStep(BooleanLiteral.FALSE);
- return bs -> new EmptyIteration<>();
+ return bs -> QueryEvaluationStep.EMPTY_ITERATION;
}
return bs -> {
CloseableIteration evaluate = null;
try {
evaluate = arg.evaluate(bs);
- return new FilterIterator(node, evaluate, ves, DefaultEvaluationStrategy.this);
+ return new FilterIterator(evaluate, ves, DefaultEvaluationStrategy.this);
} catch (Throwable t) {
if (evaluate != null) {
evaluate.close();
@@ -843,7 +838,7 @@ protected QueryEvaluationStep prepare(SingletonSet singletonSet, QueryEvaluation
protected QueryEvaluationStep prepare(EmptySet emptySet, QueryEvaluationContext context)
throws QueryEvaluationException {
- return bindings -> new EmptyIteration<>();
+ return bindings -> QueryEvaluationStep.EMPTY_ITERATION;
}
@Override
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/BindingSetAssignmentQueryEvaluationStep.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/BindingSetAssignmentQueryEvaluationStep.java
index 10eb79540fc..096339d3d3b 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/BindingSetAssignmentQueryEvaluationStep.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/BindingSetAssignmentQueryEvaluationStep.java
@@ -44,7 +44,7 @@ public CloseableIteration evaluate(BindingSet bindings) {
// we need to verify that new binding assignments do not overwrite existing bindings
CloseableIteration result;
- result = new LookAheadIteration() {
+ result = new LookAheadIteration<>() {
@Override
protected BindingSet getNextElement() throws QueryEvaluationException {
@@ -77,6 +77,11 @@ protected BindingSet getNextElement() throws QueryEvaluationException {
}
return nextResult;
}
+
+ @Override
+ protected void handleClose() {
+
+ }
};
return result;
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/JoinQueryEvaluationStep.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/JoinQueryEvaluationStep.java
index 66c726afa29..5343911f905 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/JoinQueryEvaluationStep.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/JoinQueryEvaluationStep.java
@@ -43,7 +43,7 @@ public JoinQueryEvaluationStep(EvaluationStrategy strategy, Join join, QueryEval
joinAttributes, context);
join.setAlgorithm(HashJoinIteration.class.getSimpleName());
} else {
- eval = bindings -> new JoinIterator(leftPrepared, rightPrepared, bindings);
+ eval = bindings -> JoinIterator.getInstance(leftPrepared, rightPrepared, bindings);
join.setAlgorithm(JoinIterator.class.getSimpleName());
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/LeftJoinQueryEvaluationStep.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/LeftJoinQueryEvaluationStep.java
index 669b00d814a..7d86ec5cd9e 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/LeftJoinQueryEvaluationStep.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/LeftJoinQueryEvaluationStep.java
@@ -103,7 +103,7 @@ public CloseableIteration evaluate(BindingSet bindings) {
if (containsNone) {
// left join is "well designed"
leftJoin.setAlgorithm(LeftJoinIterator.class.getSimpleName());
- return new LeftJoinIterator(left, right, condition, bindings, leftJoin.getBindingNames());
+ return LeftJoinIterator.getInstance(left, right, condition, bindings, leftJoin.getBindingNames());
} else {
Set problemVars = new HashSet<>(optionalVars);
problemVars.retainAll(bindings.getBindingNames());
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/RdfStarQueryEvaluationStep.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/RdfStarQueryEvaluationStep.java
index 57608c574b5..5def1a2c362 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/RdfStarQueryEvaluationStep.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/RdfStarQueryEvaluationStep.java
@@ -90,6 +90,11 @@ protected boolean accept(Triple triple) throws QueryEvaluationException {
}
return true;
}
+
+ @Override
+ protected void handleClose() {
+
+ }
};
return new ConvertingIteration<>(filterIter) {
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/ReificationRdfStarQueryEvaluationStep.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/ReificationRdfStarQueryEvaluationStep.java
index 4ec734e749d..2dcd652307a 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/ReificationRdfStarQueryEvaluationStep.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/ReificationRdfStarQueryEvaluationStep.java
@@ -66,9 +66,7 @@ protected Resource convert(Statement sourceObject)
// the expected values from TripleRef pattern and supplied bindings collection
return new LookAheadIteration<>() {
@Override
- protected void handleClose()
- throws QueryEvaluationException {
- super.handleClose();
+ protected void handleClose() throws QueryEvaluationException {
iter.close();
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/StatementPatternQueryEvaluationStep.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/StatementPatternQueryEvaluationStep.java
index 53c712b76db..01f96d6138c 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/StatementPatternQueryEvaluationStep.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/StatementPatternQueryEvaluationStep.java
@@ -41,6 +41,8 @@
*/
public class StatementPatternQueryEvaluationStep implements QueryEvaluationStep {
+ public static final EmptyIteration extends Statement> EMPTY_ITERATION = new EmptyIteration<>();
+
public static final Resource[] DEFAULT_CONTEXT = { null };
public static final Resource[] ALL_CONTEXT = new Resource[0];
private static final Function RETURN_NULL_VALUE_RESOURCE_ARRAY = v -> null;
@@ -206,22 +208,22 @@ private static Function makeGetVarValue(Var var, QueryEvaluat
@Override
public CloseableIteration evaluate(BindingSet bindings) {
if (emptyGraph) {
- return EMPTY_ITERATION;
+ return QueryEvaluationStep.EMPTY_ITERATION;
} else if (bindings.isEmpty()) {
ConvertStatementToBindingSetIterator iteration = getIteration();
if (iteration == null) {
- return EMPTY_ITERATION;
+ return QueryEvaluationStep.EMPTY_ITERATION;
}
return iteration;
} else if (unboundTest.test(bindings)) {
// the variable must remain unbound for this solution see
// https://www.w3.org/TR/sparql11-query/#assignment
- return EMPTY_ITERATION;
+ return QueryEvaluationStep.EMPTY_ITERATION;
} else {
JoinStatementWithBindingSetIterator iteration = getIteration(bindings);
if (iteration == null) {
- return EMPTY_ITERATION;
+ return QueryEvaluationStep.EMPTY_ITERATION;
}
return iteration;
}
@@ -281,13 +283,19 @@ private ConvertStatementToBindingSetIterator getIteration() {
}
Value subject = statementPattern.getSubjectVar().getValue();
+
+ if (subject != null && !subject.isResource()) {
+ return null;
+ }
+
Value predicate = statementPattern.getPredicateVar().getValue();
- Value object = statementPattern.getObjectVar().getValue();
- if (subject != null && !subject.isResource() || predicate != null && !predicate.isIRI()) {
+ if (predicate != null && !predicate.isIRI()) {
return null;
}
+ Value object = statementPattern.getObjectVar().getValue();
+
CloseableIteration extends Statement> iteration = null;
try {
iteration = tripleSource.getStatements((Resource) subject, (IRI) predicate, object, contexts);
@@ -324,6 +332,11 @@ private CloseableIteration extends Statement> handleFilter(Resource[] contexts
protected boolean accept(Statement object) throws QueryEvaluationException {
return filter.test(object);
}
+
+ @Override
+ protected void handleClose() {
+
+ }
};
} else {
return iteration;
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/UnionQueryEvaluationStep.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/UnionQueryEvaluationStep.java
index 63dbd1a1e28..29690ddccf3 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/UnionQueryEvaluationStep.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/UnionQueryEvaluationStep.java
@@ -35,9 +35,9 @@ public CloseableIteration evaluate(BindingSet bindings) {
evaluate = leftQes.evaluate(bindings);
evaluate1 = rightQes.evaluate(bindings);
- if (evaluate instanceof EmptyIteration) {
+ if (evaluate == QueryEvaluationStep.EMPTY_ITERATION) {
return evaluate1;
- } else if (evaluate1 instanceof EmptyIteration) {
+ } else if (evaluate1 == QueryEvaluationStep.EMPTY_ITERATION) {
return evaluate;
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/CrossProductIteration.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/CrossProductIteration.java
index 566d3320f14..fc5dbe9155e 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/CrossProductIteration.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/CrossProductIteration.java
@@ -71,10 +71,6 @@ protected BindingSet getNextElement() throws QueryEvaluationException {
@Override
protected void handleClose() throws QueryEvaluationException {
- try {
- super.handleClose();
- } finally {
- resultIteration.close();
- }
+ resultIteration.close();
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/DescribeIteration.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/DescribeIteration.java
index 929cb0a5d26..7d29768cf29 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/DescribeIteration.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/DescribeIteration.java
@@ -27,6 +27,8 @@
import org.eclipse.rdf4j.query.algebra.StatementPattern;
import org.eclipse.rdf4j.query.algebra.Var;
import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategy;
+import org.eclipse.rdf4j.query.algebra.evaluation.QueryEvaluationStep;
+import org.eclipse.rdf4j.query.algebra.evaluation.QueryValueEvaluationStep;
/**
* Iteration that implements a simplified version of Symmetric Concise Bounded Description (omitting reified
@@ -35,7 +37,6 @@
* @author Jeen Broekstra
* @see Concise Bounded Description - alternatives
*/
-@Deprecated(since = "4.1.0")
public class DescribeIteration extends LookAheadIteration {
protected final static String VARNAME_SUBJECT = "subject";
@@ -208,7 +209,7 @@ protected BindingSet getNextElement() throws QueryEvaluationException {
protected CloseableIteration createNextIteration(Value subject, Value object)
throws QueryEvaluationException {
if (subject == null && object == null) {
- return new EmptyIteration<>();
+ return QueryEvaluationStep.EMPTY_ITERATION;
}
Var subjVar = new Var(VARNAME_SUBJECT, subject);
@@ -222,17 +223,11 @@ protected CloseableIteration createNextIteration(Value subject, Valu
@Override
protected void handleClose() throws QueryEvaluationException {
try {
- super.handleClose();
-
- } finally {
- try {
- if (currentDescribeExprIter != null) {
- currentDescribeExprIter.close();
- }
- } finally {
- sourceIter.close();
+ if (currentDescribeExprIter != null) {
+ currentDescribeExprIter.close();
}
-
+ } finally {
+ sourceIter.close();
}
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ExtensionIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ExtensionIterator.java
index fed881bf324..8c6fbbd65ff 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ExtensionIterator.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ExtensionIterator.java
@@ -28,7 +28,6 @@
import org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException;
import org.eclipse.rdf4j.query.algebra.evaluation.impl.QueryEvaluationContext;
-@Deprecated(since = "4.1.0")
public class ExtensionIterator extends ConvertingIteration {
private final Consumer setter;
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/FilterIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/FilterIterator.java
index 2c3d6beb308..38537524fdc 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/FilterIterator.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/FilterIterator.java
@@ -23,14 +23,11 @@
import org.eclipse.rdf4j.query.MutableBindingSet;
import org.eclipse.rdf4j.query.QueryEvaluationException;
import org.eclipse.rdf4j.query.algebra.Filter;
-import org.eclipse.rdf4j.query.algebra.QueryModelNode;
-import org.eclipse.rdf4j.query.algebra.SubQueryValueOperator;
import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategy;
import org.eclipse.rdf4j.query.algebra.evaluation.QueryValueEvaluationStep;
import org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException;
import org.eclipse.rdf4j.query.algebra.evaluation.impl.QueryEvaluationContext;
-@Deprecated(since = "4.1.0")
public class FilterIterator extends FilterIteration {
private final QueryValueEvaluationStep condition;
@@ -40,8 +37,8 @@ public class FilterIterator extends FilterIteration {
* Constructors *
*--------------*/
- public FilterIterator(Filter filter, CloseableIteration iter,
- QueryValueEvaluationStep condition, EvaluationStrategy strategy) throws QueryEvaluationException {
+ public FilterIterator(CloseableIteration iter, QueryValueEvaluationStep condition,
+ EvaluationStrategy strategy) throws QueryEvaluationException {
super(iter);
this.condition = condition;
this.strategy = strategy;
@@ -58,6 +55,11 @@ protected boolean accept(BindingSet bindings) throws QueryEvaluationException {
}
}
+ @Override
+ protected void handleClose() {
+
+ }
+
/**
* This is used to make sure that no variable is seen by the filter that are not in scope. Historically important in
* subquery cases.
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java
index d0bb8764341..a860d9430f9 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java
@@ -14,7 +14,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
@@ -30,7 +29,7 @@
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.iteration.CloseableIteratorIteration;
+import org.eclipse.rdf4j.common.iteration.AbstractCloseableIteratorIteration;
import org.eclipse.rdf4j.common.transaction.QueryEvaluationMode;
import org.eclipse.rdf4j.model.Literal;
import org.eclipse.rdf4j.model.Value;
@@ -74,7 +73,7 @@
* @author Jerven Bolleman
* @author Tomas Kovachev
*/
-public class GroupIterator extends CloseableIteratorIteration {
+public class GroupIterator extends AbstractCloseableIteratorIteration {
/*-----------*
* Constants *
@@ -130,30 +129,11 @@ public GroupIterator(EvaluationStrategy strategy, Group group, BindingSet parent
@Override
public void handleClose() throws QueryEvaluationException {
- try {
- cf.close();
- } finally {
- super.handleClose();
- }
- }
-
- @Override
- public boolean hasNext() throws QueryEvaluationException {
- if (!super.hasIterator()) {
- super.setIterator(createIterator());
- }
- return super.hasNext();
+ cf.close();
}
@Override
- public BindingSet next() throws QueryEvaluationException {
- if (!super.hasIterator()) {
- super.setIterator(createIterator());
- }
- return super.next();
- }
-
- private Iterator createIterator() throws QueryEvaluationException {
+ protected Iterator getIterator() throws QueryEvaluationException {
List> aggregates = makeAggregates();
Supplier makeNewBindingSet;
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/HashJoinIteration.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/HashJoinIteration.java
index 09b302ebdfa..6d67e3e3fda 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/HashJoinIteration.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/HashJoinIteration.java
@@ -178,37 +178,33 @@ protected BindingSet getNextElement() throws QueryEvaluationException {
@Override
protected void handleClose() throws QueryEvaluationException {
try {
- super.handleClose();
+ if (leftIter != null) {
+ leftIter.close();
+ }
} finally {
try {
- if (leftIter != null) {
- leftIter.close();
+ if (rightIter != null) {
+ rightIter.close();
}
} finally {
try {
- if (rightIter != null) {
- rightIter.close();
+ Iterator toCloseHashTableValues = hashTableValues;
+ hashTableValues = null;
+ if (toCloseHashTableValues != null) {
+ closeHashValue(toCloseHashTableValues);
}
} finally {
try {
- Iterator toCloseHashTableValues = hashTableValues;
- hashTableValues = null;
- if (toCloseHashTableValues != null) {
- closeHashValue(toCloseHashTableValues);
+ Iterator toCloseScanList = scanList;
+ scanList = null;
+ if (toCloseScanList != null) {
+ disposeCache(toCloseScanList);
}
} finally {
- try {
- Iterator toCloseScanList = scanList;
- scanList = null;
- if (toCloseScanList != null) {
- disposeCache(toCloseScanList);
- }
- } finally {
- Map> toCloseHashTable = hashTable;
- hashTable = null;
- if (toCloseHashTable != null) {
- disposeHashTable(toCloseHashTable);
- }
+ Map> toCloseHashTable = hashTable;
+ hashTable = null;
+ if (toCloseHashTable != null) {
+ disposeHashTable(toCloseHashTable);
}
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/JoinIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/JoinIterator.java
index 0501ceb997c..c81bbed2174 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/JoinIterator.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/JoinIterator.java
@@ -10,10 +10,7 @@
*******************************************************************************/
package org.eclipse.rdf4j.query.algebra.evaluation.iterator;
-import java.util.NoSuchElementException;
-
import org.eclipse.rdf4j.common.iteration.CloseableIteration;
-import org.eclipse.rdf4j.common.iteration.EmptyIteration;
import org.eclipse.rdf4j.common.iteration.LookAheadIteration;
import org.eclipse.rdf4j.query.BindingSet;
import org.eclipse.rdf4j.query.QueryEvaluationException;
@@ -30,38 +27,33 @@
*/
public class JoinIterator extends LookAheadIteration {
- /*-----------*
- * Variables *
- *-----------*/
-
private final CloseableIteration leftIter;
private CloseableIteration rightIter;
private final QueryEvaluationStep preparedRight;
- /*--------------*
- * Constructors *
- *--------------*/
-
public JoinIterator(QueryEvaluationStep leftPrepared,
- QueryEvaluationStep rightPrepared, BindingSet bindings) throws QueryEvaluationException {
+ QueryEvaluationStep preparedRight, BindingSet bindings) throws QueryEvaluationException {
leftIter = leftPrepared.evaluate(bindings);
+ this.preparedRight = preparedRight;
+ }
- // Initialize with empty iteration so that var is never null
- rightIter = new EmptyIteration<>();
- this.preparedRight = rightPrepared;
+ private JoinIterator(CloseableIteration leftIter, QueryEvaluationStep preparedRight)
+ throws QueryEvaluationException {
+ this.leftIter = leftIter;
+ this.preparedRight = preparedRight;
}
-// public JoinIterator(EvaluationStrategy strategy, Join join, BindingSet bindings, QueryEvaluationContext context)
-// throws QueryEvaluationException {
-// leftIter = strategy.evaluate(join.getLeftArg(), bindings);
-//
-// // Initialize with empty iteration so that var is never null
-// rightIter = new EmptyIteration<>();
-// preparedRight = strategy.precompile(join.getRightArg(), context);
-// join.setAlgorithm(this);
-// }
+ public static CloseableIteration getInstance(QueryEvaluationStep leftPrepared,
+ QueryEvaluationStep preparedRight, BindingSet bindings) {
+ CloseableIteration leftIter = leftPrepared.evaluate(bindings);
+ if (leftIter == QueryEvaluationStep.EMPTY_ITERATION) {
+ return leftIter;
+ }
+
+ return new JoinIterator(leftIter, preparedRight);
+ }
/*---------*
* Methods *
@@ -69,23 +61,21 @@ public JoinIterator(QueryEvaluationStep leftPrepared,
@Override
protected BindingSet getNextElement() throws QueryEvaluationException {
-
- try {
- while (rightIter.hasNext() || leftIter.hasNext()) {
- if (rightIter.hasNext()) {
- return rightIter.next();
- }
-
- // Right iteration exhausted
+ if (rightIter != null) {
+ if (rightIter.hasNext()) {
+ return rightIter.next();
+ } else {
rightIter.close();
+ }
+ }
- if (leftIter.hasNext()) {
- rightIter = preparedRight.evaluate(leftIter.next());
- }
+ while (leftIter.hasNext()) {
+ rightIter = preparedRight.evaluate(leftIter.next());
+ if (rightIter.hasNext()) {
+ return rightIter.next();
+ } else {
+ rightIter.close();
}
- } catch (NoSuchElementException ignore) {
- // probably, one of the iterations has been closed concurrently in
- // handleClose()
}
return null;
@@ -94,11 +84,9 @@ protected BindingSet getNextElement() throws QueryEvaluationException {
@Override
protected void handleClose() throws QueryEvaluationException {
try {
- super.handleClose();
+ leftIter.close();
} finally {
- try {
- leftIter.close();
- } finally {
+ if (rightIter != null) {
rightIter.close();
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/LeftJoinIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/LeftJoinIterator.java
index 15c853319fd..45022b5f59b 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/LeftJoinIterator.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/LeftJoinIterator.java
@@ -14,7 +14,6 @@
import java.util.Set;
import org.eclipse.rdf4j.common.iteration.CloseableIteration;
-import org.eclipse.rdf4j.common.iteration.EmptyIteration;
import org.eclipse.rdf4j.common.iteration.LookAheadIteration;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.query.Binding;
@@ -31,7 +30,6 @@
import org.eclipse.rdf4j.query.algebra.evaluation.util.QueryEvaluationUtility;
public class LeftJoinIterator extends LookAheadIteration {
-
/*-----------*
* Variables *
*-----------*/
@@ -61,8 +59,7 @@ public LeftJoinIterator(EvaluationStrategy strategy, LeftJoin join, BindingSet b
leftIter = strategy.evaluate(join.getLeftArg(), bindings);
- // Initialize with empty iteration so that var is never null
- rightIter = new EmptyIteration<>();
+ rightIter = null;
prepareRightArg = strategy.precompile(join.getRightArg(), context);
join.setAlgorithm(this);
@@ -82,25 +79,58 @@ public LeftJoinIterator(QueryEvaluationStep left, QueryEvaluationStep right, Que
leftIter = left.evaluate(bindings);
// Initialize with empty iteration so that var is never null
- rightIter = new EmptyIteration<>();
+ rightIter = null;
prepareRightArg = right;
this.joinCondition = joinCondition;
}
+ public LeftJoinIterator(CloseableIteration leftIter, QueryEvaluationStep prepareRightArg,
+ QueryValueEvaluationStep joinCondition, Set scopeBindingNamse) {
+ this.scopeBindingNames = scopeBindingNamse;
+ this.leftIter = leftIter;
+ this.rightIter = null;
+ this.prepareRightArg = prepareRightArg;
+ this.joinCondition = joinCondition;
+ }
+
+ public static CloseableIteration getInstance(QueryEvaluationStep left,
+ QueryEvaluationStep prepareRightArg, QueryValueEvaluationStep joinCondition, BindingSet bindings,
+ Set scopeBindingNamse) {
+
+ CloseableIteration leftIter = left.evaluate(bindings);
+
+ if (leftIter == QueryEvaluationStep.EMPTY_ITERATION) {
+ return leftIter;
+ } else {
+ return new LeftJoinIterator(leftIter, prepareRightArg, joinCondition, scopeBindingNamse);
+ }
+
+ }
+
/*---------*
* Methods *
*---------*/
@Override
protected BindingSet getNextElement() throws QueryEvaluationException {
+
try {
CloseableIteration nextRightIter = rightIter;
- while (nextRightIter.hasNext() || leftIter.hasNext()) {
+ while (nextRightIter == null || nextRightIter.hasNext() || leftIter.hasNext()) {
BindingSet leftBindings = null;
- if (!nextRightIter.hasNext()) {
+ if (nextRightIter == null) {
+ if (leftIter.hasNext()) {
+ // Use left arg's bindings in case join fails
+ leftBindings = leftIter.next();
+ nextRightIter = rightIter = prepareRightArg.evaluate(leftBindings);
+ } else {
+ return null;
+ }
+
+ } else if (!nextRightIter.hasNext()) {
// Use left arg's bindings in case join fails
leftBindings = leftIter.next();
@@ -108,6 +138,11 @@ protected BindingSet getNextElement() throws QueryEvaluationException {
nextRightIter = rightIter = prepareRightArg.evaluate(leftBindings);
}
+ if (nextRightIter == QueryEvaluationStep.EMPTY_ITERATION) {
+ rightIter = null;
+ return leftBindings;
+ }
+
while (nextRightIter.hasNext()) {
BindingSet rightBindings = nextRightIter.next();
@@ -136,9 +171,12 @@ protected BindingSet getNextElement() throws QueryEvaluationException {
}
if (leftBindings != null) {
+ rightIter = null;
// Join failed, return left arg's bindings
return leftBindings;
}
+
+ return null;
}
} catch (NoSuchElementException ignore) {
// probably, one of the iterations has been closed concurrently in
@@ -156,11 +194,9 @@ private boolean isTrue(QueryValueEvaluationStep expr, QueryBindingSet bindings)
@Override
protected void handleClose() throws QueryEvaluationException {
try {
- super.handleClose();
+ leftIter.close();
} finally {
- try {
- leftIter.close();
- } finally {
+ if (rightIter != null) {
rightIter.close();
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/MultiProjectionIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/MultiProjectionIterator.java
index d292617c287..69d527ebe35 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/MultiProjectionIterator.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/MultiProjectionIterator.java
@@ -97,14 +97,10 @@ protected BindingSet getNextElement() throws QueryEvaluationException {
@Override
protected void handleClose() throws QueryEvaluationException {
try {
- super.handleClose();
+ iter.close();
} finally {
- try {
- iter.close();
- } finally {
- nextProjectionIdx = -1;
- Arrays.fill(previousBindings, null);
- }
+ nextProjectionIdx = -1;
+ Arrays.fill(previousBindings, null);
}
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/OrderIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/OrderIterator.java
index dd5cd489328..7b3dd00b74f 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/OrderIterator.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/OrderIterator.java
@@ -43,9 +43,154 @@
* @author James Leigh
* @author Arjohn Kampman
*/
-@Deprecated(since = "4.1.0")
public class OrderIterator extends DelayedIteration {
+ /*-----------*
+ * Variables *
+ *-----------*/
+
+ private final CloseableIteration iter;
+
+ private final Comparator comparator;
+
+ private final long limit;
+
+ private final boolean distinct;
+
+ private final List> serialized = new LinkedList<>();
+
+ /**
+ * Number of items cached before internal collection is synced to disk. If set to 0, no disk-syncing is done and all
+ * internal caching is kept in memory.
+ */
+ private final long iterationSyncThreshold;
+
+ /*--------------*
+ * Constructors *
+ *--------------*/
+
+ public OrderIterator(CloseableIteration iter, Comparator comparator) {
+ this(iter, comparator, Long.MAX_VALUE, false);
+ }
+
+ public OrderIterator(CloseableIteration iter, Comparator comparator, long limit,
+ boolean distinct) {
+ this(iter, comparator, limit, distinct, Integer.MAX_VALUE);
+ }
+
+ public OrderIterator(CloseableIteration iter, Comparator comparator, long limit,
+ boolean distinct, long iterationSyncThreshold) {
+ this.iter = iter;
+ this.comparator = comparator;
+ this.limit = limit;
+ this.distinct = distinct;
+ this.iterationSyncThreshold = iterationSyncThreshold > 0 ? iterationSyncThreshold : Integer.MAX_VALUE;
+ }
+
+ /*---------*
+ * Methods *
+ *---------*/
+
+ @Override
+ protected CloseableIteration createIteration() throws QueryEvaluationException {
+ BindingSet threshold = null;
+ List list = new LinkedList<>();
+ int limit2 = limit >= Integer.MAX_VALUE / 2 ? Integer.MAX_VALUE : (int) limit * 2;
+ int syncThreshold = (int) Math.min(iterationSyncThreshold, Integer.MAX_VALUE);
+ try {
+ while (iter.hasNext()) {
+ if (list.size() >= syncThreshold && list.size() < limit) {
+ SerializedQueue queue = new SerializedQueue<>("orderiter");
+ sort(list).forEach(queue::add);
+ serialized.add(queue);
+ decrement(list.size() - queue.size());
+ list = new ArrayList<>(list.size());
+ if (threshold == null && serialized.stream().mapToLong(SerializedQueue::size).sum() >= limit) {
+ Stream stream = serialized.stream().map(SerializedQueue::peekLast);
+ threshold = stream.sorted(comparator).skip(serialized.size() - 1).findFirst().orElseThrow();
+ }
+ } else if (list.size() >= limit2 || !distinct && threshold == null && list.size() >= limit) {
+ List sorted = new ArrayList<>(limit2);
+ sort(list).forEach(sorted::add);
+ decrement(list.size() - sorted.size());
+ list = sorted;
+ if (sorted.size() >= limit) {
+ threshold = sorted.get(sorted.size() - 1);
+ }
+ }
+ BindingSet next = iter.next();
+ if (threshold == null || comparator.compare(next, threshold) < 0) {
+ list.add(next);
+ increment();
+ }
+ }
+ } catch (IOException e) {
+ throw new QueryEvaluationException(e);
+ } finally {
+ iter.close();
+ }
+
+ List> iterators = new ArrayList<>(serialized.size() + 1);
+ serialized
+ .stream()
+ .map(SerializedQueue::iterator)
+ .forEach(iterators::add);
+
+ iterators.add(sort(list).iterator());
+
+ SortedIterators iterator = new SortedIterators<>(comparator, distinct, iterators);
+
+ return new LimitIteration<>(new CloseableIteratorIteration<>(iterator), limit);
+ }
+
+ protected void increment() throws QueryEvaluationException {
+ // give subclasses a chance to stop query evaluation
+ }
+
+ protected void decrement(int amount) throws QueryEvaluationException {
+ // let subclasses know that the expected result size is smaller
+ }
+
+ private Stream sort(Collection collection) {
+ BindingSet[] array = collection.toArray(new BindingSet[collection.size()]);
+ Arrays.parallelSort(array, comparator);
+ Stream stream = Stream.of(array);
+ if (distinct) {
+ stream = stream.distinct();
+ }
+ if (limit < Integer.MAX_VALUE) {
+ stream = stream.limit(limit);
+ }
+ return stream;
+ }
+
+ @Override
+ public void remove() throws QueryEvaluationException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void handleClose() throws QueryEvaluationException {
+ try {
+ super.handleClose();
+ } finally {
+ try {
+ iter.close();
+ } finally {
+ serialized.stream().map(queue -> {
+ try {
+ queue.close();
+ return null;
+ } catch (IOException e) {
+ return e;
+ }
+ }).filter(exec -> exec != null).findFirst().ifPresent(exec -> {
+ throw new QueryEvaluationException(exec);
+ });
+ }
+ }
+ }
+
private static class SerializedQueue extends AbstractQueue implements Closeable {
private final File file;
@@ -223,150 +368,4 @@ private void advance(int i) {
}
- /*-----------*
- * Variables *
- *-----------*/
-
- private final CloseableIteration iter;
-
- private final Comparator comparator;
-
- private final long limit;
-
- private final boolean distinct;
-
- private final List> serialized = new LinkedList<>();
-
- /**
- * Number of items cached before internal collection is synced to disk. If set to 0, no disk-syncing is done and all
- * internal caching is kept in memory.
- */
- private final long iterationSyncThreshold;
-
- /*--------------*
- * Constructors *
- *--------------*/
-
- public OrderIterator(CloseableIteration iter,
- Comparator comparator) {
- this(iter, comparator, Long.MAX_VALUE, false);
- }
-
- public OrderIterator(CloseableIteration iter,
- Comparator comparator, long limit, boolean distinct) {
- this(iter, comparator, limit, distinct, Integer.MAX_VALUE);
- }
-
- public OrderIterator(CloseableIteration iter,
- Comparator comparator, long limit, boolean distinct, long iterationSyncThreshold) {
- this.iter = iter;
- this.comparator = comparator;
- this.limit = limit;
- this.distinct = distinct;
- this.iterationSyncThreshold = iterationSyncThreshold > 0 ? iterationSyncThreshold : Integer.MAX_VALUE;
- }
-
- /*---------*
- * Methods *
- *---------*/
-
- @Override
- protected CloseableIteration createIteration() throws QueryEvaluationException {
- BindingSet threshold = null;
- List list = new LinkedList<>();
- int limit2 = limit >= Integer.MAX_VALUE / 2 ? Integer.MAX_VALUE : (int) limit * 2;
- int syncThreshold = (int) Math.min(iterationSyncThreshold, Integer.MAX_VALUE);
- try {
- while (iter.hasNext()) {
- if (list.size() >= syncThreshold && list.size() < limit) {
- SerializedQueue queue = new SerializedQueue<>("orderiter");
- sort(list).forEach(queue::add);
- serialized.add(queue);
- decrement(list.size() - queue.size());
- list = new ArrayList<>(list.size());
- if (threshold == null && serialized.stream().mapToLong(SerializedQueue::size).sum() >= limit) {
- Stream stream = serialized.stream().map(SerializedQueue::peekLast);
- threshold = stream.sorted(comparator).skip(serialized.size() - 1).findFirst().orElseThrow();
- }
- } else if (list.size() >= limit2 || !distinct && threshold == null && list.size() >= limit) {
- List sorted = new ArrayList<>(limit2);
- sort(list).forEach(sorted::add);
- decrement(list.size() - sorted.size());
- list = sorted;
- if (sorted.size() >= limit) {
- threshold = sorted.get(sorted.size() - 1);
- }
- }
- BindingSet next = iter.next();
- if (threshold == null || comparator.compare(next, threshold) < 0) {
- list.add(next);
- increment();
- }
- }
- } catch (IOException e) {
- throw new QueryEvaluationException(e);
- } finally {
- iter.close();
- }
-
- List> iterators = new ArrayList<>(serialized.size() + 1);
- serialized
- .stream()
- .map(SerializedQueue::iterator)
- .forEach(iterators::add);
-
- iterators.add(sort(list).iterator());
-
- SortedIterators iterator = new SortedIterators<>(comparator, distinct, iterators);
-
- return new LimitIteration<>(new CloseableIteratorIteration<>(iterator), limit);
- }
-
- protected void increment() throws QueryEvaluationException {
- // give subclasses a chance to stop query evaluation
- }
-
- protected void decrement(int amount) throws QueryEvaluationException {
- // let subclasses know that the expected result size is smaller
- }
-
- private Stream sort(Collection collection) {
- BindingSet[] array = collection.toArray(new BindingSet[collection.size()]);
- Arrays.parallelSort(array, comparator);
- Stream stream = Stream.of(array);
- if (distinct) {
- stream = stream.distinct();
- }
- if (limit < Integer.MAX_VALUE) {
- stream = stream.limit(limit);
- }
- return stream;
- }
-
- @Override
- public void remove() throws QueryEvaluationException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void handleClose() throws QueryEvaluationException {
- try {
- super.handleClose();
- } finally {
- try {
- iter.close();
- } finally {
- serialized.stream().map(queue -> {
- try {
- queue.close();
- return null;
- } catch (IOException e) {
- return e;
- }
- }).filter(exec -> exec != null).findFirst().ifPresent(exec -> {
- throw new QueryEvaluationException(exec);
- });
- }
- }
- }
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/PathIteration.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/PathIteration.java
index 0caf5294097..b46946a76b8 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/PathIteration.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/PathIteration.java
@@ -215,12 +215,8 @@ private void addBinding(MutableBindingSet bs, String name, Value value) {
@Override
protected void handleClose() throws QueryEvaluationException {
- try {
- super.handleClose();
- } finally {
- if (currentIter != null) {
- currentIter.close();
- }
+ if (currentIter != null) {
+ currentIter.close();
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ProjectionIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ProjectionIterator.java
index efb3176f309..668ff104942 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ProjectionIterator.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ProjectionIterator.java
@@ -28,7 +28,6 @@
import org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet;
import org.eclipse.rdf4j.query.algebra.evaluation.impl.QueryEvaluationContext;
-@Deprecated(since = "4.1.0")
public class ProjectionIterator extends ConvertingIteration {
/*-----------*
@@ -43,6 +42,25 @@ public class ProjectionIterator extends ConvertingIteration valueWithSourceName;
+ BiConsumer setTarget;
+
+ public BindingSetMapper(Function valueWithSourceName,
+ BiConsumer setTarget) {
+ this.valueWithSourceName = valueWithSourceName;
+ this.setTarget = setTarget;
+ }
+
+ public Function getValueWithSourceName() {
+ return valueWithSourceName;
+ }
+
+ public BiConsumer getSetTarget() {
+ return setTarget;
+ }
+ }
+
public ProjectionIterator(Projection projection, CloseableIteration iter,
BindingSet parentBindings, QueryEvaluationContext context) throws QueryEvaluationException {
super(iter);
@@ -50,22 +68,39 @@ public ProjectionIterator(Projection projection, CloseableIteration
boolean isOuterProjection = determineOuterProjection(projection);
boolean includeAllParentBindings = !isOuterProjection;
- BiConsumer consumer = null;
- for (ProjectionElem pe : projectionElemList.getElements()) {
- String projectionName = pe.getProjectionAlias().orElse(pe.getName());
- Function valueWithSourceName = context.getValue(pe.getName());
- BiConsumer setTarget = context.setBinding(projectionName);
- BiConsumer next = (resultBindings, sourceBindings) -> {
- Value targetValue = valueWithSourceName.apply(sourceBindings);
- if (!includeAllParentBindings && targetValue == null) {
- targetValue = valueWithSourceName.apply(parentBindings);
+ BindingSetMapper[] array = projectionElemList.getElements()
+ .stream()
+ .map(pe -> {
+ String projectionName = pe.getProjectionAlias().orElse(pe.getName());
+ return new BindingSetMapper(context.getValue(pe.getName()), context.setBinding(projectionName));
+ })
+ .toArray(BindingSetMapper[]::new);
+
+ BiConsumer consumer;
+
+ if (includeAllParentBindings) {
+ consumer = (resultBindings, sourceBindings) -> {
+ for (BindingSetMapper bindingSetMapper : array) {
+ Value targetValue = bindingSetMapper.valueWithSourceName.apply(sourceBindings);
+ if (targetValue != null) {
+ bindingSetMapper.setTarget.accept(targetValue, resultBindings);
+ }
}
- if (targetValue != null) {
- setTarget.accept(targetValue, resultBindings);
+ };
+ } else {
+ consumer = (resultBindings, sourceBindings) -> {
+ for (BindingSetMapper bindingSetMapper : array) {
+ Value targetValue = bindingSetMapper.valueWithSourceName.apply(sourceBindings);
+ if (targetValue == null) {
+ targetValue = bindingSetMapper.valueWithSourceName.apply(parentBindings);
+ }
+ if (targetValue != null) {
+ bindingSetMapper.setTarget.accept(targetValue, resultBindings);
+ }
}
};
- consumer = andThen(consumer, next);
}
+
if (projectionElemList.getElements().isEmpty()) {
consumer = (resultBindings, sourceBindings) -> {
// If there are no projection elements we do nothing.
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/QueryContextIteration.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/QueryContextIteration.java
index 4983891a013..4df8990d136 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/QueryContextIteration.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/QueryContextIteration.java
@@ -74,15 +74,11 @@ public void remove() throws QueryEvaluationException {
@Override
public void handleClose() throws QueryEvaluationException {
+ queryContext.begin();
try {
- super.handleClose();
+ iter.close();
} finally {
- queryContext.begin();
- try {
- iter.close();
- } finally {
- queryContext.end();
- }
+ queryContext.end();
}
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/SPARQLMinusIteration.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/SPARQLMinusIteration.java
index ce3e4a0cf42..e0a8a429ec8 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/SPARQLMinusIteration.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/SPARQLMinusIteration.java
@@ -13,6 +13,7 @@
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
+import java.util.stream.Collectors;
import org.eclipse.rdf4j.common.iteration.CloseableIteration;
import org.eclipse.rdf4j.common.iteration.FilterIteration;
@@ -28,7 +29,6 @@
* @author Jeen
* @see SPARQL Algebra Documentation
*/
-@Deprecated(since = "4.1.0")
public class SPARQLMinusIteration extends FilterIteration {
/*-----------*
@@ -40,6 +40,8 @@ public class SPARQLMinusIteration extends FilterIteration {
private boolean initialized;
private Set excludeSet;
+ private Set excludeSetBindingNames;
+ private boolean excludeSetBindingNamesAreAllTheSame;
/*--------------*
* Constructors *
@@ -71,20 +73,50 @@ protected boolean accept(BindingSet bindingSet) {
if (!initialized) {
// Build set of elements-to-exclude from right argument
excludeSet = makeSet(getRightArg());
+ excludeSetBindingNames = excludeSet.stream()
+ .map(BindingSet::getBindingNames)
+ .flatMap(Set::stream)
+ .collect(Collectors.toSet());
+ excludeSetBindingNamesAreAllTheSame = excludeSet.stream().allMatch(b -> {
+ Set bindingNames = b.getBindingNames();
+ if (bindingNames.size() == excludeSetBindingNames.size()) {
+ return bindingNames.containsAll(excludeSetBindingNames);
+ }
+ return false;
+ });
+
initialized = true;
}
- for (BindingSet excluded : excludeSet) {
- Set bindingNames = bindingSet.getBindingNames();
- boolean hasSharedBindings = false;
+ Set bindingNames = bindingSet.getBindingNames();
+ boolean hasSharedBindings = false;
- for (String bindingName : excluded.getBindingNames()) {
+ if (excludeSetBindingNamesAreAllTheSame) {
+ for (String bindingName : excludeSetBindingNames) {
if (bindingNames.contains(bindingName)) {
hasSharedBindings = true;
break;
}
}
+ if (!hasSharedBindings) {
+ return true;
+ }
+ }
+
+ for (BindingSet excluded : excludeSet) {
+
+ if (!excludeSetBindingNamesAreAllTheSame) {
+ hasSharedBindings = false;
+ for (String bindingName : excluded.getBindingNames()) {
+ if (bindingNames.contains(bindingName)) {
+ hasSharedBindings = true;
+ break;
+ }
+ }
+
+ }
+
// two bindingsets that share no variables are compatible by
// definition, however, the formal
// definition of SPARQL MINUS indicates that such disjoint sets should
@@ -117,12 +149,8 @@ protected Set makeSet(CloseableIteration rightArg) {
@Override
protected void handleClose() {
- try {
- super.handleClose();
- } finally {
- if (rightArg != null) {
- rightArg.close();
- }
+ if (rightArg != null) {
+ rightArg.close();
}
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ZeroLengthPathIteration.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ZeroLengthPathIteration.java
index 03dfecaedec..6e5d85b159c 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ZeroLengthPathIteration.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ZeroLengthPathIteration.java
@@ -172,4 +172,9 @@ private CloseableIteration createIteration() throws QueryEvaluationE
public Var createAnonVar(String varName) {
return new Var(varName, true);
}
+
+ @Override
+ protected void handleClose() {
+
+ }
}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/util/Statements.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/util/Statements.java
deleted file mode 100644
index 471d1a7571f..00000000000
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/util/Statements.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 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.query.algebra.evaluation.util;
-
-/**
- * @deprecated since 2.0. Use {@link TripleSources} instead.
- */
-@Deprecated(since = "2.0")
-public final class Statements extends TripleSources {
-
-}
diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/util/TripleSources.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/util/TripleSources.java
index e4b8177fbdb..0ea0502b062 100644
--- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/util/TripleSources.java
+++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/util/TripleSources.java
@@ -48,6 +48,11 @@ public static CloseableIteration listResources(final Resource subj,
protected boolean accept(Value v) throws QueryEvaluationException {
return v instanceof Resource;
}
+
+ @Override
+ protected void handleClose() {
+
+ }
}) {
@Override
@@ -157,6 +162,11 @@ public static CloseableIteration getSubjectURIs(IRI predicate,
protected boolean accept(Statement stmt) throws QueryEvaluationException {
return stmt.getSubject() instanceof IRI;
}
+
+ @Override
+ protected void handleClose() {
+
+ }
}) {
@Override
@@ -176,6 +186,11 @@ public static CloseableIteration getObjectResources(Resource subject,
protected boolean accept(Statement stmt) throws QueryEvaluationException {
return stmt.getObject() instanceof Resource;
}
+
+ @Override
+ protected void handleClose() {
+
+ }
}) {
@Override
@@ -195,6 +210,11 @@ public static CloseableIteration getObjectURIs(Resource subject,
protected boolean accept(Statement stmt) throws QueryEvaluationException {
return stmt.getObject() instanceof IRI;
}
+
+ @Override
+ protected void handleClose() {
+
+ }
}) {
@Override
@@ -214,6 +234,11 @@ public static CloseableIteration