org.openrdf.sail.memory
Class MemoryStoreConnection

java.lang.Object
  extended by org.openrdf.sail.helpers.SailConnectionBase
      extended by org.openrdf.sail.helpers.NotifyingSailConnectionBase
          extended by org.openrdf.sail.memory.MemoryStoreConnection
All Implemented Interfaces:
InferencerConnection, NotifyingSailConnection, SailConnection

public class MemoryStoreConnection
extends NotifyingSailConnectionBase
implements InferencerConnection

Implementation of a Sail Connection for memory stores.

Author:
Arjohn Kampman, jeen

Nested Class Summary
protected  class MemoryStoreConnection.MemEvaluationStatistics
          Uses the MemoryStore's statement sizes to give cost estimates based on the size of the expected results.
protected  class MemoryStoreConnection.MemTripleSource
          Implementation of the TripleSource interface from the Sail Query Model
 
Field Summary
protected  MemoryStore store
           
 
Fields inherited from class org.openrdf.sail.helpers.SailConnectionBase
logger
 
Constructor Summary
protected MemoryStoreConnection(MemoryStore store)
           
 
Method Summary
 boolean addInferredStatement(Resource subj, URI pred, Value obj, Resource... contexts)
          Adds an inferred statement to a specific context.
protected  boolean addStatementInternal(Resource subj, URI pred, Value obj, boolean explicit, Resource... contexts)
          Adds the specified statement to this MemoryStore.
protected  void addStatementInternal(Resource subj, URI pred, Value obj, Resource... contexts)
           
 void clearInferred(Resource... contexts)
          Removes all inferred statements from the specified/all contexts.
protected  void clearInternal(Resource... contexts)
           
protected  void clearNamespacesInternal()
           
protected  void closeInternal()
           
protected  void commitInternal()
           
protected  CloseableIteration<? extends BindingSet,QueryEvaluationException> evaluateInternal(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred)
           
 void flushUpdates()
          Flushes any pending updates to be processed and the resulting changes to be reported to registered SailConnectionListeners.
protected  CloseableIteration<? extends Resource,SailException> getContextIDsInternal()
           
protected  String getNamespaceInternal(String prefix)
           
protected  CloseableIteration<? extends Namespace,SailException> getNamespacesInternal()
           
protected  CloseableIteration<? extends Statement,SailException> getStatementsInternal(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts)
           
 boolean removeInferredStatement(Resource subj, URI pred, Value obj, Resource... contexts)
          Removes an inferred statement from a specific context.
protected  boolean removeIteratorStatements(CloseableIteration<MemStatement,SailException> stIter, boolean explicit)
           
protected  void removeNamespaceInternal(String prefix)
           
protected  boolean removeStatementsInternal(Resource subj, URI pred, Value obj, boolean explicit, Resource... contexts)
          Removes the statements that match the specified pattern of subject, predicate, object and context.
protected  void removeStatementsInternal(Resource subj, URI pred, Value obj, Resource... contexts)
           
protected  void rollbackInternal()
           
protected  void setNamespaceInternal(String prefix, String name)
           
protected  long sizeInternal(Resource... contexts)
           
protected  void startTransactionInternal()
           
 
Methods inherited from class org.openrdf.sail.helpers.NotifyingSailConnectionBase
addConnectionListener, hasConnectionListeners, notifyStatementAdded, notifyStatementRemoved, removeConnectionListener
 
Methods inherited from class org.openrdf.sail.helpers.SailConnectionBase
addStatement, autoStartTransaction, clear, clearNamespaces, close, commit, evaluate, finalize, getContextIDs, getExclusiveConnectionLock, getNamespace, getNamespaces, getSharedConnectionLock, getStatements, getTransactionLock, isOpen, iterationClosed, registerIteration, removeNamespace, removeStatements, rollback, setNamespace, size, transactionActive, verifyIsOpen
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openrdf.sail.NotifyingSailConnection
addConnectionListener, removeConnectionListener
 
Methods inherited from interface org.openrdf.sail.SailConnection
addStatement, clear, clearNamespaces, close, commit, evaluate, getContextIDs, getNamespace, getNamespaces, getStatements, isOpen, removeNamespace, removeStatements, rollback, setNamespace, size
 

Field Detail

store

protected final MemoryStore store
Constructor Detail

MemoryStoreConnection

protected MemoryStoreConnection(MemoryStore store)
Method Detail

evaluateInternal

protected CloseableIteration<? extends BindingSet,QueryEvaluationException> evaluateInternal(TupleExpr tupleExpr,
                                                                                             Dataset dataset,
                                                                                             BindingSet bindings,
                                                                                             boolean includeInferred)
                                                                                      throws SailException
Specified by:
evaluateInternal in class SailConnectionBase
Throws:
SailException

closeInternal

protected void closeInternal()
                      throws SailException
Specified by:
closeInternal in class SailConnectionBase
Throws:
SailException

getContextIDsInternal

protected CloseableIteration<? extends Resource,SailException> getContextIDsInternal()
                                                                              throws SailException
Specified by:
getContextIDsInternal in class SailConnectionBase
Throws:
SailException

getStatementsInternal

protected CloseableIteration<? extends Statement,SailException> getStatementsInternal(Resource subj,
                                                                                      URI pred,
                                                                                      Value obj,
                                                                                      boolean includeInferred,
                                                                                      Resource... contexts)
                                                                               throws SailException
