Skip to content

Commit a6ec965

Browse files
authored
GH-4819 Merge Join (#4822)
2 parents c3df0af + 1e5c78c commit a6ec965

File tree

195 files changed

+4436
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+4436
-375
lines changed

compliance/sparql/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
<artifactId>jetty-webapp</artifactId>
5151
<scope>test</scope>
5252
</dependency>
53+
<dependency>
54+
<groupId>${project.groupId}</groupId>
55+
<artifactId>rdf4j-sail-extensible-store</artifactId>
56+
<version>${project.version}</version>
57+
<scope>test</scope>
58+
</dependency>
5359
</dependencies>
5460
<build>
5561
<plugins>

compliance/sparql/src/test/java/org/eclipse/rdf4j/query/parser/sparql/SPARQLServiceEvaluationTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public void testVariableNameHandling() throws Exception {
268268
assertTrue(tqr.hasNext());
269269

270270
List<BindingSet> result = QueryResults.asList(tqr);
271-
assertTrue(result.size() > 0);
271+
assertTrue(!result.isEmpty());
272272
for (BindingSet bs : result) {
273273
assertTrue(bs.hasBinding("val"));
274274
assertTrue(bs.hasBinding("s"));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2023 Eclipse RDF4J contributors.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Distribution License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/org/documents/edl-v10.php.
8+
*
9+
* SPDX-License-Identifier: BSD-3-Clause
10+
******************************************************************************/
11+
12+
package org.eclipse.rdf4j.sail.extensiblestore;
13+
14+
import org.eclipse.rdf4j.repository.Repository;
15+
import org.eclipse.rdf4j.repository.dataset.DatasetRepository;
16+
import org.eclipse.rdf4j.repository.sail.SailRepository;
17+
import org.eclipse.rdf4j.sail.extensiblestore.impl.ExtensibleStoreOrderedImplForTests;
18+
import org.eclipse.rdf4j.testsuite.query.parser.sparql.manifest.SPARQL11QueryComplianceTest;
19+
20+
public class ExtensibleStoreSPARQL11QueryComplianceTest extends SPARQL11QueryComplianceTest {
21+
22+
@Override
23+
protected Repository newRepository() {
24+
return new DatasetRepository(new SailRepository(new ExtensibleStoreOrderedImplForTests()));
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2023 Eclipse RDF4J contributors.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Distribution License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/org/documents/edl-v10.php.
8+
*
9+
* SPDX-License-Identifier: BSD-3-Clause
10+
******************************************************************************/
11+
12+
package org.eclipse.rdf4j.sail.extensiblestore;
13+
14+
import org.eclipse.rdf4j.repository.Repository;
15+
import org.eclipse.rdf4j.repository.sail.SailRepository;
16+
import org.eclipse.rdf4j.sail.extensiblestore.impl.ExtensibleStoreOrderedImplForTests;
17+
import org.eclipse.rdf4j.testsuite.query.parser.sparql.manifest.SPARQL11UpdateComplianceTest;
18+
19+
/**
20+
* Test SPARQL 1.1 Update functionality on an in-memory store.
21+
*/
22+
public class ExtensibleStoreSPARQL11UpdateComplianceTest extends SPARQL11UpdateComplianceTest {
23+
24+
@Override
25+
protected Repository newRepository() {
26+
return new SailRepository(new ExtensibleStoreOrderedImplForTests());
27+
}
28+
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2023 Eclipse RDF4J contributors.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Distribution License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/org/documents/edl-v10.php.
8+
*
9+
* SPDX-License-Identifier: BSD-3-Clause
10+
******************************************************************************/
11+
12+
package org.eclipse.rdf4j.sail.extensiblestore.impl;
13+
14+
import org.eclipse.rdf4j.sail.extensiblestore.ExtensibleStoreConnection;
15+
16+
class ExtensibleStoreConnectionOrderedImplForTests
17+
extends ExtensibleStoreConnection<ExtensibleStoreOrderedImplForTests> {
18+
protected ExtensibleStoreConnectionOrderedImplForTests(ExtensibleStoreOrderedImplForTests sail) {
19+
super(sail);
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2023 Eclipse RDF4J contributors.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Distribution License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/org/documents/edl-v10.php.
8+
*
9+
* SPDX-License-Identifier: BSD-3-Clause
10+
******************************************************************************/
11+
12+
package org.eclipse.rdf4j.sail.extensiblestore.impl;
13+
14+
import org.eclipse.rdf4j.common.annotation.InternalUseOnly;
15+
import org.eclipse.rdf4j.query.algebra.evaluation.impl.EvaluationStatistics;
16+
import org.eclipse.rdf4j.sail.NotifyingSailConnection;
17+
import org.eclipse.rdf4j.sail.SailException;
18+
import org.eclipse.rdf4j.sail.extensiblestore.ExtensibleStore;
19+
import org.eclipse.rdf4j.sail.extensiblestore.SimpleMemoryNamespaceStore;
20+
21+
@InternalUseOnly
22+
public class ExtensibleStoreOrderedImplForTests
23+
extends ExtensibleStore<OrderedDataStructure, SimpleMemoryNamespaceStore> {
24+
25+
public ExtensibleStoreOrderedImplForTests() {
26+
super(Cache.NONE);
27+
}
28+
29+
public ExtensibleStoreOrderedImplForTests(Cache cache) {
30+
super(cache);
31+
}
32+
33+
@Override
34+
protected synchronized void initializeInternal() throws SailException {
35+
namespaceStore = new SimpleMemoryNamespaceStore();
36+
dataStructure = new OrderedDataStructure();
37+
super.initializeInternal();
38+
}
39+
40+
@Override
41+
protected NotifyingSailConnection getConnectionInternal() throws SailException {
42+
return new ExtensibleStoreConnectionOrderedImplForTests(this);
43+
}
44+
45+
@Override
46+
public boolean isWritable() throws SailException {
47+
return true;
48+
}
49+
50+
public EvaluationStatistics getEvalStats() {
51+
return sailStore.getEvaluationStatistics();
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2023 Eclipse RDF4J contributors.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Distribution License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/org/documents/edl-v10.php.
8+
*
9+
* SPDX-License-Identifier: BSD-3-Clause
10+
******************************************************************************/
11+
12+
package org.eclipse.rdf4j.sail.extensiblestore.impl;
13+
14+
import java.util.Collections;
15+
import java.util.Comparator;
16+
import java.util.EnumSet;
17+
import java.util.Set;
18+
import java.util.concurrent.ConcurrentHashMap;
19+
20+
import org.eclipse.rdf4j.common.iteration.CloseableIteration;
21+
import org.eclipse.rdf4j.common.iteration.CloseableIteratorIteration;
22+
import org.eclipse.rdf4j.common.iteration.EmptyIteration;
23+
import org.eclipse.rdf4j.common.order.StatementOrder;
24+
import org.eclipse.rdf4j.model.IRI;
25+
import org.eclipse.rdf4j.model.Resource;
26+
import org.eclipse.rdf4j.model.Value;
27+
import org.eclipse.rdf4j.sail.extensiblestore.DataStructureInterface;
28+
import org.eclipse.rdf4j.sail.extensiblestore.FilteringIteration;
29+
import org.eclipse.rdf4j.sail.extensiblestore.SortedIteration;
30+
import org.eclipse.rdf4j.sail.extensiblestore.valuefactory.ExtensibleStatement;
31+
32+
class OrderedDataStructure implements DataStructureInterface {
33+
34+
private static final EmptyIteration<ExtensibleStatement> EMPTY_ITERATION = new EmptyIteration<>();
35+
36+
Set<ExtensibleStatement> statements = Collections.newSetFromMap(new ConcurrentHashMap<>());
37+
38+
@Override
39+
synchronized public void addStatement(ExtensibleStatement statement) {
40+
statements.add(statement);
41+
}
42+
43+
@Override
44+
synchronized public void removeStatement(ExtensibleStatement statement) {
45+
statements.remove(statement);
46+
47+
}
48+
49+
@Override
50+
synchronized public CloseableIteration<? extends ExtensibleStatement> getStatements(Resource subject,
51+
IRI predicate,
52+
Value object, boolean inferred, Resource... context) {
53+
return new FilteringIteration<>(
54+
new CloseableIteratorIteration<>(statements.iterator()), subject, predicate, object, inferred, context);
55+
}
56+
57+
@Override
58+
public CloseableIteration<? extends ExtensibleStatement> getStatements(StatementOrder statementOrder,
59+
Resource subject, IRI predicate, Value object, boolean inferred, Resource... contexts) {
60+
if (statements.isEmpty()) {
61+
return EMPTY_ITERATION;
62+
}
63+
if (inferred) {
64+
boolean containsInferred = statements.stream().anyMatch(ExtensibleStatement::isInferred);
65+
if (!containsInferred)
66+
return EMPTY_ITERATION;
67+
}
68+
return new SortedIteration<>(new FilteringIteration<>(new CloseableIteratorIteration<>(statements.iterator()),
69+
subject, predicate, object, inferred, contexts), statementOrder);
70+
}
71+
72+
@Override
73+
public void flushForReading() {
74+
75+
}
76+
77+
@Override
78+
public void init() {
79+
80+
}
81+
82+
@Override
83+
public void flushForCommit() {
84+
85+
}
86+
87+
@Override
88+
public long getEstimatedSize() {
89+
return statements.size();
90+
}
91+
92+
@Override
93+
public Set<StatementOrder> getSupportedOrders(Resource subj, IRI pred, Value obj, boolean inferred,
94+
Resource... contexts) {
95+
return EnumSet.of(StatementOrder.S, StatementOrder.P, StatementOrder.O, StatementOrder.C);
96+
}
97+
98+
@Override
99+
public Comparator<Value> getComparator() {
100+
return Comparator.comparing(Value::stringValue);
101+
}
102+
}

core/common/io/src/main/java/org/eclipse/rdf4j/common/lang/ObjectUtil.java

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
package org.eclipse.rdf4j.common.lang;
1313

14-
import java.util.Objects;
15-
1614
/**
1715
* Generic utility methods related to objects.
1816
*

core/common/io/src/main/java/org/eclipse/rdf4j/common/net/ParsedIRI.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public String toASCIIString() {
355355
appendAscii(sb, userInfo);
356356
sb.append('@');
357357
}
358-
if (host.length() > 0) {
358+
if (!host.isEmpty()) {
359359
sb.append(IDN.toASCII(host, IDN.ALLOW_UNASSIGNED));
360360
}
361361
if (port >= 0) {
@@ -516,7 +516,7 @@ public ParsedIRI normalize() {
516516
boolean localhost = isScheme("file") && userInfo == null && -1 == port
517517
&& ("".equals(host) || "localhost".equals(host));
518518
String _host = localhost ? null
519-
: host == null || host.length() == 0 ? host
519+
: host == null || host.isEmpty() ? host
520520
: IDN.toUnicode(pctEncodingNormalization(toLowerCase(host)),
521521
IDN.USE_STD3_ASCII_RULES | IDN.ALLOW_UNASSIGNED);
522522
String _path = _scheme != null && path == null ? "" : normalizePath(path);
@@ -581,14 +581,14 @@ public ParsedIRI resolve(ParsedIRI relative) {
581581
// relURI._scheme == null
582582

583583
// RFC, step 2:
584-
if (relative.getHost() == null && relative.getQuery() == null && relative.getPath().length() == 0) {
584+
if (relative.getHost() == null && relative.getQuery() == null && relative.getPath().isEmpty()) {
585585

586586
// Inherit any fragment identifier from relURI
587587
String fragment = relative.getFragment();
588588

589589
return new ParsedIRI(this.getScheme(), this.getUserInfo(), this.getHost(), this.getPort(), this.getPath(),
590590
this.getQuery(), fragment);
591-
} else if (relative.getHost() == null && relative.getPath().length() == 0) {
591+
} else if (relative.getHost() == null && relative.getPath().isEmpty()) {
592592

593593
// Inherit any query or fragment from relURI
594594
String query = relative.getQuery();
@@ -636,7 +636,7 @@ public ParsedIRI resolve(ParsedIRI relative) {
636636
path = path.substring(0, lastSlashIdx + 1);
637637
}
638638

639-
if (path.length() == 0) {
639+
if (path.isEmpty()) {
640640
// No path means: start at root.
641641
path = "/";
642642
}
@@ -782,7 +782,7 @@ private void parse() throws URISyntaxException {
782782
if (':' == peek()) {
783783
advance(1);
784784
String p = parseMember(DIGIT, '/');
785-
if (p.length() > 0) {
785+
if (!p.isEmpty()) {
786786
port = Integer.parseInt(p);
787787
} else {
788788
port = -1;
@@ -1101,7 +1101,7 @@ && isMember(ALPHA, path.codePointAt(1))) {
11011101
}
11021102

11031103
private String pctEncodingNormalization(String path) {
1104-
if (path == null || path.length() == 0 || path.indexOf('%') < 0) {
1104+
if (path == null || path.isEmpty() || path.indexOf('%') < 0) {
11051105
return path; // no pct encodings
11061106
}
11071107
String[] encodings = listPctEncodings(path);

core/common/iterator/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
<artifactId>rdf4j-model-api</artifactId>
1616
<version>${project.version}</version>
1717
</dependency>
18+
<dependency>
19+
<groupId>${project.groupId}</groupId>
20+
<artifactId>rdf4j-common-order</artifactId>
21+
<version>${project.version}</version>
22+
</dependency>
1823
<dependency>
1924
<groupId>org.slf4j</groupId>
2025
<artifactId>slf4j-api</artifactId>

core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/AbstractCloseableIteratorIteration.java

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import java.util.Iterator;
1515
import java.util.NoSuchElementException;
16-
import java.util.Objects;
1716

1817
/**
1918
* An Iteration that can convert an {@link Iterator} to a {@link CloseableIteration}.

0 commit comments

Comments
 (0)