[rygel] tracker: Avoid duplicate triplets



commit 958605b972c69a96275fa2bbdb100479d2e661b0
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Dec 21 15:22:12 2009 +0200

    tracker: Avoid duplicate triplets

 .../tracker/rygel-tracker-query-triplet.vala       |    8 ++++++++
 .../tracker/rygel-tracker-query-triplets.vala      |    6 +++++-
 .../tracker/rygel-tracker-search-container.vala    |    4 +++-
 3 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-query-triplet.vala b/src/plugins/tracker/rygel-tracker-query-triplet.vala
index 67b0dd4..6755100 100644
--- a/src/plugins/tracker/rygel-tracker-query-triplet.vala
+++ b/src/plugins/tracker/rygel-tracker-query-triplet.vala
@@ -49,6 +49,14 @@ public class Rygel.TrackerQueryTriplet {
               triplet.optional);
     }
 
+    public static bool equal_func (TrackerQueryTriplet a,
+                                   TrackerQueryTriplet b) {
+        return a.subject == b.subject &&
+               a.obj == b.obj &&
+               a.predicate == b.predicate &&
+               a.optional == b.optional;
+    }
+
     public string to_string () {
         string str = "";
 
diff --git a/src/plugins/tracker/rygel-tracker-query-triplets.vala b/src/plugins/tracker/rygel-tracker-query-triplets.vala
index 9fb1af2..03f8c8c 100644
--- a/src/plugins/tracker/rygel-tracker-query-triplets.vala
+++ b/src/plugins/tracker/rygel-tracker-query-triplets.vala
@@ -26,8 +26,12 @@ using Gee;
  * Represents a list of SPARQL Triplet
  */
 public class Rygel.TrackerQueryTriplets : ArrayList<TrackerQueryTriplet> {
+    public TrackerQueryTriplets () {
+        base ((EqualFunc) TrackerQueryTriplet.equal_func);
+    }
+
     public TrackerQueryTriplets.clone (TrackerQueryTriplets triplets) {
-        base ();
+        base ((EqualFunc) TrackerQueryTriplet.equal_func);
 
         foreach (var triplet in triplets) {
             this.add (new TrackerQueryTriplet.clone (triplet));
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index 2035aa7..2085712 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -88,7 +88,9 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
                 var triplet = new TrackerQueryTriplet (subject,
                                                        key,
                                                        variable);
-                optional.add (triplet);
+                if (!our_mandatory.contains (triplet)) {
+                    optional.add (triplet);
+                }
 
                 if (key == chain.last ()) {
                     variables.add (variable);



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