Package org.eclipse.rdf4j.sail.lucene
Class LuceneSailConnection
- java.lang.Object
-
- org.eclipse.rdf4j.sail.helpers.SailConnectionWrapper
-
- org.eclipse.rdf4j.sail.helpers.NotifyingSailConnectionWrapper
-
- org.eclipse.rdf4j.sail.lucene.LuceneSailConnection
-
- All Implemented Interfaces:
AutoCloseable,FederatedServiceResolverClient,org.eclipse.rdf4j.sail.features.ThreadSafetyAware,NotifyingSailConnection,SailConnection
public class LuceneSailConnection extends org.eclipse.rdf4j.sail.helpers.NotifyingSailConnectionWrapperSail Connection Listener instead of implementing add/remove
Using SailConnectionListener, see above The LuceneIndex is adapted based on events coming from the wrapped Sail, rather than by overriding the addStatement and removeStatements methods. This approach has two benefits: (1) when the wrapped Sail only reports statements that were not stored before, the LuceneIndex does not have to do the check on the skipped statemements and (2) the method for removing Statements from the Lucene index does not have to take wildcards into account, making its implementation simpler.Synchronized Methods
LuceneSailConnection uses a listener to collect removed statements. The listener should not be active during the removal of contexts, as this is not needed (context removal is implemented differently). To realize this, all methods that can do changes are synchronized and during context removal, the listener is disabled. Thus, all methods of this connection that can change data are synchronized.Evaluating Queries - possible optimizations
Arjohn has answered this question in the sesame-dev mailinglist on 13.8.2007: Is there a QueryModelNode that can contain a fixed (perhaps very long) list of Query result bindings? There is currently no such node, but there are two options to get similar behaviour: 1) Include the result bindings as OR-ed constraints in the query model. E.g. if you have a result binding like {{x=1,y=1},{x=2,y=2}}, this translates to the constraints (x=1 and y=1) or (x=2 and y=2). 2) The LuceneSail could iterate over the LuceneQueryResult and supply the various results as query input parameters to the underlying Sail. This is similar to using PreparedStatement's in JDBC.- Author:
- sauermann, christian.huetter
-
-
Field Summary
Fields Modifier and Type Field Description protected SailConnectionListenerconnectionListenerThe listener that listens to the underlying connection.
-
Constructor Summary
Constructors Constructor Description LuceneSailConnection(NotifyingSailConnection wrappedConnection, SearchIndex luceneIndex, LuceneSail sail)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddStatement(org.eclipse.rdf4j.model.Resource subj, org.eclipse.rdf4j.model.IRI pred, org.eclipse.rdf4j.model.Value obj, org.eclipse.rdf4j.model.Resource... contexts)voidbegin()voidclear(org.eclipse.rdf4j.model.Resource... contexts)voidclose()voidcommit()org.eclipse.rdf4j.common.iteration.CloseableIteration<? extends org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException>evaluate(org.eclipse.rdf4j.query.algebra.TupleExpr tupleExpr, org.eclipse.rdf4j.query.Dataset dataset, org.eclipse.rdf4j.query.BindingSet bindings, boolean includeInferred)voidremoveStatements(org.eclipse.rdf4j.model.Resource subj, org.eclipse.rdf4j.model.IRI pred, org.eclipse.rdf4j.model.Value obj, org.eclipse.rdf4j.model.Resource... contexts)voidrollback()-
Methods inherited from class org.eclipse.rdf4j.sail.helpers.NotifyingSailConnectionWrapper
addConnectionListener, getWrappedConnection, removeConnectionListener
-
Methods inherited from class org.eclipse.rdf4j.sail.helpers.SailConnectionWrapper
addStatement, begin, clearNamespaces, endUpdate, explain, flush, getContextIDs, getFederatedServiceResolver, getNamespace, getNamespaces, getStatements, hasStatement, isActive, isOpen, pendingRemovals, prepare, prepareQuery, removeNamespace, removeStatement, setFederatedServiceResolver, setNamespace, setTransactionSettings, size, size, startUpdate, supportsConcurrentReads
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.sail.SailConnection
addStatement, begin, clearNamespaces, endUpdate, explain, flush, getContextIDs, getNamespace, getNamespaces, getStatements, hasStatement, isActive, isOpen, pendingRemovals, prepare, prepareQuery, removeNamespace, removeStatement, setNamespace, setTransactionSettings, size, startUpdate
-
-
-
-
Field Detail
-
connectionListener
protected final SailConnectionListener connectionListener
The listener that listens to the underlying connection. It is disabled during clearContext operations.
-
-
Constructor Detail
-
LuceneSailConnection
public LuceneSailConnection(NotifyingSailConnection wrappedConnection, SearchIndex luceneIndex, LuceneSail sail)
-
-
Method Detail
-
addStatement
public void addStatement(org.eclipse.rdf4j.model.Resource subj, org.eclipse.rdf4j.model.IRI pred, org.eclipse.rdf4j.model.Value obj, org.eclipse.rdf4j.model.Resource... contexts) throws SailException- Specified by:
addStatementin interfaceSailConnection- Overrides:
addStatementin classorg.eclipse.rdf4j.sail.helpers.SailConnectionWrapper- Throws:
SailException
-
close
public void close() throws SailException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSailConnection- Overrides:
closein classorg.eclipse.rdf4j.sail.helpers.SailConnectionWrapper- Throws:
SailException
-
clear
public void clear(org.eclipse.rdf4j.model.Resource... contexts) throws SailException- Specified by:
clearin interfaceSailConnection- Overrides:
clearin classorg.eclipse.rdf4j.sail.helpers.SailConnectionWrapper- Throws:
SailException
-
begin
public void begin() throws SailException- Specified by:
beginin interfaceSailConnection- Overrides:
beginin classorg.eclipse.rdf4j.sail.helpers.SailConnectionWrapper- Throws:
SailException
-
commit
public void commit() throws SailException- Specified by:
commitin interfaceSailConnection- Overrides:
commitin classorg.eclipse.rdf4j.sail.helpers.SailConnectionWrapper- Throws:
SailException
-
evaluate
public org.eclipse.rdf4j.common.iteration.CloseableIteration<? extends org.eclipse.rdf4j.query.BindingSet,org.eclipse.rdf4j.query.QueryEvaluationException> evaluate(org.eclipse.rdf4j.query.algebra.TupleExpr tupleExpr, org.eclipse.rdf4j.query.Dataset dataset, org.eclipse.rdf4j.query.BindingSet bindings, boolean includeInferred) throws SailException- Specified by:
evaluatein interfaceSailConnection- Overrides:
evaluatein classorg.eclipse.rdf4j.sail.helpers.SailConnectionWrapper- Throws:
SailException
-
removeStatements
public void removeStatements(org.eclipse.rdf4j.model.Resource subj, org.eclipse.rdf4j.model.IRI pred, org.eclipse.rdf4j.model.Value obj, org.eclipse.rdf4j.model.Resource... contexts) throws SailException- Specified by:
removeStatementsin interfaceSailConnection- Overrides:
removeStatementsin classorg.eclipse.rdf4j.sail.helpers.SailConnectionWrapper- Throws:
SailException
-
rollback
public void rollback() throws SailException- Specified by:
rollbackin interfaceSailConnection- Overrides:
rollbackin classorg.eclipse.rdf4j.sail.helpers.SailConnectionWrapper- Throws:
SailException
-
-