[rygel] media-export: Dump statistics of items after start



commit 3b8414c6da523cdc75c95211b3f9d1c370eb114c
Author: Jens Georg <mail jensge org>
Date:   Sun Apr 17 13:12:12 2011 +0300

    media-export: Dump statistics of items after start

 .../rygel-media-export-media-cache.vala            |   12 +++++++++++-
 .../rygel-media-export-root-container.vala         |    1 +
 .../rygel-media-export-sql-factory.vala            |    6 ++++++
 3 files changed, 18 insertions(+), 1 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 4004a51..23e77a3 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -391,7 +391,17 @@ public class Rygel.MediaExport.MediaCache : Object {
         }
     }
 
-
+    public void debug_statistics () {
+        try {
+            debug ("Database statistics:");
+            var cursor = this.exec_cursor (SQLString.STATISTICS);
+            foreach (var statement in cursor) {
+                debug ("%s: %d",
+                       statement.column_text (0),
+                       statement.column_int (1));
+            }
+        } catch (Error error) { }
+    }
 
     private void save_metadata (Rygel.MediaItem item) throws Error {
         // Fill common properties
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index b2c80e5..bdbf683 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -395,6 +395,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
 
     private void on_initial_harvesting_done () {
         this.harvester.disconnect (this.harvester_signal_id);
+        this.media_db.debug_statistics ();
 
         this.filesystem_container.container_updated.connect( () => {
             this.add_default_virtual_folders ();
diff --git a/src/plugins/media-export/rygel-media-export-sql-factory.vala b/src/plugins/media-export/rygel-media-export-sql-factory.vala
index 95b719d..243e6d5 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -65,6 +65,7 @@ internal enum Rygel.MediaExport.SQLString {
     INDEX_COMMON,
     SCHEMA,
     EXISTS_CACHE,
+    STATISTICS,
 }
 
 internal class Rygel.MediaExport.SQLFactory : Object {
@@ -239,6 +240,9 @@ internal class Rygel.MediaExport.SQLFactory : Object {
     "SELECT m.size, o.timestamp, o.uri FROM Object o " +
         "JOIN meta_data m ON o.upnp_id = m.object_fk";
 
+    private const string STATISTICS_STRING =
+    "SELECT class, count(1) FROM meta_data GROUP BY class";
+
     public unowned string make (SQLString query) {
         switch (query) {
             case SQLString.SAVE_METADATA:
@@ -277,6 +281,8 @@ internal class Rygel.MediaExport.SQLFactory : Object {
                 return EXISTS_CACHE_STRING;
             case SQLString.TABLE_CLOSURE:
                 return CREATE_CLOSURE_TABLE;
+            case SQLString.STATISTICS:
+                return STATISTICS_STRING;
             default:
                 assert_not_reached ();
         }



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