# TrackerBatch

TrackerBatch is an object containing a series of SPARQL updates, in either SPARQL string or TrackerResource form. This object has a single use, after the batch is executed, it can only be finished and freed.

A batch is created with tracker_sparql_connection_create_batch. To add resources use tracker_batch_add_resource or tracker_batch_add_sparql.

When a batch is ready for execution, use tracker_batch_execute or tracker_batch_execute_async. The batch is executed as a single transaction, it will succeed or fail entirely.

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.

This object was added in Tracker 3.1.

## TrackerBatch

    GObject
        ╰──TrackerBatch

### Members

`parent_instance` (GObject) –
No description available

### Class structure

#### TrackerBatchClass

### Tracker.BatchClass

## Tracker.Batch

    GObject.Object
        ╰──Tracker.Batch

### Members

`parent_instance` (GObject.Object) –
No description available

## Tracker.Batch

    GObject.Object
        ╰──Tracker.Batch

### Members

`parent_instance` (GObject.Object) –
No description available

### Methods

#### tracker_batch_add_resource

    tracker_batch_add_resource (TrackerBatch * batch,
                                const gchar* graph,
                                TrackerResource * resource)

Adds the RDF represented by resource to batch.

Parameters:

`batch` –

a TrackerBatch

`graph` ( [nullable]) –

RDF graph to insert the resource to

`resource` –

a TrackerResource

Since : 3.1

#### Tracker.Batch.prototype.add_resource

    function Tracker.Batch.prototype.add_resource(graph: String, resource: Tracker.Resource): {
        // javascript wrapper for 'tracker_batch_add_resource'
    }

Adds the RDF represented by resource to batch.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`graph` (String) –

RDF graph to insert the resource to

`resource` (Tracker.Resource) –

a Tracker.Resource

Since : 3.1

#### Tracker.Batch.add_resource

    def Tracker.Batch.add_resource (self, graph, resource):
        #python wrapper for 'tracker_batch_add_resource'

Adds the RDF represented by resource to batch.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`graph` (str) –

RDF graph to insert the resource to

`resource` (Tracker.Resource) –

a Tracker.Resource

Since : 3.1

#### tracker_batch_add_sparql

    tracker_batch_add_sparql (TrackerBatch * batch,
                              const gchar* sparql)

Adds an SPARQL update string to batch.

Parameters:

`batch` –

a TrackerBatch

`sparql` –

a SPARQL update string

Since : 3.1

#### Tracker.Batch.prototype.add_sparql

    function Tracker.Batch.prototype.add_sparql(sparql: String): {
        // javascript wrapper for 'tracker_batch_add_sparql'
    }

Adds an SPARQL update string to batch.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`sparql` (String) –

a SPARQL update string

Since : 3.1

#### Tracker.Batch.add_sparql

    def Tracker.Batch.add_sparql (self, sparql):
        #python wrapper for 'tracker_batch_add_sparql'

Adds an SPARQL update string to batch.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`sparql` (str) –

a SPARQL update string

Since : 3.1

#### tracker_batch_add_statement

    tracker_batch_add_statement (TrackerBatch * batch,
                                 TrackerSparqlStatement * stmt,
                                 ... ...)

Adds a TrackerSparqlStatement containing an SPARQL update. The statement will be executed once in the batch, with the parameters bound as specified in the variable arguments.

The variable arguments are a NULL terminated set of variable name, value GType, and actual value. For example, for a statement that has a single `~name` parameter, it could be given a value for execution with the given code:

    tracker_batch_add_statement (batch, stmt,
                                 "name", G_TYPE_STRING, "John Smith",
                                 NULL);

The TrackerSparqlStatement may be used on multiple tracker_batch_add_statement calls with the same or different values, on the same or different TrackerBatch objects.

This function should only be called on TrackerSparqlStatement objects obtained through tracker_sparql_connection_update_statement or update statements loaded through tracker_sparql_connection_load_statement_from_gresource.

Parameters:

`batch` –

a TrackerBatch

`stmt` –

a TrackerSparqlStatement containing a SPARQL update

`...` –

parameters bound to stmt, in triples of name/type/value

Since : 3.5

#### tracker_batch_add_statementv

    tracker_batch_add_statementv (TrackerBatch * batch,
                                  TrackerSparqlStatement * stmt,
                                  guint n_values,
                                  const gchar** variable_names,
                                  const GValue* values)

Adds a TrackerSparqlStatement 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:

    const char *names = { "name" };
    const GValue values[G_N_ELEMENTS (names)] = { 0, };

    g_value_init (&values[0], G_TYPE_STRING);
    g_value_set_string (&values[0], "John Smith");
    tracker_batch_add_statementv (batch, stmt,
                                  G_N_ELEMENTS (names),
                                  names, values);

    batch.add_statement(stmt, ['name'], ['John Smith']);

    batch.add_statement(stmt, ['name'], ['John Smith']);

