|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.rdf.sail.BigdataSail.BigdataSailConnection
public class BigdataSail.BigdataSailConnection
Inner class implements the SailConnection. Some additional
functionality is available on this class, including
computeClosure().
BigdataSail. For example, this was
causing a problem with the close() method on this class
and on the classes derived from this class.| Field Summary | |
|---|---|
protected DelegatingChangeLog |
changeLog
Note: This needs to be visible to BigdataSailRWTxConnection#commit2(). |
protected AbstractTripleStore |
database
The database view. |
protected boolean |
openConn
True iff the SailConnection is open. |
protected boolean |
readOnly
True iff the database view is read-only. |
| Constructor Summary | |
|---|---|
protected |
BigdataSail.BigdataSailConnection(AbstractTripleStore database,
Lock lock,
boolean unisolated)
Create a SailConnection for the database. |
protected |
BigdataSail.BigdataSailConnection(Lock lock,
boolean unisolated)
|
| Method Summary | |
|---|---|
void |
addChangeLog(IChangeLog changeLog)
Set the change log on the SAIL connection. |
void |
addConnectionListener(SailConnectionListener listener)
Note: This method is strongly discouraged as it imposes an extremely high burden on the database requiring the materialization at the client of every statement to be added or removed from the database in the scope of this SailConnection. |
void |
addStatement(Resource s,
URI p,
Value o,
Resource... contexts)
Sesame has a concept of a "null" graph. |
protected void |
assertOpenConn()
|
protected void |
assertWritableConn()
|
protected void |
attach(AbstractTripleStore database)
Attach to a new database view. |
void |
clear(Resource... contexts)
|
void |
clearNamespaces()
|
void |
close()
Note: This does NOT implicitly rollback() the
SailConnection. |
void |
commit()
Commit the write set. |
long |
commit2()
Commit the write set. |
void |
computeClosure()
Computes the closure of the triple store for RDF(S)+ entailments. |
CloseableIteration<? extends BindingSet,QueryEvaluationException> |
evaluate(QueryRoot queryRoot,
Dataset dataset,
BindingSet bindings,
boolean includeInferred)
Deprecated. Consider removing this method from our public API. It is no longer in any code path for the bigdata code base. Embedded applications requiring high level evaluation should use BigdataSailRepositoryConnection. It
does not call through here, but goes directly to the
ASTEvalHelper. |
CloseableIteration<? extends BindingSet,QueryEvaluationException> |
evaluate(TupleExpr tupleExpr,
Dataset dataset,
BindingSet bindings,
boolean includeInferred)
Bigdata now uses an internal query model which differs significantly from the Sesame query model. |
long |
exactSize(Resource... contexts)
Note: This method is quite expensive since it must materialize all statement in either the database or in the specified context(s) and then filter for the explicit statements in order to obtain an exact count. |
void |
executeUpdate(UpdateExpr updateExpr,
Dataset dataset,
BindingSet bindingSet,
boolean includeInferred)
Bigdata now uses an internal query model which differs significantly from the Sesame query model. |
protected void |
finalize()
Invoke close, which will be harmless if we are already closed. |
protected void |
fireSailChangedEvent(boolean added,
Statement stmt)
Notifies SailConnectionListeners if one or more statements have
been added to or removed from the repository using the SAIL methods:
#addStatement(Resource, URI, Value)
#removeStatements(Resource, URI, Value)
#clearRepository()
|
void |
flush()
Flush the statement buffers. |
protected void |
flushStatementBuffers(boolean flushAssertBuffer,
boolean flushRetractBuffer)
Flush pending assertions and/or retractions to the database using efficient batch operations. |
boolean |
getAllowAutoCommit()
Used by the RepositoryConnection to determine whether or not to allow auto-commits. |
protected StatementBuffer<Statement> |
getAssertionBuffer()
Return the assertion buffer. |
BigdataSail |
getBigdataSail()
|
CloseableIteration<? extends Resource,SailException> |
getContextIDs()
|
String |
getNamespace(String prefix)
|
com.bigdata.rdf.sail.BigdataSail.BigdataSailConnection.NamespaceIterator |
getNamespaces()
|
protected StatementBuffer<Statement> |
getRetractionBuffer()
Return the retraction buffer (truth maintenance only). |
CloseableIteration<? extends Statement,SailException> |
getStatements(Resource s,
URI p,
Value o,
boolean includeInferred,
Resource... contexts)
Note: if the context is null, then you will see data
from each context in a quad store, including anything in the
BigdataSail.NULL_GRAPH. |
CloseableIteration<? extends Statement,SailException> |
getStatements(Resource s,
URI p,
Value o,
Resource context)
|
AbstractTripleStore |
getTripleStore()
The implementation object. |
boolean |
isOpen()
|
boolean |
isQueryTimeExpander()
When true, SAIL will compute entailments at query time that were excluded from forward closure. |
boolean |
isReadOnly()
When true, the connection does not permit mutation. |
boolean |
isUnisolated()
Return true if this is the ITx.UNISOLATED
connection. |
void |
removeAllEntailments()
Removes all "inferred" statements from the database and the proof chains (if any) associated with those inferences (does NOT commit the database). |
void |
removeConnectionListener(SailConnectionListener listener)
|
void |
removeNamespace(String prefix)
|
void |
removeStatements(Resource s,
URI p,
Value o,
Resource... contexts)
|
int |
removeStatements(Resource s,
URI p,
Value o,
Resource c)
Note: The CONTEXT is ignored when in statementIdentifier mode! |
void |
rollback()
Note: The semantics depend on the Options#STORE_CLASS. |
void |
setNamespace(String prefix,
String namespace)
|
long |
size(Resource... contexts)
Count the statements in the specified contexts. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected AbstractTripleStore database
protected boolean readOnly
protected boolean openConn
SailConnection is open.
protected DelegatingChangeLog changeLog
BigdataSailRWTxConnection#commit2().
| Constructor Detail |
|---|
protected BigdataSail.BigdataSailConnection(Lock lock,
boolean unisolated)
protected BigdataSail.BigdataSailConnection(AbstractTripleStore database,
Lock lock,
boolean unisolated)
SailConnection for the database.
database - The database. If this is a read-only view, then the
SailConnection will not support update.| Method Detail |
|---|
public String toString()
toString in class Objectpublic BigdataSail getBigdataSail()
protected StatementBuffer<Statement> getAssertionBuffer()
The assertion buffer is used to buffer statements that are being asserted so as to maximize the opportunity for batch writes. Truth maintenance (if enabled) will be performed no later than the commit of the transaction.
Note: When non-null and non-empty, the buffer MUST be
flushed (a) if a transaction completes (otherwise writes will not be
stored on the database); or (b) if there is a read against the
database during a transaction (otherwise reads will not see the
unflushed statements).
Note: if BigdataSail.truthMaintenance is enabled then this buffer is
backed by a temporary store which accumulates the SPOs to be
asserted. Otherwise it will write directly on the database each time
it is flushed, including when it overflows.
protected StatementBuffer<Statement> getRetractionBuffer()
The retraction buffer is used by the SailConnection API IFF
truth maintenance is enabled since the only methods available on the
Sail to delete statements,
#removeStatements(Resource, URI, Value) and
removeStatements(Resource, URI, Value, Resource[]), each
accepts a statement pattern rather than a set of statements. The
AbstractTripleStore directly supports removal of statements
matching a triple pattern, so we do not buffer retractions for those
method UNLESS truth maintenance is enabled.
protected void attach(AbstractTripleStore database)
database - public AbstractTripleStore getTripleStore()
public final boolean isQueryTimeExpander()
BigdataSail.Options.QUERY_TIME_EXPANDERpublic final boolean isReadOnly()
true, the connection does not permit mutation.
public final boolean isUnisolated()
true if this is the ITx.UNISOLATED
connection.
public boolean getAllowAutoCommit()
BigdataSail.Options.ALLOW_AUTO_COMMITpublic void addConnectionListener(SailConnectionListener listener)
SailConnection.
Further, while the client is only notified for explicit statements
added or removed, it is possible that a statement remains entailed in
the database regardless of its removal.
addConnectionListener in interface NotifyingSailConnectionpublic void removeConnectionListener(SailConnectionListener listener)
removeConnectionListener in interface NotifyingSailConnection
protected void fireSailChangedEvent(boolean added,
Statement stmt)
SailConnectionListeners if one or more statements have
been added to or removed from the repository using the SAIL methods:
#addStatement(Resource, URI, Value)
#removeStatements(Resource, URI, Value)
#clearRepository()
public void setNamespace(String prefix,
String namespace)
throws SailException
setNamespace in interface SailConnectionSailExceptionpublic String getNamespace(String prefix)
getNamespace in interface SailConnectionpublic void removeNamespace(String prefix)
removeNamespace in interface SailConnectionpublic void clearNamespaces()
clearNamespaces in interface SailConnectionpublic com.bigdata.rdf.sail.BigdataSail.BigdataSailConnection.NamespaceIterator getNamespaces()
getNamespaces in interface SailConnection
public void addStatement(Resource s,
URI p,
Value o,
Resource... contexts)
throws SailException
addStatement in interface SailConnectionSailExceptionBigdataSail.NULL_GRAPH
public void clear(Resource... contexts)
throws SailException
clear in interface SailConnectionSailException
public long size(Resource... contexts)
throws SailException
BigdataSail.Options.EXACT_SIZE. Exact size is an extremely expensive operation,
which we turn off by default. In default mode, an upper bound is
given for the total number of statements in the database, explicit
and inferred. In exact size mode, the entire index will be visited
and materialized and each explicit statement will be counted.
size in interface SailConnectionSailExceptionBigdataSail.Options.EXACT_SIZE
public long exactSize(Resource... contexts)
throws SailException
AbstractTripleStore.getStatementCount() or
IAccessPath#rangeCount() for efficient methods for reporting
on the #of statements in the database or within a specific context.
SailExceptionBigdataSail.Options.EXACT_SIZE
public void removeStatements(Resource s,
URI p,
Value o,
Resource... contexts)
throws SailException
removeStatements in interface SailConnectionSailException
public int removeStatements(Resource s,
URI p,
Value o,
Resource c)
throws SailException
SailException
public CloseableIteration<? extends Resource,SailException> getContextIDs()
throws SailException
getContextIDs in interface SailConnectionSailException
public void rollback()
throws SailException
Options#STORE_CLASS. See
ITripleStore#abort().
rollback in interface SailConnectionSailException
public long commit2()
throws SailException
Note: The semantics depend on the Options#STORE_CLASS. See
ITripleStore#commit().
0L if the write set was empty such that nothing
was committed.
SailException
public final void commit()
throws SailException
Note: The semantics depend on the Options#STORE_CLASS. See
ITripleStore#commit().
commit in interface SailConnectionSailException
public final boolean isOpen()
throws SailException
isOpen in interface SailConnectionSailException
public void close()
throws SailException
rollback() the
SailConnection. If you are doing error handling do NOT
assume that close() will discard all writes.
close in interface SailConnectionSailException
protected void finalize()
throws Throwable
finalize in class ObjectThrowablepublic void flush()
BigdataSail.BigdataSailConnection
heavily buffers assertions and retractions. Either a flush()
or a commit() is required before executing any operations
directly against the backing AbstractTripleStore so that the
buffered assertions or retractions will be written onto the KB and
become visible to other methods. This is not a transaction issue --
just a buffer issue. The public methods on the
BigdataSail.BigdataSailConnection all flush the buffers before performing
any queries against the underlying AbstractTripleStore.
protected void flushStatementBuffers(boolean flushAssertBuffer,
boolean flushRetractBuffer)
BigdataSail.getTruthMaintenance() returns
true this method will also handle truth maintenance.
Note: This MUST be invoked within any method that will read on the database to ensure that any pending writes have been flushed (otherwise the read operation will not be able to see the pending writes). However, methods that assert or retract statements MUST only flush the buffer on which they will NOT write. E.g., if you are going to retract statements, then first flush the assertions buffer and visa versa.
protected void assertOpenConn()
throws SailException
SailException
protected void assertWritableConn()
throws SailException
SailException
public CloseableIteration<? extends Statement,SailException> getStatements(Resource s,
URI p,
Value o,
Resource context)
throws SailException
SailException
public CloseableIteration<? extends Statement,SailException> getStatements(Resource s,
URI p,
Value o,
boolean includeInferred,
Resource... contexts)
throws SailException
null, then you will see data
from each context in a quad store, including anything in the
BigdataSail.NULL_GRAPH.
getStatements in interface SailConnectionSailException
public void computeClosure()
throws SailException
This computes the closure of the database. This can be used if you do NOT enable truth maintenance and choose instead to load up all of your data first and then compute the closure of the database. Note that some rules may be computed by eager closure while others are computed at query time.
Note: If there are already entailments in the database AND you have retracted statements since the last time the closure was computed then you MUST delete all entailments from the database before re-computing the closure.
Note: This method does NOT commit the database. See
ITripleStore#commit() and getTripleStore().
SailExceptionremoveAllEntailments()
public void removeAllEntailments()
throws SailException
SailException
public void executeUpdate(UpdateExpr updateExpr,
Dataset dataset,
BindingSet bindingSet,
boolean includeInferred)
throws SailException
UpdateExpr evaluation. SPARQL UPDATE requests must be
prepared and evaluated using a
BigdataSailRepositoryConnection.
executeUpdate in interface SailConnectionSailException - always.
public CloseableIteration<? extends BindingSet,QueryEvaluationException> evaluate(TupleExpr tupleExpr,
Dataset dataset,
BindingSet bindings,
boolean includeInferred)
throws SailException
TupleExpr evaluation. SPARQL queries must be prepared and
evaluated using a BigdataSailRepositoryConnection.
evaluate in interface SailConnectionSailException - always.
public CloseableIteration<? extends BindingSet,QueryEvaluationException> evaluate(QueryRoot queryRoot,
Dataset dataset,
BindingSet bindings,
boolean includeInferred)
throws SailException
BigdataSailRepositoryConnection. It
does not call through here, but goes directly to the
ASTEvalHelper.
queryRoot - The query model.dataset - The data set (optional).bindings - The initial bindings.includeInferred - true iff inferences will be considered when
reading on access paths.
CloseableIteration from which the solutions may
be drained.
SailExceptionpublic void addChangeLog(IChangeLog changeLog)
IChangeLog
and IChangeRecord.
changeLog - the change log
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||