diff --git a/core/sail/api/src/main/java/org/eclipse/rdf4j/sail/helpers/AbstractSailConnection.java b/core/sail/api/src/main/java/org/eclipse/rdf4j/sail/helpers/AbstractSailConnection.java index ca9bb7b60f..01d9c659a6 100644 --- a/core/sail/api/src/main/java/org/eclipse/rdf4j/sail/helpers/AbstractSailConnection.java +++ b/core/sail/api/src/main/java/org/eclipse/rdf4j/sail/helpers/AbstractSailConnection.java @@ -24,6 +24,7 @@ import java.util.concurrent.locks.LockSupport; import java.util.concurrent.locks.ReentrantLock; +import org.eclipse.rdf4j.common.annotation.Experimental; import org.eclipse.rdf4j.common.annotation.InternalUseOnly; import org.eclipse.rdf4j.common.concurrent.locks.Lock; import org.eclipse.rdf4j.common.concurrent.locks.diagnostics.ConcurrentCleaner; @@ -733,10 +734,8 @@ protected void endUpdateInternal(UpdateContext op) throws SailException { synchronized (added) { model = added.remove(op); } - if (model != null) { - for (Statement st : model) { - addStatementInternal(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext()); - } + if (model != null && !model.isEmpty()) { + bulkAddStatementsInternal(model); } } @@ -973,6 +972,14 @@ protected void prepareInternal() throws SailException { protected abstract void addStatementInternal(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException; + @Experimental + protected void bulkAddStatementsInternal(final Collection statements) + throws SailException { + for (final Statement st : statements) { + addStatementInternal(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext()); + } + } + protected abstract void removeStatementsInternal(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException;