Skip to content

Commit

Permalink
Merge pull request #3573 from eclipse/GH-3572-concurreny-weak-object-…
Browse files Browse the repository at this point in the history
…registry

GH-3572 Concurrent WeakObjectRegistry
  • Loading branch information
hmottestad authored Jan 11, 2022
2 parents 61e0551 + 066ba5a commit bf89717
Show file tree
Hide file tree
Showing 9 changed files with 607 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,11 @@ protected void parsePrefixID() throws IOException, RDFParseException, RDFHandler
skipWSC();

// Read the namespace URI
IRI namespace = parseURI();
String namespaceStr = parseURI().toString();

// Store and report this namespace mapping
String prefixStr = prefixID.toString();
String namespaceStr = namespace.toString();

// Store and report this namespace mapping
setNamespace(prefixStr, namespaceStr);

if (rdfHandler != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.eclipse.rdf4j.sail.base.SailSink;
import org.eclipse.rdf4j.sail.base.SailSource;
import org.eclipse.rdf4j.sail.base.SailStore;
import org.eclipse.rdf4j.sail.memory.model.MemBNode;
import org.eclipse.rdf4j.sail.memory.model.MemIRI;
import org.eclipse.rdf4j.sail.memory.model.MemResource;
import org.eclipse.rdf4j.sail.memory.model.MemStatement;
Expand All @@ -49,6 +50,7 @@
import org.eclipse.rdf4j.sail.memory.model.MemTriple;
import org.eclipse.rdf4j.sail.memory.model.MemValue;
import org.eclipse.rdf4j.sail.memory.model.MemValueFactory;
import org.eclipse.rdf4j.sail.memory.model.WeakObjectRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -782,20 +784,27 @@ public CloseableIteration<? extends Resource, SailException> getContextIDs() thr

Lock stLock = openStatementsReadLock();
try {
synchronized (valueFactory) {
int snapshot = getCurrentSnapshot();
for (MemResource memResource : valueFactory.getMemURIs()) {
int snapshot = getCurrentSnapshot();
try (WeakObjectRegistry.AutoCloseableIterator<MemIRI> memIRIsIterator = valueFactory
.getMemIRIsIterator()) {
while (memIRIsIterator.hasNext()) {
MemResource memResource = memIRIsIterator.next();
if (isContextResource(memResource, snapshot)) {
contextIDs.add(memResource);
}
}
}

for (MemResource memResource : valueFactory.getMemBNodes()) {
try (WeakObjectRegistry.AutoCloseableIterator<MemBNode> memBNodesIterator = valueFactory
.getMemBNodesIterator()) {
while (memBNodesIterator.hasNext()) {
MemResource memResource = memBNodesIterator.next();
if (isContextResource(memResource, snapshot)) {
contextIDs.add(memResource);
}
}
}

} finally {
stLock.release();
}
Expand Down
Loading

0 comments on commit bf89717

Please sign in to comment.