The TrackerSparqlStatement may be used on multiple tracker_batch_add_statement calls with the same or different values, on the same or different TrackerBatch objects.

This function should only be called on TrackerSparqlStatement objects obtained through tracker_sparql_connection_update_statement or update statements loaded through tracker_sparql_connection_load_statement_from_gresource.

Parameters:

`batch` –

a TrackerBatch

`stmt` –

a TrackerSparqlStatement containing a SPARQL update

`n_values` –

the number of bound parameters

`variable_names` ( [arraylength=n_values]) –

the names of each bound parameter

`values` ( [arraylength=n_values]) –

the values of each bound parameter

Since : 3.5

#### Tracker.Batch.prototype.add_statementv

    function Tracker.Batch.prototype.add_statementv(stmt: Tracker.SparqlStatement, n_values: Number, variable_names: [ String ], values: [ GObject.Value]): {
        // javascript wrapper for 'tracker_batch_add_statementv'
    }

Adds a Tracker.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:

    const char *names = { "name" };
    const GValue values[G_N_ELEMENTS (names)] = { 0, };

    g_value_init (&values[0], G_TYPE_STRING);
    g_value_set_string (&values[0], "John Smith");
    tracker_batch_add_statementv (batch, stmt,
                                  G_N_ELEMENTS (names),
                                  names, values);

    batch.add_statement(stmt, ['name'], ['John Smith']);

    batch.add_statement(stmt, ['name'], ['John Smith']);

The Tracker.SparqlStatement may be used on multiple tracker_batch_add_statement (not introspectable) calls with the same or different values, on the same or different Tracker.Batch objects.

This function should only be called on Tracker.SparqlStatement objects obtained through Tracker.SparqlConnection.prototype.update_statement or update statements loaded through Tracker.SparqlConnection.prototype.load_statement_from_gresource.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`stmt` (Tracker.SparqlStatement) –

a Tracker.SparqlStatement containing a SPARQL update

`n_values` (Number) –

the number of bound parameters

`variable_names` ([ String ]) –

the names of each bound parameter

`values` ([ GObject.Value]) –

the values of each bound parameter

Since : 3.5

#### Tracker.Batch.add_statementv

    def Tracker.Batch.add_statementv (self, stmt, n_values, variable_names, values):
        #python wrapper for 'tracker_batch_add_statementv'

Adds a Tracker.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:

    const char *names = { "name" };
    const GValue values[G_N_ELEMENTS (names)] = { 0, };

    g_value_init (&values[0], G_TYPE_STRING);
    g_value_set_string (&values[0], "John Smith");
    tracker_batch_add_statementv (batch, stmt,
                                  G_N_ELEMENTS (names),
                                  names, values);

    batch.add_statement(stmt, ['name'], ['John Smith']);

    batch.add_statement(stmt, ['name'], ['John Smith']);

The Tracker.SparqlStatement may be used on multiple tracker_batch_add_statement (not introspectable) calls with the same or different values, on the same or different Tracker.Batch objects.

This function should only be called on Tracker.SparqlStatement objects obtained through Tracker.SparqlConnection.update_statement or update statements loaded through Tracker.SparqlConnection.load_statement_from_gresource.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`stmt` (Tracker.SparqlStatement) –

a Tracker.SparqlStatement containing a SPARQL update

`n_values` (int) –

the number of bound parameters

`variable_names` ([ str ]) –

the names of each bound parameter

`values` ([ GObject.Value]) –

the values of each bound parameter

Since : 3.5

#### tracker_batch_execute

    gboolean
    tracker_batch_execute (TrackerBatch * batch,
                           GCancellable* cancellable,
                           GError** error)

Executes the batch. This operations happens synchronously.

Parameters:

`batch` –

a TrackerBatch

`cancellable` ( [nullable]) –

a GCancellable, or NULL

`error` –

location for a GError, or NULL

Returns –

TRUE of there were no errors, FALSE otherwise

Since : 3.1

#### Tracker.Batch.prototype.execute

    function Tracker.Batch.prototype.execute(cancellable: Gio.Cancellable): {
        // javascript wrapper for 'tracker_batch_execute'
    }

Executes the batch. This operations happens synchronously.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`cancellable` (Gio.Cancellable) –

a GCancellable, or NULL

Returns (Number) –

TRUE of there were no errors, FALSE otherwise

Since : 3.1

#### Tracker.Batch.execute

    @raises(GLib.GError)
    def Tracker.Batch.execute (self, cancellable):
        #python wrapper for 'tracker_batch_execute'

Executes the batch. This operations happens synchronously.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`cancellable` (Gio.Cancellable) –

a GCancellable, or NULL

Returns (bool) –

TRUE of there were no errors, FALSE otherwise

