public LuceneSpinSailConnection(NotifyingSailConnection wrappedConnection, SearchIndex luceneIndex, LuceneSpinSail sail) { super(wrappedConnection); this.luceneIndex = luceneIndex; this.sail = sail; /* * Using SailConnectionListener, see <a href="#whySailConnectionListener">above</a> */ wrappedConnection.addConnectionListener(connectionListener); }
/** * Removes the given listener from the wrapped connection. */ @Override public void removeConnectionListener(SailConnectionListener listener) { getWrappedConnection().removeConnectionListener(listener); } }
@Override public void begin(IsolationLevel level) throws SailException { assert addedStatements == null; assert removedStatements == null; stats = new Stats(); // start two transactions, synchronize on underlying sail so that we get two transactions immediatly successivley synchronized (sail){ super.begin(level); previousStateConnection.begin(IsolationLevels.SNAPSHOT); } }
@Override public synchronized void clear(Resource... contexts) throws SailException { // remove the connection listener, this is safe as the changing methods // are synchronized // during the clear(), no other operation can be invoked getWrappedConnection().removeConnectionListener(connectionListener); try { super.clear(contexts); buffer.clear(contexts); } finally { getWrappedConnection().addConnectionListener(connectionListener); } }
boolean empty = !baseSailConnection.hasStatement((Resource) null, (IRI) null, null, true); if (empty) { return; try (CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate = baseSailConnection.evaluate(parsedQuery.getTupleExpr(), parsedQuery.getDataset(), new MapBindingSet(), true)) { while (evaluate.hasNext()) { BindingSet next = evaluate.next();
@Override public void rollback() throws SailException { synchronized (sail) { previousStateConnection.commit(); cleanup(); super.rollback(); } }
void calculateNext() { while (next == null && parentIterator.hasNext()) { Tuple temp = parentIterator.next(); Resource subject = (Resource) temp.line.get(0); if (shaclSailConnection.hasStatement(subject, RDF.TYPE, filterOnType, true)) { next = temp; next.addHistory(new Tuple(Arrays.asList(subject, RDF.TYPE, filterOnType))); } } }
try (CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate = baseSailConnection.evaluate(parsedQuery.getTupleExpr(), parsedQuery.getDataset(), new MapBindingSet(), true)) { while (evaluate.hasNext()) { BindingSet next = evaluate.next();
connection.addStatement(subject, predicate, object, resources);
@Override public synchronized void clear(Resource... resources) throws SailException { // remove the connection listener, this is safe as the changing methods // are synchronized // during the clear(), no other operation can be invoked getWrappedConnection().removeConnectionListener(connectionListener); try { super.clear(resources); buffer.clear(resources); } finally { getWrappedConnection().addConnectionListener(connectionListener); } }
boolean empty = !baseSailConnection.hasStatement((Resource) null, (IRI) null, null, true); if (empty) { return; try (CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate = baseSailConnection.evaluate(parsedQuery.getTupleExpr(), parsedQuery.getDataset(), new MapBindingSet(), true)) { while (evaluate.hasNext()) { BindingSet next = evaluate.next();
@Override public void rollback() throws SailException { synchronized (sail) { previousStateConnection.commit(); cleanup(); super.rollback(); } }
void calculateNext() { while (next == null && parentIterator.hasNext()) { Tuple temp = parentIterator.next(); Resource subject = (Resource) temp.line.get(0); if (shaclSailConnection.hasStatement(subject, RDF.TYPE, filterOnType, true)) { next = temp; next.addHistory(new Tuple(Arrays.asList(subject, RDF.TYPE, filterOnType))); } } }
try (CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate = baseSailConnection.evaluate(parsedQuery.getTupleExpr(), parsedQuery.getDataset(), new MapBindingSet(), true)) { while (evaluate.hasNext()) { BindingSet next = evaluate.next();
/** * Adds the given listener to the wrapped connection. */ @Override public void addConnectionListener(SailConnectionListener listener) { getWrappedConnection().addConnectionListener(listener); }
/** * Removes the given listener from the wrapped connection. */ @Override public void removeConnectionListener(SailConnectionListener listener) { getWrappedConnection().removeConnectionListener(listener); } }
@Override public void commit() throws SailException { synchronized (sail) { try { boolean valid = validate(); previousStateConnection.commit(); if (!valid) { rollback(); throw new SailException("Failed SHACL validation"); } else { super.commit(); } } finally { cleanup(); } } }
@Override public void begin(IsolationLevel level) throws SailException { assert addedStatements == null; assert removedStatements == null; stats = new Stats(); // start two transactions, synchronize on underlying sail so that we get two transactions immediatly successivley synchronized (sail){ super.begin(level); previousStateConnection.begin(IsolationLevels.SNAPSHOT); } }
/** * Adds the given listener to the wrapped connection. */ @Override public void addConnectionListener(SailConnectionListener listener) { getWrappedConnection().addConnectionListener(listener); }
@Override public void commit() throws SailException { synchronized (sail) { try { boolean valid = validate(); previousStateConnection.commit(); if (!valid) { rollback(); throw new SailException("Failed SHACL validation"); } else { super.commit(); } } finally { cleanup(); } } }