[tracker/wip/carlosg/serialize-api: 9/11] libtracker-data: Do not forward static value types to cursors
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/serialize-api: 9/11] libtracker-data: Do not forward static value types to cursors
- Date: Wed, 2 Feb 2022 11:06:21 +0000 (UTC)
commit f97cc064ee547ff5d50dc95260556dc5763a3ab7
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jan 30 17:07:43 2022 +0100
libtracker-data: Do not forward static value types to cursors
Now that this information is contained in the cursor itself for all the
query types that we care, we can avoid forwarding this programmatically.
src/libtracker-data/tracker-db-interface-sqlite.c | 54 +++--------------------
src/libtracker-data/tracker-db-interface.h | 2 -
src/libtracker-data/tracker-sparql.c | 19 +-------
3 files changed, 9 insertions(+), 66 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 9659b561f..24ea5a75c 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -116,8 +116,6 @@ struct TrackerDBCursor {
TrackerDBStatement *ref_stmt;
gboolean finished;
guint n_columns;
- TrackerPropertyType *types;
- guint n_types;
};
struct TrackerDBCursorClass {
@@ -143,9 +141,7 @@ static TrackerDBStatement *tracker_db_statement_sqlite_new (TrackerDBIn
sqlite3_stmt *sqlite_stmt);
static void tracker_db_statement_sqlite_reset (TrackerDBStatement *stmt);
static TrackerDBCursor *tracker_db_cursor_sqlite_new (TrackerDBStatement *ref_stmt,
- guint n_columns,
- TrackerPropertyType *types,
- guint n_types);
+ guint n_columns);
static gboolean tracker_db_cursor_get_boolean (TrackerSparqlCursor *cursor,
guint column);
static gboolean db_cursor_iter_next (TrackerDBCursor *cursor,
@@ -3132,8 +3128,6 @@ tracker_db_cursor_finalize (GObject *object)
tracker_db_cursor_close (cursor);
- g_free (cursor->types);
-
G_OBJECT_CLASS (tracker_db_cursor_parent_class)->finalize (object);
}
@@ -3222,9 +3216,7 @@ tracker_db_cursor_class_init (TrackerDBCursorClass *class)
static TrackerDBCursor *
tracker_db_cursor_sqlite_new (TrackerDBStatement *ref_stmt,
- guint n_columns,
- TrackerPropertyType *types,
- guint n_types)
+ guint n_columns)
{
TrackerDBCursor *cursor;
TrackerDBInterface *iface;
@@ -3256,16 +3248,6 @@ tracker_db_cursor_sqlite_new (TrackerDBStatement *ref_stmt,
cursor->stmt = ref_stmt->stmt;
cursor->ref_stmt = tracker_db_statement_sqlite_grab (ref_stmt);
- if (types) {
- guint i;
-
- cursor->types = g_new (TrackerPropertyType, n_types);
- cursor->n_types = n_types;
- for (i = 0; i < n_types; i++) {
- cursor->types[i] = types[i];
- }
- }
-
return cursor;
}
@@ -3658,26 +3640,6 @@ tracker_db_cursor_get_value_type (TrackerDBCursor *cursor,
return TRACKER_SPARQL_VALUE_TYPE_UNBOUND;
}
- if (column < cursor->n_types) {
- switch (cursor->types[column]) {
- case TRACKER_PROPERTY_TYPE_RESOURCE:
- return TRACKER_SPARQL_VALUE_TYPE_URI;
- case TRACKER_PROPERTY_TYPE_INTEGER:
- return TRACKER_SPARQL_VALUE_TYPE_INTEGER;
- case TRACKER_PROPERTY_TYPE_DOUBLE:
- return TRACKER_SPARQL_VALUE_TYPE_DOUBLE;
- case TRACKER_PROPERTY_TYPE_DATETIME:
- return TRACKER_SPARQL_VALUE_TYPE_DATETIME;
- case TRACKER_PROPERTY_TYPE_BOOLEAN:
- return TRACKER_SPARQL_VALUE_TYPE_BOOLEAN;
- case TRACKER_PROPERTY_TYPE_DATE:
- case TRACKER_PROPERTY_TYPE_LANGSTRING:
- case TRACKER_PROPERTY_TYPE_STRING:
- case TRACKER_PROPERTY_TYPE_UNKNOWN:
- return TRACKER_SPARQL_VALUE_TYPE_STRING;
- }
- }
-
switch (column_type) {
case SQLITE_INTEGER:
return TRACKER_SPARQL_VALUE_TYPE_INTEGER;
@@ -3754,20 +3716,18 @@ tracker_db_statement_start_cursor (TrackerDBStatement *stmt,
g_return_val_if_fail (TRACKER_IS_DB_STATEMENT (stmt), NULL);
g_return_val_if_fail (!stmt->stmt_is_used, NULL);
- return tracker_db_cursor_sqlite_new (stmt, 0, NULL, 0);
+ return tracker_db_cursor_sqlite_new (stmt, 0);
}
TrackerDBCursor *
-tracker_db_statement_start_sparql_cursor (TrackerDBStatement *stmt,
- guint n_columns,
- TrackerPropertyType *types,
- guint n_types,
- GError **error)
+tracker_db_statement_start_sparql_cursor (TrackerDBStatement *stmt,
+ guint n_columns,
+ GError **error)
{
g_return_val_if_fail (TRACKER_IS_DB_STATEMENT (stmt), NULL);
g_return_val_if_fail (!stmt->stmt_is_used, NULL);
- return tracker_db_cursor_sqlite_new (stmt, n_columns, types, n_types);
+ return tracker_db_cursor_sqlite_new (stmt, n_columns);
}
static void
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index 67b76704d..66aa31b63 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -144,8 +144,6 @@ TrackerDBCursor * tracker_db_statement_start_cursor (TrackerDBS
GError **error);
TrackerDBCursor * tracker_db_statement_start_sparql_cursor (TrackerDBStatement *stmt,
guint n_columns,
- TrackerPropertyType *types,
- guint n_types,
GError **error);
/* Functions to deal with a cursor */
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 51f3e1cd5..5f8eee365 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -174,7 +174,6 @@ struct _TrackerSparql
GHashTable *prefix_map;
GList *filter_clauses;
- GArray *var_types;
GHashTable *cached_bindings;
GVariantBuilder *blank_nodes;
@@ -242,7 +241,6 @@ tracker_sparql_finalize (GObject *object)
g_ptr_array_unref (sparql->named_graphs);
g_ptr_array_unref (sparql->anon_graphs);
- g_array_unref (sparql->var_types);
g_free (sparql->base);
g_clear_pointer (&sparql->policy.graphs, g_ptr_array_unref);
@@ -2788,10 +2786,7 @@ tracker_sparql_add_select_var (TrackerSparql *sparql,
const gchar *name,
TrackerPropertyType type)
{
- if (sparql->current_state->select_context == sparql->context) {
- /* Topmost select context */
- g_array_append_val (sparql->var_types, type);
- } else {
+ if (sparql->current_state->select_context != sparql->context) {
TrackerContext *parent;
TrackerVariable *var;
@@ -4704,9 +4699,7 @@ get_solution_for_pattern (TrackerSparql *sparql,
if (!stmt)
return NULL;
- cursor = tracker_db_statement_start_sparql_cursor (stmt, 0,
- NULL, 0,
- error);
+ cursor = tracker_db_statement_start_sparql_cursor (stmt, 0, error);
g_object_unref (stmt);
if (!cursor)
@@ -9794,7 +9787,6 @@ tracker_sparql_init (TrackerSparql *sparql)
g_free, g_object_unref);
sparql->parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
- sparql->var_types = g_array_new (FALSE, FALSE, sizeof (TrackerPropertyType));
sparql->anon_graphs = g_ptr_array_new_with_free_func (g_free);
sparql->named_graphs = g_ptr_array_new_with_free_func (g_free);
sparql->cacheable = TRUE;
@@ -9986,7 +9978,6 @@ tracker_sparql_reset_state (TrackerSparql *sparql)
g_clear_object (&sparql->context);
g_list_free (sparql->filter_clauses);
sparql->filter_clauses = NULL;
- g_array_set_size (sparql->var_types, 0);
g_hash_table_remove_all (sparql->cached_bindings);
g_hash_table_remove_all (sparql->parameters);
g_ptr_array_set_size (sparql->anon_graphs, 0);
@@ -10002,8 +9993,6 @@ tracker_sparql_execute_cursor (TrackerSparql *sparql,
TrackerDBInterface *iface = NULL;
TrackerDBCursor *cursor = NULL;
TrackerSelectContext *select_context;
- TrackerPropertyType *types;
- guint n_types;
g_mutex_lock (&sparql->mutex);
@@ -10052,12 +10041,8 @@ tracker_sparql_execute_cursor (TrackerSparql *sparql,
if (!stmt)
goto error;
- types = (TrackerPropertyType *) sparql->var_types->data;
- n_types = sparql->var_types->len;
-
cursor = tracker_db_statement_start_sparql_cursor (stmt,
select_context->n_columns,
- types, n_types,
error);
g_object_unref (stmt);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]