[tracker] Precalculate duration and track count of playlists
- From: Ivan Frade <ifrade src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker] Precalculate duration and track count of playlists
- Date: Mon, 15 Jun 2009 08:53:10 -0400 (EDT)
commit bb8dd289a2a20679a2eede48caa98043cc9f44b5
Author: Ivan Frade <ivan frade nokia com>
Date: Mon Jun 15 15:52:22 2009 +0300
Precalculate duration and track count of playlists
Added properties to MediaList to store the duration and track count of
the playlists. Updated extractor to populate those data.
data/ontologies/33-nfo.ontology | 15 ++++++++++++
src/libtracker-common/tracker-statement-list.c | 13 ++++++++++
src/libtracker-common/tracker-statement-list.h | 4 +++
src/tracker-extract/tracker-extract-playlist.c | 29 ++++++++++++++----------
4 files changed, 49 insertions(+), 12 deletions(-)
---
diff --git a/data/ontologies/33-nfo.ontology b/data/ontologies/33-nfo.ontology
index 05ffcd3..22ae7f5 100644
--- a/data/ontologies/33-nfo.ontology
+++ b/data/ontologies/33-nfo.ontology
@@ -428,6 +428,20 @@ nfo:hasMediaFileListEntry a rdf:Property ;
rdfs:domain nfo:MediaList ;
rdfs:range nfo:MediaFileListEntry .
+# Propose in nepomuk
+nfo:entryCounter a rdf:Property ;
+ rdfs:label "entry Counter" ;
+ rdfs:comment "Number of entries in the list. Optimize some common queries" ;
+ rdfs:domain nfo:MediaList ;
+ rdfs:range xsd:integer .
+
+nfo:listDuration a rdf:Property ;
+ rdfs:label "List duration" ;
+ rdfs:comment "Sum of the duration of all items in the list. Optimize some common queries. In seconds";
+ rdfs:domain nfo:MediaList ;
+ rdfs:range xsd:integer .
+
+# Propose in nepomuk
nfo:listPosition a rdf:Property ;
rdfs:label "list position" ;
rdfs:comment "Position of an entry in a list. Double, to optimize the poor insertions" ;
@@ -435,6 +449,7 @@ nfo:listPosition a rdf:Property ;
rdfs:domain nfo:MediaFileListEntry ;
rdfs:range xsd:double .
+# Propose in nepomuk
nfo:entryContent a rdf:Property ;
rdfs:label "Entry content" ;
rdfs:Comment "URI to the element in certain position of the list" ;
diff --git a/src/libtracker-common/tracker-statement-list.c b/src/libtracker-common/tracker-statement-list.c
index 77f3f0b..61f965d 100644
--- a/src/libtracker-common/tracker-statement-list.c
+++ b/src/libtracker-common/tracker-statement-list.c
@@ -100,6 +100,19 @@ tracker_statement_list_insert_with_int64 (GPtrArray *statements,
g_free (value_str);
}
+void
+tracker_statement_list_insert_with_uint (GPtrArray *statements,
+ const gchar *subject,
+ const gchar *predicate,
+ guint32 value)
+{
+ gchar *value_str;
+
+ value_str = g_strdup_printf ("%" G_GUINT32_FORMAT, value);
+ tracker_statement_list_insert (statements, subject, predicate, value_str);
+ g_free (value_str);
+}
+
void
tracker_statement_list_insert_with_double (GPtrArray *statements,
diff --git a/src/libtracker-common/tracker-statement-list.h b/src/libtracker-common/tracker-statement-list.h
index 6a18a33..dfba1f4 100644
--- a/src/libtracker-common/tracker-statement-list.h
+++ b/src/libtracker-common/tracker-statement-list.h
@@ -39,6 +39,10 @@ void tracker_statement_list_insert_with_int64 (GPtrArray *statements,
const gchar *subject,
const gchar *predicate,
gint64 value);
+void tracker_statement_list_insert_with_uint (GPtrArray *statements,
+ const gchar *subject,
+ const gchar *predicate,
+ guint32 value);
void tracker_statement_list_insert_with_double (GPtrArray *statements,
const gchar *subject,
const gchar *predicate,
diff --git a/src/tracker-extract/tracker-extract-playlist.c b/src/tracker-extract/tracker-extract-playlist.c
index ebbdf5c..52973d7 100644
--- a/src/tracker-extract/tracker-extract-playlist.c
+++ b/src/tracker-extract/tracker-extract-playlist.c
@@ -38,9 +38,12 @@
#include "tracker-main.h"
-#define PLAYLIST_PROPERTY_NO_TRACKS "Playlist:Songs"
-#define PLAYLIST_PROPERTY_DURATION "Playlist:Duration"
+#define PLAYLIST_PROPERTY_NO_TRACKS "entryCounter"
+#define PLAYLIST_PROPERTY_DURATION "listDuration"
+/*
+ FIXME Decide what to do with this in nepomuk
#define PLAYLIST_PROPERTY_CALCULATED "Playlist:ValidDuration"
+*/
#define PLAYLIST_DEFAULT_NO_TRACKS 0
#define PLAYLIST_DEFAULT_DURATION 0
@@ -77,27 +80,29 @@ static void
entry_parsed (TotemPlParser *parser, const gchar *to_uri, GHashTable *to_metadata, gpointer user_data)
{
gchar *duration;
+ gchar *anon_node;
PlaylistMetadata *data;
data = (PlaylistMetadata *)user_data;
+ data->track_counter++;
- tracker_statement_list_insert (data->metadata, ":1", RDF_TYPE,
+ anon_node = g_strdup_printf (":%" G_GUINT32_FORMAT, data->track_counter);
+
+ tracker_statement_list_insert (data->metadata, anon_node, RDF_TYPE,
NFO_PREFIX "MediaFileListEntry");
- tracker_statement_list_insert (data->metadata, ":1",
+ tracker_statement_list_insert (data->metadata, anon_node,
NFO_PREFIX "entryContent",
to_uri);
- data->track_counter++;
-
- tracker_statement_list_insert_with_int (data->metadata, ":1",
+ tracker_statement_list_insert_with_int (data->metadata, anon_node,
NFO_PREFIX "listPosition",
data->track_counter);
tracker_statement_list_insert (data->metadata, data->uri,
NFO_PREFIX "hasMediaFileListEntry",
- ":1");
+ anon_node);
duration = g_hash_table_lookup (to_metadata, TOTEM_PL_PARSER_FIELD_DURATION);
@@ -147,15 +152,15 @@ extract_playlist (const gchar *uri,
g_warning ("Undefined result in totem-plparser");
}
- /* TODO
tracker_statement_list_insert_with_int64 (metadata, uri,
- PLAYLIST_PROPERTY_DURATION,
+ NFO_PREFIX PLAYLIST_PROPERTY_DURATION,
data.total_time);
tracker_statement_list_insert_with_uint (metadata, uri,
- PLAYLIST_PROPERTY_NO_TRACKS,
+ NFO_PREFIX PLAYLIST_PROPERTY_NO_TRACKS,
data.track_counter);
-
+/*
+ TODO
tracker_statement_list_insert_with_int64 (metadata, uri,
PLAYLIST_PROPERTY_CALCULATED,
data.total_time);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]