Specified by:
getStatementsInternal in class SailConnectionBase
Throws:
SailException

sizeInternal

protected long sizeInternal(Resource... contexts)
                     throws SailException
Specified by:
sizeInternal in class SailConnectionBase
Throws:
SailException

getNamespacesInternal

protected CloseableIteration<? extends Namespace,SailException> getNamespacesInternal()
                                                                               throws SailException
Specified by:
getNamespacesInternal in class SailConnectionBase
Throws:
SailException

getNamespaceInternal

protected String getNamespaceInternal(String prefix)
                               throws SailException
Specified by:
getNamespaceInternal in class SailConnectionBase
Throws:
SailException

startTransactionInternal

protected void startTransactionInternal()
                                 throws SailException
Specified by:
startTransactionInternal in class SailConnectionBase
Throws:
SailException

commitInternal

protected void commitInternal()
                       throws SailException
Specified by:
commitInternal in class SailConnectionBase
Throws:
SailException

rollbackInternal

protected void rollbackInternal()
                         throws SailException
Specified by:
rollbackInternal in class SailConnectionBase
Throws:
SailException

addStatementInternal

protected void addStatementInternal(Resource subj,
                                    URI pred,
                                    Value obj,
                                    Resource... contexts)
                             throws SailException
Specified by:
addStatementInternal in class SailConnectionBase
Throws:
SailException

addInferredStatement

public boolean addInferredStatement(Resource subj,
                                    URI pred,
                                    Value obj,
                                    Resource... contexts)
                             throws SailException
Description copied from interface: InferencerConnection
Adds an inferred statement to a specific context.

Specified by:
addInferredStatement in interface InferencerConnection
Parameters:
subj - The subject of the statement to add.
pred - The predicate of the statement to add.
obj - The object of the statement to add.
contexts - The context(s) to add the statement to. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.
Throws:
SailException - If the statement could not be added.

addStatementInternal

protected boolean addStatementInternal(Resource subj,
                                       URI pred,
                                       Value obj,
                                       boolean explicit,
                                       Resource... contexts)
                                throws SailException
Adds the specified statement to this MemoryStore.

Throws:
SailException

removeStatementsInternal

protected void removeStatementsInternal(Resource subj,
                                        URI pred,
                                        Value obj,
                                        Resource... contexts)
                                 throws SailException
Specified by:
removeStatementsInternal in class SailConnectionBase
Throws:
SailException

removeInferredStatement

public boolean removeInferredStatement(Resource subj,
                                       URI pred,
                                       Value obj,
                                       Resource... contexts)
                                throws SailException
Description copied from interface: InferencerConnection
Removes an inferred statement from a specific context.

Specified by:
removeInferredStatement in interface InferencerConnection
Parameters:
subj - The subject of the statement that should be removed.
pred - The predicate of the statement that should be removed.
obj - The object of the statement that should be removed.
contexts - The context(s) from which to remove the statements. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.
Throws:
SailException - If the statement could not be removed.

clearInternal

protected void clearInternal(Resource... contexts)
                      throws SailException
Specified by:
clearInternal in class SailConnectionBase
Throws:
SailException

clearInferred

public void clearInferred(Resource... contexts)
                   throws SailException
Description copied from interface: InferencerConnection
Removes all inferred statements from the specified/all contexts. If no contexts are specified the method operates on the entire repository.

Specified by:
clearInferred in interface InferencerConnection
Parameters:
contexts - The context(s) from which to remove the statements. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.
Throws:
SailException - If the statements could not be removed.

flushUpdates

public void flushUpdates()
Description copied from interface: InferencerConnection
Flushes any pending updates to be processed and the resulting changes to be reported to registered SailConnectionListeners.

Specified by:
flushUpdates in interface InferencerConnection

removeStatementsInternal

protected boolean removeStatementsInternal(Resource subj,
                                           URI pred,
                                           Value obj,
                                           boolean explicit,
                                           Resource... contexts)
                                    throws SailException
Removes the statements that match the specified pattern of subject, predicate, object and context.

Parameters:
subj - The subject for the pattern, or null for a wildcard.
pred - The predicate for the pattern, or null for a wildcard.
obj - The object for the pattern, or null for a wildcard.
explicit - Flag indicating whether explicit or inferred statements should be removed; true removes explicit statements that match the pattern, false removes inferred statements that match the pattern.
Throws:
SailException

removeIteratorStatements

protected boolean removeIteratorStatements(CloseableIteration<MemStatement,SailException> stIter,
                                           boolean explicit)
                                    throws SailException
Throws:
SailException

setNamespaceInternal

protected void setNamespaceInternal(String prefix,
                                    String name)
                             throws SailException
Specified by:
setNamespaceInternal in class SailConnectionBase
Throws:
SailException

removeNamespaceInternal

protected void removeNamespaceInternal(String prefix)
                                throws SailException
Specified by:
removeNamespaceInternal in class SailConnectionBase
Throws:
SailException

clearNamespacesInternal

protected void clearNamespacesInternal()
                                throws SailException
Specified by:
clearNamespacesInternal in class SailConnectionBase
Throws:
SailException


Copyright © 2001-2008 Aduna. All Rights Reserved.