[tracker/sparql-update: 16/16] libtracker-data: Move blank_node handling to shared function
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sparql-update: 16/16] libtracker-data: Move blank_node handling to shared function
- Date: Mon, 14 Mar 2011 09:20:33 +0000 (UTC)
commit 9293b85b03b679962ce70e5dc4116a24d2a7fd04
Author: Philip Van Hoof <philip codeminded be>
Date: Fri Mar 11 18:18:27 2011 +0100
libtracker-data: Move blank_node handling to shared function
src/libtracker-data/tracker-data-update.c | 106 +++++++++++++---------------
1 files changed, 49 insertions(+), 57 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 2cba3a3..cd1278f 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2267,6 +2267,49 @@ tracker_data_insert_statement (const gchar *graph,
}
}
+
+static void
+handle_blank_node (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object,
+ const gchar *graph,
+ GError **error)
+{
+ GError *actual_error = NULL;
+ /* anonymous blank node used as object in a statement */
+ const gchar *blank_uri;
+
+ if (blank_buffer.subject != NULL) {
+ if (strcmp (blank_buffer.subject, object) == 0) {
+ /* object still in blank buffer, need to flush buffer */
+ tracker_data_blank_buffer_flush (&actual_error);
+
+ if (actual_error) {
+ g_propagate_error (error, actual_error);
+ return;
+ }
+ }
+ }
+
+ blank_uri = g_hash_table_lookup (blank_buffer.table, object);
+
+ if (blank_uri != NULL) {
+ /* now insert statement referring to blank node */
+ tracker_data_update_statement (graph, subject, predicate, blank_uri, &actual_error);
+
+ g_hash_table_remove (blank_buffer.table, object);
+
+ if (actual_error) {
+ g_propagate_error (error, actual_error);
+ return;
+ }
+
+ return;
+ } else {
+ g_critical ("Blank node '%s' not found", object);
+ }
+}
+
void
tracker_data_insert_statement_with_uri (const gchar *graph,
const gchar *subject,
@@ -2306,37 +2349,11 @@ tracker_data_insert_statement_with_uri (const gchar *graph,
/* subjects and objects starting with `:' are anonymous blank nodes */
if (g_str_has_prefix (object, ":")) {
- /* anonymous blank node used as object in a statement */
- const gchar *blank_uri;
-
- if (blank_buffer.subject != NULL) {
- if (strcmp (blank_buffer.subject, object) == 0) {
- /* object still in blank buffer, need to flush buffer */
- tracker_data_blank_buffer_flush (&actual_error);
-
- if (actual_error) {
- g_propagate_error (error, actual_error);
- return;
- }
- }
- }
-
- blank_uri = g_hash_table_lookup (blank_buffer.table, object);
-
- if (blank_uri != NULL) {
- /* now insert statement referring to blank node */
- tracker_data_insert_statement (graph, subject, predicate, blank_uri, &actual_error);
-
- g_hash_table_remove (blank_buffer.table, object);
-
- if (actual_error) {
- g_propagate_error (error, actual_error);
- return;
- }
+ handle_blank_node (subject, predicate, object, graph, &actual_error);
+ if (actual_error) {
+ g_propagate_error (error, actual_error);
return;
- } else {
- g_critical ("Blank node '%s' not found", object);
}
}
@@ -2539,37 +2556,12 @@ tracker_data_update_statement_with_uri (const gchar *graph,
/* subjects and objects starting with `:' are anonymous blank nodes */
if (g_str_has_prefix (object, ":")) {
- /* anonymous blank node used as object in a statement */
- const gchar *blank_uri;
- if (blank_buffer.subject != NULL) {
- if (strcmp (blank_buffer.subject, object) == 0) {
- /* object still in blank buffer, need to flush buffer */
- tracker_data_blank_buffer_flush (&actual_error);
-
- if (actual_error) {
- g_propagate_error (error, actual_error);
- return;
- }
- }
- }
-
- blank_uri = g_hash_table_lookup (blank_buffer.table, object);
-
- if (blank_uri != NULL) {
- /* now insert statement referring to blank node */
- tracker_data_update_statement (graph, subject, predicate, blank_uri, &actual_error);
-
- g_hash_table_remove (blank_buffer.table, object);
-
- if (actual_error) {
- g_propagate_error (error, actual_error);
- return;
- }
+ handle_blank_node (subject, predicate, object, graph, &actual_error);
+ if (actual_error) {
+ g_propagate_error (error, actual_error);
return;
- } else {
- g_critical ("Blank node '%s' not found", object);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]