Soprano
2.7.56
|
The Virtuoso storage backend provides access to Virtuoso servers. It can connect to already running servers as well as spawn its own local instance. The Virtuoso server is accessed via ODBC through the client library iODBC. Currently no other client libraries are supported (which also means that this backend can only be used on systems that have libiODBC which excludes Windows).
The name of the backend is virtuosobackend
. Thus, to use it one simply has to load it as follows:
const Soprano::Backend* virtBack = Soprano::PluginManager::instance()->discoverBackendByName("virtuosobackend");
The Virtuoso backend supports the following settings which can be passed to Soprano::Backend::createModel:
indexes
- A comma separated list of quadruple indexes to be used (Example: 'spog
,posg
,opsg'
). If not specified, the indexes are not changed, ie. the Virtuoso defaults are used.fulltextindex
- Enable or disable the full text index which allows to perform full text queries on string literals embedded in SPARQL queries. For more information see the documentation on Virtuoso SPARQL extensions.none
- disable the indexsync
- enable syncroneous updates of the index (the index is always in sync. This might give a performace penalty)N
- The interval in minutes after which the index will be updated.NumberOfBuffers
- The number of buffers (8k in size) to be used by Virtuoso. Defaults to 2000.ServerThreads
- The number of server threads. Defaults to 100.CheckpointInterval
- The interval in minutes at which Virtuoso will automatically make a database checkpoint. Defaults to 60.MinAutoCheckpointSize
- The minimum size of the Virtuoso transaction log. An automatic checkpoint will not be made if there is less than MinAutoCheckpointSize bytes in the current transaction log. Defaults to 4000000.forcedstart
- A boolean property which when set will result in the backend killing any Virtuoso instance accessing the data in the storage dir before starting its own instance. This option is ignored when connecting to an already running Virtuoso server.QueryTimeout
- The maximum time any query may take in milliseconds. See Virtuoso Anytime Queries for details.noStatementSignals
- A boolean property which when set will disable the statement signals like Model::statementsAdded(). The default is false
, ie. to emit the signals.The settings above are user settings and have to be provided using Soprano::BackendOptionUser:
Soprano::BackendSettings settings; // configure the used indexes settings << Soprano::BackendSetting( "indexes", "spog,posg,opsg" ); // set the full text index to be updated every 10 minutes settings << Soprano::BackendSetting( "fulltextindex", "10" );
The following setting is required for starting a local instance of Virtuoso:
The following settings need to be provided to access an already running Virtuoso server:
Models created by the Virtuoso backend emit a non-standard signal which informs the client that the Virtuoso server went down. This signal is only emitted for Virtuoso instances that were started by the backend and has the following signature:
void virtuosoStopped(bool normalExit);
The parameter normalExit
is true
if the instance went down as scheduled (deletion of the model) and false
if the Virtuoso instance crashed or was killed by a third party. Typically a client would connect to the signal to properly re-create the model.
It is possible to perform plain SQL queries through the Soprano API by using the sql
user query language in Model::executeQuery:
QString query = "select * from DB.DBA.RDF_GRAPH_GROUP"; Soprano::QueryResultIterator it = model->executeQuery(query, Soprano::Query::QueryLanguageUser, "sql");
Since Virtuoso is an SQL server and, thus, does store all RDF data in SQL tables it has some characteristics that are worth mentioning:
Virtuoso/SPAURL has no notion of the empty/default graph. Thus, by default, it is not possible to add statements to the empty/default graph. The Soprano backend works around this problem by introducing a special named graph which is used internally to store triples that belong to the default/empty graph.
This means that a conversion needs to take place whenever the empty graph or the special graph are encountered. This introduces a slight performance penalty. In the future an option might be introduced to disable this behaviour.
Virtuoso, being an SQL server, does not have specific types for boolean, decimal and others. They are all represented as SQL integer values.
The backend does solve this issue for boolean values only by introducing a fake datatype for boolean literals. This is converted internally so the user of the backend will never notice it. The only exception may be queries that contain filters. More input is needed here.