Tracker.Batch

g GObject.Object GObject.Object Tracker.Batch Tracker.Batch GObject.Object->Tracker.Batch

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

add_rdf (flags, format, default_graph, stream)

add_resource (graph, resource)

add_sparql (sparql)

add_statement (stmt, variable_names, values)

execute (cancellable)

execute_async (cancellable, callback, *user_data)

execute_finish (res)

get_connection ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

connection

Tracker.SparqlConnection

r/w/co

connection

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Tracker.Batch(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Tracker.BatchClass

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:

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 the GRAPH 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:

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 update

  • variable_names ([str]) – The names of each bound parameter

  • values ([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” }; const GObject.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 or None) – Optional [type`Gio`.Cancellable]

Raises:

GLib.Error

Returns:

True of there were no errors, False otherwise

Return type:

bool

Executes the batch. This operations happens synchronously.

New in version 3.1.

execute_async(cancellable, callback, *user_data)
Parameters:
  • cancellable (Gio.Cancellable or None) – Optional [type`Gio`.Cancellable]

  • callback (Gio.AsyncReadyCallback or None) – User-defined [type`Gio`.AsyncReadyCallback] to be called when the asynchronous operation is finished.

  • user_data (object or None) – 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:

GLib.Error

Returns:

True of there were no errors, False otherwise

Return type:

bool

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:

Tracker.SparqlConnection

Returns the [class`SparqlConnection`] that this batch was created from.

Property Details

Tracker.Batch.props.connection
Name:

connection

Type:

Tracker.SparqlConnection

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The [class`SparqlConnection`] the batch belongs to.