TrackerBatch: Tracker SPARQL Library Reference Manual

## TrackerBatch TrackerBatch — Update batches |

## Stability Level

Stable, unless otherwise indicated

## Functions

TrackerSparqlConnection * | tracker_batch_get_connection ()
void | tracker_batch_add_sparql ()
void | tracker_batch_add_resource ()
gboolean | tracker_batch_execute ()
void | tracker_batch_execute_async ()
gboolean | tracker_batch_execute_finish ()

## Properties

TrackerSparqlConnection * | connection | Read / Write / Construct Only

## Types and Values

| TrackerBatch

## Object Hierarchy

        GObject
        ╰── TrackerBatch

## Includes

    #include <tracker-sparql.h>

## Description

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.

## Functions

### 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

The SPARQL connection of this batch.

[transfer none]

### tracker_batch_add_sparql ()

    void
    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_add_resource ()

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

Adds the RDF represented by `resource` to `batch` .

#### Parameters

batch | a TrackerBatch |
graph | RDF graph to insert the resource to |
resource | a TrackerResource |

Since: 3.1

### 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 | a GCancellable, or `NULL`. | [nullable]
error | location for a GError, or `NULL` |

#### Returns

`TRUE` of there were no errors, `FALSE` otherwise

Since: 3.1

### tracker_batch_execute_async ()

    void
    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 | a GCancellable, or `NULL`. | [nullable]
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_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

## Types and Values

### TrackerBatch

    typedef struct _TrackerBatch TrackerBatch;

## Property Details

### The `“connection”` property

      “connection”               TrackerSparqlConnection *

The TrackerSparqlConnection the batch belongs to.

Owner: TrackerBatch

Flags: Read / Write / Construct Only