[polari/wip/carlosg/tracker: 430/445] log-tool: Push updates in batches




commit 831634b55536e178a9b0b047db1fcb0dbb64734b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Feb 24 22:55:49 2019 +0100

    log-tool: Push updates in batches
    
    Allow a maximum of 500 elements to be pushed at once. Improves
    abysmal performance when importing logs for those spam heavy days.

 src/polari-log-tool.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/polari-log-tool.c b/src/polari-log-tool.c
index c33dc0a0..2985eccc 100644
--- a/src/polari-log-tool.c
+++ b/src/polari-log-tool.c
@@ -42,6 +42,7 @@ import_ready (GObject      *source,
   GString *sparql = g_string_new (NULL);
   char *account_id = NULL, *channel_name = NULL;
   gboolean is_room;
+  int batch_count = 0;
 
   messages = polari_tpl_importer_import_finish (importer,
                                                 result,
@@ -90,6 +91,17 @@ import_ready (GObject      *source,
               polari_message_get_sender (tpl_message),
               polari_message_get_text (tpl_message));
 #endif
+
+      batch_count++;
+
+      if (batch_count == 500)
+        {
+          tracker_sparql_connection_update (connection, sparql->str,
+                                            G_PRIORITY_DEFAULT, NULL, &error);
+          g_string_free (sparql, TRUE);
+          sparql = g_string_new (NULL);
+          batch_count = 0;
+        }
     }
   g_list_free_full (messages, (GDestroyNotify)polari_message_free);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]