Since : 3.1

#### tracker_batch_execute_async

    tracker_batch_execute_async (TrackerBatch * batch,
                                 GCancellable* cancellable,
                                 GAsyncReadyCallback callback,
                                 gpointer user_data)

Executes the batch. This operation happens asynchronously, when finished callback will be executed.

Parameters:

`batch` –

a TrackerBatch

`cancellable` ( [nullable]) –

a GCancellable, or NULL

`callback` –

user-defined GAsyncReadyCallback to be called when asynchronous operation is finished.

`user_data` –

user-defined data to be passed to callback

Since : 3.1

#### Tracker.Batch.prototype.execute_async

    function Tracker.Batch.prototype.execute_async(cancellable: Gio.Cancellable, callback: Gio.AsyncReadyCallback, user_data: Object): {
        // javascript wrapper for 'tracker_batch_execute_async'
    }

Executes the batch. This operation happens asynchronously, when finished callback will be executed.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`cancellable` (Gio.Cancellable) –

a GCancellable, or NULL

`callback` (Gio.AsyncReadyCallback) –

user-defined GAsyncReadyCallback to be called when asynchronous operation is finished.

`user_data` (Object) –

user-defined data to be passed to callback

Since : 3.1

#### Tracker.Batch.execute_async

    def Tracker.Batch.execute_async (self, cancellable, callback, *user_data):
        #python wrapper for 'tracker_batch_execute_async'

Executes the batch. This operation happens asynchronously, when finished callback will be executed.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`cancellable` (Gio.Cancellable) –

a GCancellable, or NULL

`callback` (Gio.AsyncReadyCallback) –

user-defined GAsyncReadyCallback to be called when asynchronous operation is finished.

`user_data` (variadic) –

user-defined data to be passed to callback

Since : 3.1

#### tracker_batch_execute_finish

    gboolean
    tracker_batch_execute_finish (TrackerBatch * batch,
                                  GAsyncResult* res,
                                  GError** error)

Finishes the operation started with tracker_batch_execute_async.

Parameters:

`batch` –

a TrackerBatch

`res` –

a GAsyncResult with the result of the operation

`error` –

location for a GError, or NULL

Returns –

TRUE of there were no errors, FALSE otherwise

Since : 3.1

#### Tracker.Batch.prototype.execute_finish

    function Tracker.Batch.prototype.execute_finish(res: Gio.AsyncResult): {
        // javascript wrapper for 'tracker_batch_execute_finish'
    }

Finishes the operation started with Tracker.Batch.prototype.execute_async.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`res` (Gio.AsyncResult) –

a GAsyncResult with the result of the operation

Returns (Number) –

TRUE of there were no errors, FALSE otherwise

Since : 3.1

#### Tracker.Batch.execute_finish

    @raises(GLib.GError)
    def Tracker.Batch.execute_finish (self, res):
        #python wrapper for 'tracker_batch_execute_finish'

Finishes the operation started with Tracker.Batch.execute_async.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

`res` (Gio.AsyncResult) –

a GAsyncResult with the result of the operation

Returns (bool) –

TRUE of there were no errors, FALSE otherwise

Since : 3.1

#### tracker_batch_get_connection

    TrackerSparqlConnection *
    tracker_batch_get_connection (TrackerBatch * batch)

Returns the TrackerSparqlConnection that this batch was created from.

Parameters:

`batch` –

a TrackerBatch

Returns ( [transfer: none]) –

The SPARQL connection of this batch.

#### Tracker.Batch.prototype.get_connection

    function Tracker.Batch.prototype.get_connection(): {
        // javascript wrapper for 'tracker_batch_get_connection'
    }

Returns the Tracker.SparqlConnection that this batch was created from.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

Returns (Tracker.SparqlConnection) –

The SPARQL connection of this batch.

#### Tracker.Batch.get_connection

    def Tracker.Batch.get_connection (self):
        #python wrapper for 'tracker_batch_get_connection'

Returns the Tracker.SparqlConnection that this batch was created from.

Parameters:

`batch` (Tracker.Batch) –

a Tracker.Batch

Returns (Tracker.SparqlConnection) –

The SPARQL connection of this batch.

### Properties

#### connection

    “connection” TrackerSparqlConnection *

ਪ * The TrackerSparqlConnection the batch belongs to.

Flags : Read / Write / Construct Only

#### connection

    “connection” Tracker.SparqlConnection

ਪ * The Tracker.SparqlConnection the batch belongs to.

Flags : Read / Write / Construct Only

#### connection

    “self.props.connection” Tracker.SparqlConnection

ਪ * The Tracker.SparqlConnection the batch belongs to.

Flags : Read / Write / Construct Only

## Constants

### TRACKER_TYPE_BATCH

    #define TRACKER_TYPE_BATCH tracker_batch_get_type ()

The results of the search are