[tracker/binary-log-2: 17/63] libtracker-data: Use cached ids instead of lookups
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/binary-log-2: 17/63] libtracker-data: Use cached ids instead of lookups
- Date: Fri, 8 Jan 2010 09:43:51 +0000 (UTC)
commit 319ff64bfc6226fb9e981827d7e2e01a5c91f9ff
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Dec 31 12:56:25 2009 +0100
libtracker-data: Use cached ids instead of lookups
src/libtracker-data/tracker-data-update.c | 33 ++++++++++++++++++----------
1 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index d89554b..56e01c2 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -1286,13 +1286,14 @@ tracker_data_delete_statement (const gchar *graph,
} else {
field = tracker_ontology_get_property_by_uri (predicate);
if (field != NULL) {
+ gint id = tracker_property_get_id (field);
if (tracker_property_get_data_type (field) == TRACKER_PROPERTY_TYPE_RESOURCE) {
tracker_db_journal_append_delete_statement_code (resource_buffer->id,
- tracker_data_query_resource_id (predicate),
+ (id != -1) ? id : tracker_data_query_resource_id (predicate),
query_resource_id (object));
} else {
tracker_db_journal_append_delete_statement (resource_buffer->id,
- tracker_data_query_resource_id (predicate),
+ (id != -1) ? id : tracker_data_query_resource_id (predicate),
object);
}
@@ -1433,6 +1434,7 @@ tracker_data_insert_statement_with_uri (const gchar *graph,
GError *actual_error = NULL;
TrackerClass *class;
TrackerProperty *property;
+ gint prop_id = -1;
g_return_if_fail (subject != NULL);
g_return_if_fail (predicate != NULL);
@@ -1448,10 +1450,13 @@ tracker_data_insert_statement_with_uri (const gchar *graph,
"Property '%s' not found in the ontology", predicate);
return;
}
- } else if (tracker_property_get_data_type (property) != TRACKER_PROPERTY_TYPE_RESOURCE) {
- g_set_error (error, TRACKER_DATA_ERROR, TRACKER_DATA_ERROR_INVALID_TYPE,
- "Property '%s' does not accept URIs", predicate);
- return;
+ } else {
+ if (tracker_property_get_data_type (property) != TRACKER_PROPERTY_TYPE_RESOURCE) {
+ g_set_error (error, TRACKER_DATA_ERROR, TRACKER_DATA_ERROR_INVALID_TYPE,
+ "Property '%s' does not accept URIs", predicate);
+ return;
+ }
+ prop_id = tracker_property_get_id (property);
}
/* subjects and objects starting with `:' are anonymous blank nodes */
@@ -1500,7 +1505,7 @@ tracker_data_insert_statement_with_uri (const gchar *graph,
}
tracker_db_journal_append_insert_statement_code (resource_buffer->id,
- tracker_data_query_resource_id (predicate),
+ (prop_id != -1) ? prop_id : tracker_data_query_resource_id (predicate),
query_resource_id (object));
if (strcmp (predicate, RDF_PREFIX "type") == 0) {
@@ -1548,6 +1553,7 @@ tracker_data_insert_statement_with_string (const gchar *graph,
{
GError *actual_error = NULL;
TrackerProperty *property;
+ gint id = -1;
g_return_if_fail (subject != NULL);
g_return_if_fail (predicate != NULL);
@@ -1559,10 +1565,13 @@ tracker_data_insert_statement_with_string (const gchar *graph,
g_set_error (error, TRACKER_DATA_ERROR, TRACKER_DATA_ERROR_UNKNOWN_PROPERTY,
"Property '%s' not found in the ontology", predicate);
return;
- } else if (tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_RESOURCE) {
- g_set_error (error, TRACKER_DATA_ERROR, TRACKER_DATA_ERROR_INVALID_TYPE,
- "Property '%s' only accepts URIs", predicate);
- return;
+ } else {
+ if (tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_RESOURCE) {
+ g_set_error (error, TRACKER_DATA_ERROR, TRACKER_DATA_ERROR_INVALID_TYPE,
+ "Property '%s' only accepts URIs", predicate);
+ return;
+ }
+ id = tracker_property_get_id (property);
}
if (!tracker_data_insert_statement_common (graph, subject, predicate, object, &actual_error)) {
@@ -1575,7 +1584,7 @@ tracker_data_insert_statement_with_string (const gchar *graph,
}
tracker_db_journal_append_insert_statement (resource_buffer->id,
- tracker_data_query_resource_id (predicate),
+ (id != -1) ? id : tracker_data_query_resource_id (predicate),
object);
/* add value to metadata database */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]