Tracker.Batch¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
connection |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Tracker.Batch(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
TrackerBatch
executes a series of SPARQL updates and RDF data insertions within a transaction.A batch is created with [method`SparqlConnection`.create_batch]. To add resources use [method`Batch`.add_resource], [method`Batch`.add_sparql] or [method`Batch`.add_statement].
When a batch is ready for execution, use [method`Batch`.execute] or [method`Batch`.execute_async]. The batch is executed as a single transaction, it will succeed or fail entirely.
This object has a single use, after the batch is executed it can only be finished and freed.
The mapping of blank node labels is global in a
TrackerBatch
, referencing the same blank node label in different operations in a batch will resolve to the same resource.New in version 3.1.
- add_rdf(flags, format, default_graph, stream)¶
- Parameters:
flags (
Tracker.DeserializeFlags
) – Deserialization flagsformat (
Tracker.RdfFormat
) – RDF format of data in streamdefault_graph (
str
) – Default graph that will receive the RDF datastream (
Gio.InputStream
) – Input stream with RDF data
Inserts the RDF data contained in stream as part of self.
The RDF data will be inserted in the given default_graph if one is provided, or the anonymous graph if default_graph is
None
. Any RDF data that has a graph specified (e.g. using theGRAPH
clause in the Trig format) will be inserted in the specified graph instead of default_graph.The flags argument is reserved for future expansions, currently
Tracker.DeserializeFlags.NONE
must be passed.New in version 3.6.
- add_resource(graph, resource)¶
- Parameters:
resource (
Tracker.Resource
) – A [class`Resource`]
Adds the RDF represented by resource to self.
New in version 3.1.
- add_sparql(sparql)¶
- Parameters:
sparql (
str
) – A SPARQL update string
Adds an SPARQL update string to self.
New in version 3.1.
- add_statement(stmt, variable_names, values)¶
- Parameters:
stmt (
Tracker.SparqlStatement
) – A [class`SparqlStatement`] containing a SPARQL updatevariable_names ([
str
]) – The names of each bound parametervalues ([
GObject.Value
]) – The values of each bound parameter
Adds a [class`SparqlStatement`] containing an SPARQL update. The statement will be executed once in the batch, with the values bound as specified by variable_names and values.
For example, for a statement that has a single
~name
parameter, it could be given a value for execution with the given code:```c const
str
*names = { “name” }; constGObject.Value
values[G_N_ELEMENTS (names)] = { 0, };GObject.Value.init
(&values[0],GObject.TYPE_STRING
);GObject.Value.set_string
(&values[0], “John Smith”);Tracker.Batch.add_statement
(batch, stmt, G_N_ELEMENTS (names), names, values); `` ``python batch.add_statement(stmt, [‘name’], [‘John Smith’]); `` ``js batch.add_statement(stmt, [‘name’], [‘John Smith’]); ```A [class`SparqlStatement`] may be used on multiple [method`Batch`.add_statement] calls with the same or different values, on the same or different
TrackerBatch
objects.This function should only be called on [class`SparqlStatement`] objects obtained through [method`SparqlConnection`.update_statement] or update statements loaded through [method`SparqlConnection`.load_statement_from_gresource].
New in version 3.5.
- execute(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Optional [type`Gio`.Cancellable]- Raises:
- Returns:
- Return type:
Executes the batch. This operations happens synchronously.
New in version 3.1.
- execute_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – Optional [type`Gio`.Cancellable]callback (
Gio.AsyncReadyCallback
orNone
) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.user_data (
object
orNone
) – User-defined data to be passed to callback
Executes the batch. This operation happens asynchronously, when finished callback will be executed.
New in version 3.1.
- execute_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – A [type`Gio`.AsyncResult] with the result of the operation- Raises:
- Returns:
- Return type:
Finishes the operation started with [method`Batch`.execute_async].
New in version 3.1.
- get_connection()¶
- Returns:
The SPARQL connection of this batch.
- Return type:
Returns the [class`SparqlConnection`] that this batch was created from.
Property Details¶
- Tracker.Batch.props.connection¶
- Name:
connection
- Type:
- Default Value:
- Flags:
The [class`SparqlConnection`] the batch belongs to.