Interface DataStoreConnection
- All Superinterfaces:
java.lang.AutoCloseable
public interface DataStoreConnection
extends java.lang.AutoCloseable
Encapsulates the connection to a data store of an RDFox server. All instances of this class are single-threaded — that is, no method should
be called simultaneously on several threads. However, please note that there is no thread affinity — that is, methods on one connection can
be called from different threads as long as the calls are serialised externally. Methods
duplicate()
and interrupt()
are
exceptions and can be invoked in parallel with any other method apart from close()
: calling close()
in parallel with any other
method runs a high risk of crashing the JVM. Multiple connections to the same data store should be used to access a data store concurrently. A data
store connection uses transactions to coordinate how concurrent accesses interact. A connection must be closed after use in order to release the
resources associated with it.-
Field Summary
Fields Modifier and Type Field Description static long
WAIT_FOREVER
Specifies that the system should wait forever when it needs to acquire a lock on a data store (seesetLockTimeout(long)
). -
Method Summary
Modifier and Type Method Description long
addRule(tech.oxfordsemantic.jrdfox.logic.datalog.Rule rule)
Adds a rule to the data store.long
addRules(java.util.Collection<tech.oxfordsemantic.jrdfox.logic.datalog.Rule> datalogProgram)
Adds a collection of rules to the data store.void
begin(TransactionType transactionType)
Deprecated.void
beginTransaction(TransactionType transactionType)
Starts a new transaction on this connection.void
clear()
Clears the content of this data store -- that is, it clears all data and rules so the logical state of the data store is the same as after initialisation.void
clearFactsKeepRulesAxioms()
Clears all facts, while keeping all the currently loaded rules and axioms.void
clearRulesAxiomsExplicateFacts()
Clears all rules and turns all facts in the data store into EDB facts.void
close()
Closes the data store connection by freeing all resources associated with it.void
commit()
Deprecated.void
commitTransaction()
Commits the transaction associated with this connection.void
compact()
Compact the data in the data store.boolean
containsDataSource(java.lang.String dataSourceName)
Checks whether the data store contains a data source with the specified name.boolean
containsDataSourceTable(java.lang.String dataSourceName, java.lang.String dataSourceTableName)
Checks whether the specified data source in the data store contains a data source table with the specified name.boolean
containsStatistics(java.lang.String statisticsName)
Checks whether the data store contains the statistics with the specified name.boolean
containsTupleTable(java.lang.String tupleTableName)
Checks whether the data store contains a tuple table with the specified name.Cursor
createCursor(tech.oxfordsemantic.jrdfox.logic.sparql.statement.Query query, java.util.Map<java.lang.String,java.lang.String> compilationParameters)
Creates a cursor over the results of the given query.Cursor
createCursor(Prefixes prefixes, java.lang.String queryText, java.util.Map<java.lang.String,java.lang.String> compilationParameters)
Creates a cursor over the results of the given query.void
createDataSource(java.lang.String dataSourceName, java.lang.String dataSourceTypeName, java.util.Map<java.lang.String,java.lang.String> dataSourceParameters)
Creates a data source in a data store.void
createStatistics(java.lang.String statisticsName, java.util.Map<java.lang.String,java.lang.String> statisticsParameters)
Creates the statistics in a data store.void
createTupleTable(java.lang.String tupleTableName, java.util.Map<java.lang.String,java.lang.String> tupleTableParameters)
Creates a tuple table in a data store.void
deleteDataSource(java.lang.String dataSourceName)
Deletes the data source table with the specified name from the data store.long
deleteRule(tech.oxfordsemantic.jrdfox.logic.datalog.Rule rule)
Deletes a rule to the data store.long
deleteRules(java.util.Collection<tech.oxfordsemantic.jrdfox.logic.datalog.Rule> datalogProgram)
Deletes a collection of rules to the data store.void
deleteStatistics(java.lang.String statisticsName)
Deletes the data store statistics with the specified name from the data store.void
deleteTupleTable(java.lang.String tupleTableName)
Deletes the tuple table with the specified name from the data store.DataSourceInfo
describeDataSource(java.lang.String dataSourceName)
Returns information about the data source with the given name.DataSourceTableInfo
describeDataSourceTable(java.lang.String dataSourceName, java.lang.String dataSourceTableName)
Returns information about the data source table of the specified data source in the data store.StatisticsInfo
describeStatistics(java.lang.String statisticsName)
Returns information about the specific statistics of the data store.TupleTableInfo
describeTupleTable(java.lang.String tupleTableName)
Returns information about the tuple table with the given name.DataStoreConnection
duplicate()
Creates a new connection to the same data store.StatementResult
evaluateQuery(tech.oxfordsemantic.jrdfox.logic.sparql.statement.Query query, java.util.Map<java.lang.String,java.lang.String> compilationParameters, QueryAnswerMonitor queryAnswerMonitor)
Evaluates a query and calls the suppliedQueryAnswerMonitor
instance for each tuple in the result.StatementResult
evaluateQuery(Prefixes prefixes, java.lang.String queryText, java.util.Map<java.lang.String,java.lang.String> compilationParameters, QueryAnswerMonitor queryAnswerMonitor)
Evaluates a query and calls the suppliedQueryAnswerMonitor
instance for each tuple in the result.StatementResult
evaluateStatement(Prefixes prefixes, java.lang.String statementText, java.util.Map<java.lang.String,java.lang.String> compilationParameters, java.io.File file, java.lang.String queryAnswerFormatName)
Evaluates a statement and serialises the result to the supplied file using the specified format.StatementResult
evaluateStatement(Prefixes prefixes, java.lang.String statementText, java.util.Map<java.lang.String,java.lang.String> compilationParameters, java.io.OutputStream outputStream, java.lang.String queryAnswerFormatName)
Evaluates a statement and serialises the result to the supplied output stream using the specified format.StatementResult
evaluateStatement(Prefixes prefixes, tech.oxfordsemantic.jrdfox.logic.sparql.statement.Query statement, java.util.Map<java.lang.String,java.lang.String> compilationParameters, java.io.File file, java.lang.String queryAnswerFormatName)
Evaluates a statement and serialises the result to the supplied file using the specified format.StatementResult
evaluateStatement(Prefixes prefixes, tech.oxfordsemantic.jrdfox.logic.sparql.statement.Query statement, java.util.Map<java.lang.String,java.lang.String> compilationParameters, java.io.OutputStream outputStream, java.lang.String queryAnswerFormatName)
Evaluates a statement and serialises the result to the supplied output stream using the specified format.StatementResult
evaluateUpdate(tech.oxfordsemantic.jrdfox.logic.sparql.statement.Update update, java.util.Map<java.lang.String,java.lang.String> compilationParameters)
Evaluates an update.StatementResult
evaluateUpdate(Prefixes prefixes, java.lang.String updateText, java.util.Map<java.lang.String,java.lang.String> compilationParameters)
Evaluates an update.void
exportData(Prefixes prefixes, java.io.File file, java.lang.String formatName, java.util.Map<java.lang.String,java.lang.String> parameters)
Exports the data in the data store using the given format.void
exportData(Prefixes prefixes, java.io.OutputStream outputStream, java.lang.String formatName, java.util.Map<java.lang.String,java.lang.String> parameters)
Exports the data in the data store using the given format.ComponentInfo
getComponentInfo(boolean extended)
Returns diagnostic information about the data store as a tree of objects each providing detailed information about the data store.ResourceValue[][]
getDataSourceTableData(java.lang.String dataSourceName, java.lang.String dataSourceTableName, int numberOfRows)
Returns a sample of the data from the specified data source table.long
getDictionaryGenerationCounter()
Returns the generation counter of the data store dictionary, which is an number that is incremented every time the data store dictionary is cleared.long
getEndResourceID()
Returns the one plus the maximum resource ID that can be stored in tuple tables of this data store.EqualityAxiomatization
getEqualityAxiomatization()
Returns a flag that determines how the data store deals with equality reasoning.long
getGenerationCounter()
Returns the generation counter of the data store, which is an number that is incremented every time the data store is updated.int
getID()
Returns an integer that uniquely identifies the data store within the server.long
getLockTimeout()
Returns the time in milliseconds that the system will wait for when it needs to acquire a lock on a data store.java.lang.String
getName()
Returns the name of the data store inside the server.OWLSupportMonitor
getOWLSupportMonitor()
Returns the callback interface that is currently registered to receive callback notifications during the conversion of loaded RDF triples into OWL axioms, or during the conversion of OWL axioms into rules.java.util.Map<java.lang.String,java.lang.String>
getParameters()
Returns the parameters that the data store was created with.tech.oxfordsemantic.jrdfox.logic.expression.Resource
getResource(long resourceID)
Looks up the resource with the given IDs.boolean
getResources(long[] resourceIDs, int startIndex, int endIndex, tech.oxfordsemantic.jrdfox.logic.expression.Resource[] resources)
Looks up the resources with the given IDs.ResourceValue
getResourceValue(long resourceID)
Looks up the resource with the given ID.boolean
getResourceValues(long[] resourceIDs, int startIndex, int endIndex, ResourceValue[] resourceValues)
Looks up the resources with the given IDs.java.lang.String
getRoleName()
Returns the name of the role currently associated with this connection.TransactionState
getTransactionState()
Returns the state of the transaction associated with this connection.java.lang.String
getTypeName()
Returns the type of the data store.java.lang.String
getUniqueID()
Returns a string that uniquely identifies the data store.ImportResult
importData(UpdateType updateType, Prefixes prefixes, java.io.File file)
Imports the data from the given file into the current data store.ImportResult
importData(UpdateType updateType, Prefixes prefixes, java.io.InputStream inputStream)
Imports the data from the given input stream into the current data store.ImportResult
importData(UpdateType updateType, Prefixes prefixes, java.lang.String content)
Imports the data from the given string into the current data store.ImportResult
importData(UpdateType updateType, Prefixes prefixes, java.util.Collection<InputSourceFactory> inputSourceFactories, java.lang.String formatName, ImportNotificationMonitor importNotificationMonitor)
Imports the data described by the given input source factories into the current data store.ImportResult
importData(UpdateType updateType, Prefixes prefixes, InputSourceFactory inputSourceFactory, java.lang.String formatName, ImportNotificationMonitor importNotificationMonitor)
Imports the data described by the given input source factory into the current data store.void
interrupt()
Tries to interrupt an operation that is running in parallel on this connection.boolean
isConcurrent()
Returnstrue
if the data store supports concurrent access.boolean
isPersistent()
Returnstrue
if the data store is persistent.java.util.List<DataSourceInfo>
listDataSources()
Returns information about the data sources currently present in the data store.java.util.List<DataSourceTableInfo>
listDataSourceTables(java.lang.String dataSourceName)
Returns information about the data source tables of the specified data source in the data store.java.util.List<RuleInfo>
listRules()
Returns the information about the rules currently loaded into the data store.java.util.List<StatisticsInfo>
listStatistics()
Returns information about all statistics currently managed by the data store.java.util.List<TupleTableInfo>
listTupleTables()
Returns information about the tuple tables currently present in the data store.void
recompileRules()
Recompiles the rules using the currently available statistics.boolean
requiresIncrementalReasoning()
Returnstrue
if the next data store update must be performed using incremental reasoning (rather than standard using the standard datalog materialization "from scratch" algorithm).void
rollback()
Deprecated.void
rollbackTransaction()
Rolls back the transaction associated with this connection.void
saveToBinaryFormat(java.io.File file, BinaryDataStoreFormat format)
Saves the data store into the specified binary format.void
saveToBinaryFormat(java.io.OutputStream outputStream, BinaryDataStoreFormat format)
Saves the data store into the specified binary format.void
setLockTimeout(long timeout)
Sets the time in milliseconds that the system will wait for when it needs to acquire a lock on a data store.void
setOWLSupportMonitor(OWLSupportMonitor owlSupportMonitor)
Sets the callback interface that will be called for each error encountered during the conversion of loaded RDF triples into OWL axioms, or during the conversion of OWL axioms into rules.void
switchRole(java.lang.String roleName, java.lang.String password)
Changes the identity of the user associated with this connection.boolean
transactionRequiresRollback()
Returnstrue
if a transaction is active on this connection and this transaction must be rolled back (i.e., it cannot be committed).void
updateMaterialization()
Updates the materialization so that all and only the consequences of the explicitly stated facts and the rules are derived.void
updateStatistics()
Updates all statistics that the data store uses to plan queries and rules.void
updateStatistics(java.lang.String statisticsName)
Updates the statistics with the given name that the data store uses to plan queries and rules.
-
Field Details
-
WAIT_FOREVER
static final long WAIT_FOREVERSpecifies that the system should wait forever when it needs to acquire a lock on a data store (seesetLockTimeout(long)
).- See Also:
- Constant Field Values
-
-
Method Details
-
close
void close()Closes the data store connection by freeing all resources associated with it. Once a connection is closed, it cannot be used any further. Calling this method in parallel with any other method runs a very high risk of crashing the JVM.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
getLockTimeout
Returns the time in milliseconds that the system will wait for when it needs to acquire a lock on a data store. SeesetLockTimeout(long)
for more detail.- Returns:
- the current timeout value
- Throws:
JRDFoxException
- thrown if an error is encountered
-
setLockTimeout
Sets the time in milliseconds that the system will wait for when it needs to acquire a lock on a data store. The value ofWAIT_FOREVER
specifies that the system should wait indefinitely. When successful completion of an operation (e.g., adding data to a data store) requires locking a store and the lock cannot be acquired within the timeout period, aLockTimeoutException
is thrown.- Parameters:
timeout
- the new timeout value- Throws:
JRDFoxException
- thrown if an error is encountered
-
setOWLSupportMonitor
Sets the callback interface that will be called for each error encountered during the conversion of loaded RDF triples into OWL axioms, or during the conversion of OWL axioms into rules.- Parameters:
owlSupportMonitor
- the object that receives callback notifications- Throws:
JRDFoxException
- thrown if an error is encountered
-
getOWLSupportMonitor
Returns the callback interface that is currently registered to receive callback notifications during the conversion of loaded RDF triples into OWL axioms, or during the conversion of OWL axioms into rules.- Returns:
- the currently registered object that receives callback notifications
- Throws:
JRDFoxException
- thrown if an error is encountered
-
duplicate
Creates a new connection to the same data store. The new connection inherits the role name and the lock timeout from this one. Regardless of whether a transaction is active on this connection, the new connection will not have an active transaction. The main use of this method is to avoid having to specify the user credentials again. This method can be called concurrently with any other method apart fromclose()
.- Returns:
- a new connection to the same data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
interrupt
Tries to interrupt an operation that is running in parallel on this connection. RDFox will make a best effort to interrupt an operation, but there are no guarantees that the operation will indeed be interrupted. An operation will throw anOperationInterruptedException
exception. This method can be called concurrently with any other method apart fromclose()
.- Throws:
JRDFoxException
- thrown if an error is encountered
-
getRoleName
Returns the name of the role currently associated with this connection.- Returns:
- the name of the role currently associated with this connection
- Throws:
JRDFoxException
- thrown if there is an error
-
switchRole
Changes the identity of the user associated with this connection. The new user is reauthenticated, and if that succeeds, all subsequent actions on this connection will be made under the identity of the new user. This method can be called at any point in time, even if a transaction is associated with the connection. If a transaction is subsequently rolled back, the new user remains associated with the connection -- that is, the user identity is not rolled back as well.- Parameters:
roleName
- the new role namepassword
- the password of the new user- Throws:
JRDFoxException
- thrown if there is an error
-
getName
Returns the name of the data store inside the server.- Returns:
- the name of the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getID
Returns an integer that uniquely identifies the data store within the server. This number will be as low as possible, thus allowing for easy indexing of data stores using arrays. When a data store is deleted and a new data store is created, the same ID can be assigned to the new data store.- Returns:
- an integer that uniquely identifies this data store within the server
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getUniqueID
Returns a string that uniquely identifies the data store. Each time a data store is created, a fresh random string is associated to the data store. This string aims to be unique across servers and data stores.- Returns:
- a string that uniquely identifies this data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getTypeName
Returns the type of the data store.- Returns:
- the type of the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getParameters
Returns the parameters that the data store was created with.- Returns:
- the parameters of the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getEndResourceID
Returns the one plus the maximum resource ID that can be stored in tuple tables of this data store. In some data stores this number can be larger than 263 - 1, in which case this method returns 263 - 1 (i.e., the maximum signed long integer).- Returns:
- the maximum resource ID that can be stored in tuple tables of this data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
isConcurrent
Returnstrue
if the data store supports concurrent access. If not, then all access to the data store will be serialised.- Returns:
true
if the data store supports concurrent access- Throws:
JRDFoxException
- thrown if an error is encountered
-
isPersistent
Returnstrue
if the data store is persistent.- Returns:
true
if the data store is persistent- Throws:
JRDFoxException
- thrown if an error is encountered
-
getEqualityAxiomatization
Returns a flag that determines how the data store deals with equality reasoning.- Returns:
- determines the way in which equality is handled by the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getGenerationCounter
Returns the generation counter of the data store, which is an number that is incremented every time the data store is updated. Hence, by recording the value of this counter and checking it later again, clients can detect whether the store has been changed in between.- Returns:
- the generation counter of the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getComponentInfo
Returns diagnostic information about the data store as a tree of objects each providing detailed information about the data store. Note: This information should be used for diagnostics purposes only. The content ofComponentInfo
is subject to change in future version. Callers should not rely on named property or a specific subcomponent being present.- Parameters:
extended
- iftrue
, returns extensive information about various subcomponents about the data store (mainly used for troubleshooting)- Returns:
- information about the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
listTupleTables
Returns information about the tuple tables currently present in the data store.- Returns:
- information about the tuple tables currently present in the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
containsTupleTable
Checks whether the data store contains a tuple table with the specified name.- Parameters:
tupleTableName
- the name of the tuple table to be checked- Returns:
true
if the data store contains a tuple table with the given name- Throws:
JRDFoxException
- thrown if an error is encountered
-
createTupleTable
void createTupleTable(java.lang.String tupleTableName, java.util.Map<java.lang.String,java.lang.String> tupleTableParameters) throws JRDFoxExceptionCreates a tuple table in a data store. The type of the tuple table is described by the supplied parameters. By using appropriate parameters, this method can be used to mount a tuple table from a data source. This operation can be invoked only if no transaction is active on the connection.- Parameters:
tupleTableName
- the name of the tuple table to be createdtupleTableParameters
- the key-value pairs that describe the tuple table to be created- Throws:
JRDFoxException
- thrown if an error is encountered
-
deleteTupleTable
Deletes the tuple table with the specified name from the data store. A tuple table can be deleted only if it is not used in the body or head of any rule currently loaded in the data store. This operation can be invoked only if no transaction is active on the connection.- Parameters:
tupleTableName
- the name of the tuple table to be deleted- Throws:
JRDFoxException
- thrown if an error is encountered
-
describeTupleTable
Returns information about the tuple table with the given name.- Parameters:
tupleTableName
- the name of the tuple table whose information is to be returned- Returns:
- information about the tuple table
- Throws:
JRDFoxException
- thrown if an error is encountered
-
listDataSources
Returns information about the data sources currently present in the data store.- Returns:
- information about the tuple tables currently present in the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
containsDataSource
Checks whether the data store contains a data source with the specified name.- Parameters:
dataSourceName
- the name of the data source to be checked- Returns:
true
if the data store contains a data source with the given name- Throws:
JRDFoxException
- thrown if an error is encountered
-
createDataSource
void createDataSource(java.lang.String dataSourceName, java.lang.String dataSourceTypeName, java.util.Map<java.lang.String,java.lang.String> dataSourceParameters) throws JRDFoxExceptionCreates a data source in a data store. The new data source will have the specified type and is described using the supplied key-value pairs. This operation can be invoked only if no transaction is active on the connection.- Parameters:
dataSourceName
- the name of the data source to be createddataSourceTypeName
- the type of the data sourcedataSourceParameters
- the key-value pairs that describe the data source to be created- Throws:
JRDFoxException
- thrown if an error is encountered
-
deleteDataSource
Deletes the data source table with the specified name from the data store. This operation can be invoked only if no transaction is active on the connection.- Parameters:
dataSourceName
- the name of the data source to be deleted- Throws:
JRDFoxException
- thrown if an error is encountered
-
describeDataSource
Returns information about the data source with the given name.- Parameters:
dataSourceName
- the name of the data source whose information is to be returned- Returns:
- information about the data source
- Throws:
JRDFoxException
- thrown if an error is encountered
-
listDataSourceTables
java.util.List<DataSourceTableInfo> listDataSourceTables(java.lang.String dataSourceName) throws JRDFoxExceptionReturns information about the data source tables of the specified data source in the data store.- Parameters:
dataSourceName
- the name of the data source whose tables are to be listed- Returns:
- information about the data source tables of the specified data source
- Throws:
JRDFoxException
- thrown if an error is encountered
-
containsDataSourceTable
boolean containsDataSourceTable(java.lang.String dataSourceName, java.lang.String dataSourceTableName) throws JRDFoxExceptionChecks whether the specified data source in the data store contains a data source table with the specified name.- Parameters:
dataSourceName
- the name of the data sourcedataSourceTableName
- the name of the data source table- Returns:
true
if the specified data source contains the specified data source table- Throws:
JRDFoxException
- thrown if an error is encountered
-
describeDataSourceTable
DataSourceTableInfo describeDataSourceTable(java.lang.String dataSourceName, java.lang.String dataSourceTableName) throws JRDFoxExceptionReturns information about the data source table of the specified data source in the data store.- Parameters:
dataSourceName
- the name of the data sourcedataSourceTableName
- the name of the data source table- Returns:
- information about the data source table
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getDataSourceTableData
ResourceValue[][] getDataSourceTableData(java.lang.String dataSourceName, java.lang.String dataSourceTableName, int numberOfRows) throws JRDFoxExceptionReturns a sample of the data from the specified data source table. This method is not designed for efficient importation of data from a data source. Rather, its main purpose is to allow applications to view the data in the source before mounting an appropriate tuple table.- Parameters:
dataSourceName
- the name of the data sourcedataSourceTableName
- the name of the data source tablenumberOfRows
- the maximum number of rows to be returned- Returns:
- a sample of the data from the data source table
- Throws:
JRDFoxException
- thrown if an error is encountered
-
listStatistics
Returns information about all statistics currently managed by the data store.- Returns:
- information about all statistics that the data store currently manages
- Throws:
JRDFoxException
- thrown if an error is encountered
-
containsStatistics
Checks whether the data store contains the statistics with the specified name.- Parameters:
statisticsName
- the name of the statistics- Returns:
true
if the data store contains the specified statistics- Throws:
JRDFoxException
- thrown if an error is encountered
-
createStatistics
void createStatistics(java.lang.String statisticsName, java.util.Map<java.lang.String,java.lang.String> statisticsParameters) throws JRDFoxExceptionCreates the statistics in a data store. The name of the statistics determines their type; thus, a data store can contain at most one statistics of a particular type, and the type corresponds to the statistics name. The way in which the statistics are gathered is influenced by the the supplied key-value pairs. This operation can be invoked only if no transaction is active on the connection.- Parameters:
statisticsName
- the name of the data source to be createdstatisticsParameters
- the key-value pairs that describe the statistics to be created- Throws:
JRDFoxException
- thrown if an error is encountered
-
deleteStatistics
Deletes the data store statistics with the specified name from the data store. This operation can be invoked only if no transaction is active on the connection.- Parameters:
statisticsName
- the name of the data store statistics to be deleted- Throws:
JRDFoxException
- thrown if an error is encountered
-
describeStatistics
Returns information about the specific statistics of the data store.- Parameters:
statisticsName
- the name of the statistics whose information should be returned- Returns:
- information about the statistics
- Throws:
JRDFoxException
- thrown if an error is encountered
-
updateStatistics
Updates all statistics that the data store uses to plan queries and rules. This operation should be invoked after large additions to the data store, or after a large number of facts has been derived. This operation can be invoked if either no transaction is active, or a read/write transaction is active. In the latter case, rolling back a transaction does not restore the statistics to their original state.- Throws:
JRDFoxException
- thrown if an error is encountered
-
updateStatistics
Updates the statistics with the given name that the data store uses to plan queries and rules. This operation should be invoked after large additions to the data store, or after a large number of facts has been derived. This operation can be invoked if either no transaction is active, or a read/write transaction is active. In the latter case, rolling back a transaction does not restore the statistics to their original state.- Parameters:
statisticsName
- the name of the statistics that should be updated- Throws:
JRDFoxException
- thrown if an error is encountered
-
getTransactionState
Returns the state of the transaction associated with this connection.- Returns:
- the state of the transaction
- Throws:
JRDFoxException
- thrown if an error is encountered
-
transactionRequiresRollback
Returnstrue
if a transaction is active on this connection and this transaction must be rolled back (i.e., it cannot be committed). This happens when certain operations invoked in a transaction result in an error.- Returns:
true
if the currently active transaction must be committed- Throws:
JRDFoxException
- thrown if an error is encountered
-
beginTransaction
Starts a new transaction on this connection.- Parameters:
transactionType
- determines the type of the transaction (i.e., whether a read-only or a read/write transaction is requested)- Throws:
JRDFoxException
- thrown if an error is encountered
-
commitTransaction
Commits the transaction associated with this connection. If an exception is thrown during a commit operation,transactionRequiresRollback()
will returntrue
, and the transaction should be explicitly rolled back usingrollbackTransaction()
.- Throws:
JRDFoxException
- thrown if an error is encountered
-
rollbackTransaction
Rolls back the transaction associated with this connection.- Throws:
JRDFoxException
- thrown if an error is encountered
-
clear
Clears the content of this data store -- that is, it clears all data and rules so the logical state of the data store is the same as after initialisation. This operation, however, does not clear the data store dictionary, so clients that have cached any resource IDs can still use them. This operation can be called inside a transaction, but, depending on the circumstances,requiresIncrementalReasoning()
can subsequently returntrue
, — that is, subsequent materialization will not be performed using the standard "from scratch" algorithm, which can affect efficiency. In contrast, if this operation is performed outside a transaction, then subsequent materialization will necessarily be performed using the standard "from scratch" algorithm.- Throws:
JRDFoxException
- thrown if an error is encountered
-
clearFactsKeepRulesAxioms
Clears all facts, while keeping all the currently loaded rules and axioms. After this operation, the data store is in the same state as if all rules and used-defined axioms have been imported from a file. This operation can be invoked only if no transaction is active.- Throws:
JRDFoxException
- thrown if an error is encountered
-
clearRulesAxiomsExplicateFacts
Clears all rules and turns all facts in the data store into EDB facts. After this operation, the data store is in the same state as if all derived facts have been imported from a file. This operation can be invoked only if no transaction is active.- Throws:
JRDFoxException
- thrown if an error is encountered
-
compact
Compact the data in the data store. This involves removing all deleted triples, and possibly sorting the data in order to facilitate faster access. This may result in reduced memory usage and/or disk usage for persisted data stores. This operation can be invoked only if no transaction is active.- Throws:
JRDFoxException
- thrown if an error is encountered
-
exportData
void exportData(Prefixes prefixes, java.io.OutputStream outputStream, java.lang.String formatName, java.util.Map<java.lang.String,java.lang.String> parameters) throws JRDFoxExceptionExports the data in the data store using the given format. The format determines which subset of the store data is to be exported; for example, the Turtle format can store triples, but not facts in other tuple tables or the rules.- Parameters:
prefixes
- the prefixes used to abbreviate IRIs in the output (provided that the output format supports IRI abbreviation)outputStream
- receives the exported dataformatName
- the name of the output formatparameters
- key-value pairs that, depending on the format, customise the export process- Throws:
JRDFoxException
- thrown if an error is encountered
-
exportData
void exportData(Prefixes prefixes, java.io.File file, java.lang.String formatName, java.util.Map<java.lang.String,java.lang.String> parameters) throws JRDFoxExceptionExports the data in the data store using the given format. The format determines which subset of the store data is to be exported; for example, the Turtle format can store triples, but not facts in other tuple tables or the rules. This operation can be invoked either with no active transaction or in a read-only transaction.- Parameters:
prefixes
- the prefixes used to abbreviate IRIs in the output (provided that the output format supports IRI abbreviation)file
- receives the exported dataformatName
- the name of the output formatparameters
- key-value pairs that, depending on the format, customise the export process- Throws:
JRDFoxException
- thrown if an error is encountered
-
importData
ImportResult importData(UpdateType updateType, Prefixes prefixes, InputSourceFactory inputSourceFactory, java.lang.String formatName, ImportNotificationMonitor importNotificationMonitor) throws JRDFoxExceptionImports the data described by the given input source factory into the current data store.- Parameters:
updateType
- specifies whether the imported data should be added or removed from the data storeprefixes
- used for expanding abbreviated IRIs in the inputinputSourceFactory
- the content being importedformatName
- the name of the format of the dataimportNotificationMonitor
- receives errors/warnings encountered during import- Returns:
- provides information about the importation process
- Throws:
JRDFoxException
- thrown if an error is encountered
-
importData
ImportResult importData(UpdateType updateType, Prefixes prefixes, java.util.Collection<InputSourceFactory> inputSourceFactories, java.lang.String formatName, ImportNotificationMonitor importNotificationMonitor) throws JRDFoxExceptionImports the data described by the given input source factories into the current data store. If this server is configured to use more than one thread, then sources are parsed and imported in parallel.- Parameters:
updateType
- specifies whether the imported data should be added or removed from the data storeprefixes
- used for expanding abbreviated IRIs in the inputinputSourceFactories
- the content being importedformatName
- the name of the format of the dataimportNotificationMonitor
- receives errors/warnings encountered during import- Returns:
- provides information about the importation process
- Throws:
JRDFoxException
- thrown if an error is encountered
-
importData
ImportResult importData(UpdateType updateType, Prefixes prefixes, java.io.File file) throws JRDFoxExceptionImports the data from the given file into the current data store.- Parameters:
updateType
- specifies whether the imported data should be added or removed from the data storeprefixes
- used for expanding abbreviated IRIs in the inputfile
- the content being imported- Returns:
- provides information about the importation process
- Throws:
JRDFoxException
- thrown if an error is encountered
-
importData
ImportResult importData(UpdateType updateType, Prefixes prefixes, java.lang.String content) throws JRDFoxExceptionImports the data from the given string into the current data store.- Parameters:
updateType
- specifies whether the imported data should be added or removed from the data storeprefixes
- used for expanding abbreviated IRIs in the inputcontent
- the content being imported- Returns:
- provides information about the importation process
- Throws:
JRDFoxException
- thrown if an error is encountered
-
importData
ImportResult importData(UpdateType updateType, Prefixes prefixes, java.io.InputStream inputStream) throws JRDFoxExceptionImports the data from the given input stream into the current data store.- Parameters:
updateType
- specifies whether the imported data should be added or removed from the data storeprefixes
- used for expanding abbreviated IRIs in the inputinputStream
- the content being imported- Returns:
- provides information about the importation process
- Throws:
JRDFoxException
- thrown if an error is encountered
-
listRules
Returns the information about the rules currently loaded into the data store.- Returns:
- information about the rules currently loaded into the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
addRule
Adds a rule to the data store.- Parameters:
rule
- the rule to be added- Returns:
- the number of rules that were changed
- Throws:
JRDFoxException
- thrown if an error is encountered
-
addRules
long addRules(java.util.Collection<tech.oxfordsemantic.jrdfox.logic.datalog.Rule> datalogProgram) throws JRDFoxExceptionAdds a collection of rules to the data store.- Parameters:
datalogProgram
- the rules to be added- Returns:
- the number of rules that were changed
- Throws:
JRDFoxException
- thrown if an error is encountered
-
deleteRule
Deletes a rule to the data store.- Parameters:
rule
- the rule to be deleted- Returns:
- the number of rules that were changed
- Throws:
JRDFoxException
- thrown if an error is encountered
-
deleteRules
long deleteRules(java.util.Collection<tech.oxfordsemantic.jrdfox.logic.datalog.Rule> datalogProgram) throws JRDFoxExceptionDeletes a collection of rules to the data store.- Parameters:
datalogProgram
- the rules to be deleted- Returns:
- the number of rules that were changed
- Throws:
JRDFoxException
- thrown if an error is encountered
-
recompileRules
Recompiles the rules using the currently available statistics. This method should be called after bulk updates to a data store in order to ensure that the rules are evaluated using efficient query plans. TThis operation can be invoked if either no transaction is active, or a read/write transaction is active.- Throws:
JRDFoxException
- thrown if an error is encountered
-
requiresIncrementalReasoning
Returnstrue
if the next data store update must be performed using incremental reasoning (rather than standard using the standard datalog materialization "from scratch" algorithm).- Returns:
true
if the next data store update must be performed using incremental reasoning- Throws:
JRDFoxException
- thrown if an error is encountered
-
updateMaterialization
Updates the materialization so that all and only the consequences of the explicitly stated facts and the rules are derived. This operation is automatically applied internally so that all queries are always evaluated with respect to the updated materialization. However, requesting an update explicitly can be beneficial in some cases (e.g., when benchmarking reasoning algorithms). This operation can be invoked only if a read/write transaction is active.- Throws:
JRDFoxException
- thrown if an error is encountered
-
createCursor
Cursor createCursor(Prefixes prefixes, java.lang.String queryText, java.util.Map<java.lang.String,java.lang.String> compilationParameters) throws JRDFoxExceptionCreates a cursor over the results of the given query. If this connection has no active transaction, the cursor is "frozen" -- that is, its content will not reflect any changes made to the data. If this connection has an active transaction, the cursor is "live" -- that is, it produces answers as they are being retrieved. Live cursors are thus more efficient since they do not require storing entire query result. If a transaction is committed but a live cursor is kept open, the cursor's behaviour is unspecified.- Parameters:
prefixes
- used to expand IRIs in the queryqueryText
- the query to be evaluatedcompilationParameters
- the key-value pairs guiding query compilation- Returns:
- the cursor with the query results
- Throws:
JRDFoxException
- thrown if an error is encountered
-
createCursor
Cursor createCursor(tech.oxfordsemantic.jrdfox.logic.sparql.statement.Query query, java.util.Map<java.lang.String,java.lang.String> compilationParameters) throws JRDFoxExceptionCreates a cursor over the results of the given query. If this connection has no active transaction, the cursor is "frozen" -- that is, its content will not reflect any changes made to the data. If this connection has an active transaction, the cursor is "live" -- that is, it produces answers as they are being retrieved. Live cursors are thus more efficient since they do not require storing entire query result. If a transaction is committed but a live cursor is kept open, the cursor's behaviour is unspecified.- Parameters:
query
- the query to be evaluatedcompilationParameters
- the key-value pairs guiding query compilation- Returns:
- the cursor with the query results
- Throws:
JRDFoxException
- thrown if an error is encountered
-
evaluateQuery
StatementResult evaluateQuery(Prefixes prefixes, java.lang.String queryText, java.util.Map<java.lang.String,java.lang.String> compilationParameters, QueryAnswerMonitor queryAnswerMonitor) throws JRDFoxExceptionEvaluates a query and calls the suppliedQueryAnswerMonitor
instance for each tuple in the result.- Parameters:
prefixes
- used to expand IRIs in the queryqueryText
- the query to be evaluatedcompilationParameters
- the key-value pairs guiding query compilationqueryAnswerMonitor
- an interface containing a callback method that is called for each tuple in the result- Returns:
- provides information about the number of results produced
- Throws:
JRDFoxException
- thrown if an error is encountered
-
evaluateQuery
StatementResult evaluateQuery(tech.oxfordsemantic.jrdfox.logic.sparql.statement.Query query, java.util.Map<java.lang.String,java.lang.String> compilationParameters, QueryAnswerMonitor queryAnswerMonitor) throws JRDFoxExceptionEvaluates a query and calls the suppliedQueryAnswerMonitor
instance for each tuple in the result.- Parameters:
query
- the query to be evaluatedcompilationParameters
- the key-value pairs guiding query compilationqueryAnswerMonitor
- an interface containing a callback method that is called for each tuple in the result- Returns:
- provides information about the number of results produced
- Throws:
JRDFoxException
- thrown if an error is encountered
-
evaluateUpdate
StatementResult evaluateUpdate(Prefixes prefixes, java.lang.String updateText, java.util.Map<java.lang.String,java.lang.String> compilationParameters) throws JRDFoxExceptionEvaluates an update. This operation can be called only if a read/write transaction is active.- Parameters:
prefixes
- used to expand IRIs in the queryupdateText
- the update to be evaluatedcompilationParameters
- the key-value pairs guiding statement compilation- Returns:
- provides information about the number of results produced
- Throws:
JRDFoxException
- thrown if an error is encountered
-
evaluateUpdate
StatementResult evaluateUpdate(tech.oxfordsemantic.jrdfox.logic.sparql.statement.Update update, java.util.Map<java.lang.String,java.lang.String> compilationParameters) throws JRDFoxExceptionEvaluates an update. This operation can be called only if a read/write transaction is active.- Parameters:
update
- the update to be evaluatedcompilationParameters
- the key-value pairs guiding statement compilation- Returns:
- provides information about the number of results produced
- Throws:
JRDFoxException
- thrown if an error is encountered
-
evaluateStatement
StatementResult evaluateStatement(Prefixes prefixes, java.lang.String statementText, java.util.Map<java.lang.String,java.lang.String> compilationParameters, java.io.OutputStream outputStream, java.lang.String queryAnswerFormatName) throws JRDFoxExceptionEvaluates a statement and serialises the result to the supplied output stream using the specified format.- Parameters:
prefixes
- used to expand IRIs in the statement and to abbreviate IRIs in the outputstatementText
- the statement to be evaluatedcompilationParameters
- the key-value pairs guiding statement compilationoutputStream
- receives the statement resultqueryAnswerFormatName
- specifies the name of the answer format in case of a query- Returns:
- provides information about the number of results produced
- Throws:
JRDFoxException
- thrown if an error is encountered
-
evaluateStatement
StatementResult evaluateStatement(Prefixes prefixes, tech.oxfordsemantic.jrdfox.logic.sparql.statement.Query statement, java.util.Map<java.lang.String,java.lang.String> compilationParameters, java.io.OutputStream outputStream, java.lang.String queryAnswerFormatName) throws JRDFoxExceptionEvaluates a statement and serialises the result to the supplied output stream using the specified format.- Parameters:
prefixes
- used to abbreviate IRIs in the outputstatement
- the statement to be evaluatedcompilationParameters
- the key-value pairs guiding statement compilationoutputStream
- receives the query resultqueryAnswerFormatName
- specifies the name of the answer format in case of a query- Returns:
- provides information about the number of results produced
- Throws:
JRDFoxException
- thrown if an error is encountered
-
evaluateStatement
StatementResult evaluateStatement(Prefixes prefixes, java.lang.String statementText, java.util.Map<java.lang.String,java.lang.String> compilationParameters, java.io.File file, java.lang.String queryAnswerFormatName) throws JRDFoxExceptionEvaluates a statement and serialises the result to the supplied file using the specified format.- Parameters:
prefixes
- used to expand IRIs in the statement and to abbreviate IRIs in the outputstatementText
- the statement to be evaluatedcompilationParameters
- the key-value pairs guiding statement compilationfile
- receives the query resultqueryAnswerFormatName
- specifies the name of the answer format in case of a query- Returns:
- provides information about the number of results produced
- Throws:
JRDFoxException
- thrown if an error is encountered
-
evaluateStatement
StatementResult evaluateStatement(Prefixes prefixes, tech.oxfordsemantic.jrdfox.logic.sparql.statement.Query statement, java.util.Map<java.lang.String,java.lang.String> compilationParameters, java.io.File file, java.lang.String queryAnswerFormatName) throws JRDFoxExceptionEvaluates a statement and serialises the result to the supplied file using the specified format.- Parameters:
prefixes
- used to abbreviate IRIs in the outputstatement
- the statement to be evaluatedcompilationParameters
- the key-value pairs guiding statement compilationfile
- receives the query resultqueryAnswerFormatName
- specifies the name of the answer format in case of a query- Returns:
- provides information about the number of results produced
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getDictionaryGenerationCounter
Returns the generation counter of the data store dictionary, which is an number that is incremented every time the data store dictionary is cleared. By recording the value of this counter and checking it later again, clients can detect whether the resource IDs resolved earlier are still valid.- Returns:
- the generation counter of the data store
- Throws:
JRDFoxException
- thrown if an error is encountered
-
getResourceValue
Looks up the resource with the given ID.- Parameters:
resourceID
- the resource ID that should be looked up- Returns:
- the resource term, or
null
if the resource ID cannot be looked up - Throws:
JRDFoxException
- thrown if an error is encountered
-
getResourceValues
boolean getResourceValues(long[] resourceIDs, int startIndex, int endIndex, ResourceValue[] resourceValues) throws JRDFoxExceptionLooks up the resources with the given IDs. The length of theresourceValues
array must be at leastendIndex
so that each resource ID at some index inresourceIDs
can be resolved to a resource at the same position inresources
.- Parameters:
resourceIDs
- the resource IDs that should be looked upstartIndex
- the first index inresourceIDs
to look upendIndex
- the index after the last inresourceIDs
to look upresourceValues
- receives the information about the resources- Returns:
true
if all IDs were successfully looked up- Throws:
JRDFoxException
- thrown if an error is encountered
-
getResource
tech.oxfordsemantic.jrdfox.logic.expression.Resource getResource(long resourceID) throws JRDFoxExceptionLooks up the resource with the given IDs.- Parameters:
resourceID
- the resource ID that should be looked up- Returns:
- the resource, or
null
if the resource ID cannot be looked up - Throws:
JRDFoxException
- thrown if an error is encountered
-
getResources
boolean getResources(long[] resourceIDs, int startIndex, int endIndex, tech.oxfordsemantic.jrdfox.logic.expression.Resource[] resources) throws JRDFoxExceptionLooks up the resources with the given IDs. The length of theresources
array must be at leastendIndex
so that each resource ID at some index inresourceIDs
can be resolved to a resource at the same position inresources
.- Parameters:
resourceIDs
- the resource IDs that should be looked upstartIndex
- the first index inresourceIDs
to look upendIndex
- the index after the last inresourceIDs
to look upresources
- receives the resources- Returns:
true
if all IDs were successfully looked up- Throws:
JRDFoxException
- thrown if an error is encountered
-
saveToBinaryFormat
void saveToBinaryFormat(java.io.OutputStream outputStream, BinaryDataStoreFormat format) throws JRDFoxExceptionSaves the data store into the specified binary format. This operation can be invoked only if no transaction is active.- Parameters:
outputStream
- receives the binary content of the data storeformat
- specifies the format in which the store is saved- Throws:
JRDFoxException
- thrown if an error is encountered
-
saveToBinaryFormat
Saves the data store into the specified binary format. This operation can be invoked only if no transaction is active.- Parameters:
file
- receives the binary content of the data storeformat
- specifies the format in which the store is saved- Throws:
JRDFoxException
- thrown if an error is encountered
-
begin
Deprecated.Starts a new transaction on this connection.- Parameters:
transactionType
- determines the type of the transaction (i.e., whether a read-only or a read/write transaction is requested)- Throws:
JRDFoxException
- thrown if an error is encountered
-
commit
Deprecated.Commits the transaction associated with this connection. If an exception is thrown during a commit operation,transactionRequiresRollback()
will returntrue
, and the transaction should be explicitly rolled back usingrollbackTransaction()
.- Throws:
JRDFoxException
- thrown if an error is encountered
-
rollback
Deprecated.Rolls back the transaction associated with this connection.- Throws:
JRDFoxException
- thrown if an error is encountered
-