Constructor
TsparqlSparqlConnectionnew
Declaration [src]
TrackerSparqlConnection*
tracker_sparql_connection_new (
TrackerSparqlConnectionFlags flags,
GFile* store,
GFile* ontology,
GCancellable* cancellable,
GError** error
)
Description [src]
Creates or opens a process-local database.
This method should only be used for databases owned by the current process.
To connect to databases managed by other processes, use
tracker_sparql_connection_bus_new()
.
If store
is NULL
, the database will be created in memory.
If defined, the ontology
argument must point to a location containing
suitable .ontology
files in Turtle format. These define the structure of
the triple store. You can learn more about ontologies,
or you can use the stock Nepomuk ontologies by calling
tracker_sparql_get_ontology_nepomuk()
.
If opening an existing database, it is possible to pass NULL
as the
ontology
location, the ontology will be introspected from the database.
Passing a NULL
ontology
will raise an error if the database does not exist.
If a database is opened without the READONLY
TrackerSparqlConnectionFlags
flag enabled, and the given ontology
holds differences with the current
data layout, migration to the new structure will be attempted. This operation
may raise an error. In particular, not all migrations are possible without
causing data loss and Tracker will refuse to delete data during a migration.
The database is always left in a consistent state, either prior or posterior
to migration.
Operations on a TrackerSparqlConnection
resulting on a
CORRUPT
TrackerSparqlError
will have the event recorded
persistently through a .meta.corrupted
file alongside the database files.
If the database is opened without the READONLY
TrackerSparqlConnectionFlags
flag enabled and the file is found, this constructor will attempt to repair the
database. In that situation, this constructor will either return a valid
TrackerSparqlConnection
if the database was repaired successfully, or
raise a CORRUPT
TrackerSparqlError
error if the database remains corrupted.
It is considered a developer error to ship ontologies that contain format errors, or that fail at migrations.
It is encouraged to use resource:///
URI locations for ontology
wherever
possible, so the triple store structure is tied to the executable binary,
and in order to minimize disk seeks during TrackerSparqlConnection
initialization.
Parameters
flags
-
Type:
TrackerSparqlConnectionFlags
Connection flags to define the SPARQL connection behavior.
store
-
Type:
GFile
The directory that contains the database as a
GFile
, orNULL
.The argument can be NULL
.The data is owned by the caller of the function. ontology
-
Type:
GFile
The directory that contains the database schemas as a
GFile
, orNULL
.The argument can be NULL
.The data is owned by the caller of the function. cancellable
-
Type:
GCancellable
Optional
GCancellable
.The argument can be NULL
.The data is owned by the caller of the function. error
-
Type:
GError **
The return location for a recoverable error.
The argument can be NULL
.If the return location is not NULL
, then you must initialize it to aNULL
GError*
.The argument will be left initialized to NULL
by the constructor if there are no errors.In case of error, the argument will be set to a newly allocated GError
; the caller will take ownership of the data, and be responsible for freeing it.
Return value
Type: TrackerSparqlConnection
A new TrackerSparqlConnection
.
The caller of the function takes ownership of the data, and is responsible for freeing it. |