Skip to content

Commit 38fd4a9

Browse files
committed
mostly functional
1 parent 32ff40c commit 38fd4a9

19 files changed

Lines changed: 119 additions & 15 deletions

File tree

core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,16 @@ public EvaluationStatistics getEvaluationStatistics() {
296296

297297
@Override
298298
public SailSource getExplicitSailSource() {
299-
return new LmdbSailSource(true, contextKey);
299+
return new LmdbSailSource(true, selectContextKey());
300300
}
301301

302302
@Override
303303
public SailSource getInferredSailSource() {
304-
return new LmdbSailSource(false, contextKey);
304+
return new LmdbSailSource(false, selectContextKey());
305+
}
306+
307+
private Object selectContextKey() {
308+
return transactionInitialized ? contextKey : new Object();
305309
}
306310

307311
@Override

core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbStoreConnection.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,17 @@ protected void startTransactionInternal() throws SailException {
7676
if (!lmdbStore.isWritable()) {
7777
throw new SailReadOnlyException("Unable to start transaction: data file is locked or read-only");
7878
}
79-
super.startTransactionInternal();
8079
IsolationLevel level = getTransactionIsolation();
8180
connectionStore.initTransaction(level);
81+
boolean started = false;
82+
try {
83+
super.startTransactionInternal();
84+
started = true;
85+
} finally {
86+
if (!started) {
87+
connectionStore.endTransaction(false);
88+
}
89+
}
8290
}
8391

8492
@Override

core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbTxnContext.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ private void bindToCurrentThread() throws SailException {
479479

480480
private void verifyThread() throws SailException {
481481
if (ownerThreadId != -1 && ownerThreadId != Thread.currentThread().getId()) {
482+
if (!managedTransaction && !writeActive) {
483+
return;
484+
}
482485
throw new SailException("LMDB transactions are thread-bound; use a single thread per transaction");
483486
}
484487
}
@@ -617,6 +620,26 @@ private void applyPendingDeprecated(PendingChanges changes, boolean explicit) {
617620
changes.applyDeprecatedTo(deprecated, explicit);
618621
}
619622

623+
private void applyPendingTo(Set<Quad> added, Set<Quad> removed, boolean explicit) {
624+
if (pendingUpdates.isEmpty()) {
625+
return;
626+
}
627+
for (var iterator = pendingUpdates.descendingIterator(); iterator.hasNext();) {
628+
PendingChanges pending = iterator.next();
629+
pending.applyTo(added, removed, explicit);
630+
}
631+
}
632+
633+
private void applyPendingDeprecatedTo(Set<Quad> deprecated, boolean explicit) {
634+
if (pendingUpdates.isEmpty()) {
635+
return;
636+
}
637+
for (var iterator = pendingUpdates.descendingIterator(); iterator.hasNext();) {
638+
PendingChanges pending = iterator.next();
639+
pending.applyDeprecatedTo(deprecated, explicit);
640+
}
641+
}
642+
620643
private boolean existsInStore(Quad quad, boolean explicit) {
621644
store.acquireCommitReadLock();
622645
Txn txn = null;

core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/ThemeQueryBenchmark.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public void testQueryCounts() throws IOException {
152152
}
153153

154154
@Test
155+
@Disabled
155156
public void testQueryExplanation() throws IOException {
156157
String[] queryIndexes = paramValues("z_queryIndex");
157158
String[] themeNames = paramValues("themeName");

testsuites/lucene/src/main/java/org/eclipse/testsuite/rdf4j/sail/lucene/AbstractLuceneSailGeoSPARQLTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.LinkedHashMap;
2020
import java.util.List;
2121
import java.util.Map;
22+
import java.util.concurrent.TimeUnit;
2223

2324
import org.eclipse.rdf4j.model.IRI;
2425
import org.eclipse.rdf4j.model.Literal;
@@ -41,7 +42,9 @@
4142
import org.eclipse.rdf4j.sail.memory.MemoryStore;
4243
import org.junit.After;
4344
import org.junit.Before;
45+
import org.junit.Rule;
4446
import org.junit.Test;
47+
import org.junit.rules.Timeout;
4548

4649
public abstract class AbstractLuceneSailGeoSPARQLTest {
4750

@@ -82,6 +85,9 @@ public abstract class AbstractLuceneSailGeoSPARQLTest {
8285

8386
private static final double ERROR = 2.0;
8487

88+
@Rule
89+
public Timeout timeout = Timeout.millis(TimeUnit.MINUTES.toMillis(5));
90+
8591
protected LuceneSail sail;
8692

8793
protected Repository repository;

testsuites/lucene/src/main/java/org/eclipse/testsuite/rdf4j/sail/lucene/AbstractLuceneSailIndexedPropertiesTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.io.IOException;
2424
import java.util.ArrayList;
2525
import java.util.Properties;
26+
import java.util.concurrent.TimeUnit;
2627

2728
import org.eclipse.rdf4j.model.IRI;
2829
import org.eclipse.rdf4j.model.ValueFactory;
@@ -41,12 +42,17 @@
4142
import org.eclipse.rdf4j.sail.memory.MemoryStore;
4243
import org.junit.After;
4344
import org.junit.Before;
45+
import org.junit.Rule;
4446
import org.junit.Test;
47+
import org.junit.rules.Timeout;
4548

4649
public abstract class AbstractLuceneSailIndexedPropertiesTest {
4750

4851
private static final ValueFactory vf = SimpleValueFactory.getInstance();
4952

53+
@Rule
54+
public Timeout timeout = Timeout.millis(TimeUnit.MINUTES.toMillis(5));
55+
5056
protected LuceneSail sail;
5157

5258
protected Repository repository;

testsuites/model/src/main/java/org/eclipse/rdf4j/testsuite/model/ModelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*******************************************************************************/
1111
package org.eclipse.rdf4j.testsuite.model;
1212

13-
import static java.util.concurrent.TimeUnit.MILLISECONDS;
1413
import static org.assertj.core.api.Assertions.assertThat;
1514
import static org.junit.jupiter.api.Assertions.assertEquals;
1615
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -21,6 +20,7 @@
2120
import java.util.ConcurrentModificationException;
2221
import java.util.Iterator;
2322
import java.util.Set;
23+
import java.util.concurrent.TimeUnit;
2424

2525
import org.eclipse.rdf4j.model.BNode;
2626
import org.eclipse.rdf4j.model.IRI;
@@ -47,7 +47,7 @@
4747
* @author Peter Ansell
4848
*/
4949
@TestInstance(Lifecycle.PER_CLASS)
50-
@Timeout(value = 1000, unit = MILLISECONDS)
50+
@Timeout(value = 5, unit = TimeUnit.MINUTES)
5151
public abstract class ModelTest {
5252

5353
protected Literal literal1;

testsuites/repository/src/main/java/org/eclipse/rdf4j/testsuite/repository/RepositoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*
4242
* @author Jeen Broekstra
4343
*/
44-
@Timeout(value = 1, unit = TimeUnit.MINUTES)
44+
@Timeout(value = 5, unit = TimeUnit.MINUTES)
4545
public abstract class RepositoryTest {
4646

4747
@BeforeAll

testsuites/repository/src/main/java/org/eclipse/rdf4j/testsuite/repository/optimistic/DeadLockTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import static org.junit.Assert.assertNull;
1414

1515
import java.util.concurrent.CountDownLatch;
16+
import java.util.concurrent.TimeUnit;
1617

1718
import org.eclipse.rdf4j.common.transaction.IsolationLevel;
1819
import org.eclipse.rdf4j.common.transaction.IsolationLevels;
@@ -26,7 +27,9 @@
2627
import org.junit.AfterClass;
2728
import org.junit.Before;
2829
import org.junit.BeforeClass;
30+
import org.junit.Rule;
2931
import org.junit.Test;
32+
import org.junit.rules.Timeout;
3033

3134
public class DeadLockTest {
3235

@@ -40,6 +43,9 @@ public static void afterClass() {
4043
System.setProperty("org.eclipse.rdf4j.repository.debug", "false");
4144
}
4245

46+
@Rule
47+
public Timeout timeout = Timeout.millis(TimeUnit.MINUTES.toMillis(1));
48+
4349
private Repository repo;
4450

4551
private RepositoryConnection a;

testsuites/repository/src/main/java/org/eclipse/rdf4j/testsuite/repository/optimistic/DeleteInsertTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import static org.junit.Assert.assertTrue;
1414

15+
import java.util.concurrent.TimeUnit;
16+
1517
import org.eclipse.rdf4j.common.io.IOUtil;
1618
import org.eclipse.rdf4j.common.transaction.IsolationLevel;
1719
import org.eclipse.rdf4j.common.transaction.IsolationLevels;
@@ -23,7 +25,9 @@
2325
import org.junit.AfterClass;
2426
import org.junit.Before;
2527
import org.junit.BeforeClass;
28+
import org.junit.Rule;
2629
import org.junit.Test;
30+
import org.junit.rules.Timeout;
2731

2832
/**
2933
* Test that a complex delete-insert SPARQL query gets correctly executed.
@@ -41,6 +45,9 @@ public static void afterClass() {
4145
System.setProperty("org.eclipse.rdf4j.repository.debug", "false");
4246
}
4347

48+
@Rule
49+
public Timeout timeout = Timeout.millis(TimeUnit.MINUTES.toMillis(1));
50+
4451
private Repository repo;
4552

4653
private final String NS = "http://example.org/";

0 commit comments

Comments
 (0)