[rygel] media-export: Locally cache parent in search



commit e27bc88f22c86b098206d336fa45042850771645
Author: Jens Georg <mail jensge org>
Date:   Sun May 16 13:20:36 2010 +0200

    media-export: Locally cache parent in search
    
    This reduces the number of additional queries necessary in searches.

 .../rygel-media-export-media-cache.vala            |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala b/src/plugins/media-export/rygel-media-export-media-cache.vala
index de47da6..0a5967f 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -175,7 +175,8 @@ public class Rygel.MediaExport.MediaCache : Object {
         "LEFT OUTER JOIN meta_data m " +
             "ON o.upnp_id = m.object_fk " +
     "WHERE %s " +
-        "ORDER BY o.type_fk ASC, " +
+        "ORDER BY o.parent ASC, " +
+                 "o.type_fk ASC, " +
                  "m.class ASC, " +
                  "m.track ASC, " +
                  "o.title ASC " +
@@ -427,7 +428,6 @@ public class Rygel.MediaExport.MediaCache : Object {
         args.append (v);
         long count = 0;
 
-        debug ("%s %ld %ld", container_id, offset, max_count);
         debug ("Parameters to bind: %u", args.n_values);
 
         Database.RowCallback callback = (statement) => {
@@ -458,6 +458,8 @@ public class Rygel.MediaExport.MediaCache : Object {
         args.append (v);
         v = max_count;
         args.append (v);
+        var last_parent = "";
+        MediaContainer parent = null;
 
         debug ("Parameters to bind: %u", args.n_values);
 
@@ -465,7 +467,11 @@ public class Rygel.MediaExport.MediaCache : Object {
             var child_id = statement.column_text (17);
             var parent_id = statement.column_text (18);
             try {
-                var parent = get_object (parent_id) as MediaContainer;
+                if (parent_id != last_parent) {
+                    parent = get_object (parent_id) as MediaContainer;
+                    last_parent = parent_id;
+                }
+
                 if (parent != null) {
                     children.add (get_object_from_statement (parent,
                                                              child_id,



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