Merge lp:~mhr3/libunity/no-double-push into lp:~unity-team/libunity/libunity-7.0

Proposed by Michal Hruby on 2013-05-02
Status: Rejected
Rejected by: Michal Hruby on 2013-05-10
Proposed branch: lp:~mhr3/libunity/no-double-push
Merge into: lp:~unity-team/libunity/libunity-7.0
Diff against target: 140 lines (+53/-8)
3 files modified
debian/libunity9.symbols (+1/-0)
src/unity-aggregator-scope-private.vala (+43/-8)
src/unity-scope-channel.vala (+9/-0)
To merge this branch: bzr merge lp:~mhr3/libunity/no-double-push
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2013-05-03
Unity Team 2013-05-02 Pending
Review via email: mp+162261@code.launchpad.net

Commit message

Make sure we don't duplicate results when pushing.

Description of the change

Make sure we don't duplicate results when pushing.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mhr3/libunity/no-double-push updated on 2013-05-03
378. By Michal Hruby on 2013-05-03

Invalidate pushed models after each clear

379. By Michal Hruby on 2013-05-03

Update symbols

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

379. By Michal Hruby on 2013-05-03

Update symbols

378. By Michal Hruby on 2013-05-03

Invalidate pushed models after each clear

377. By Michal Hruby on 2013-05-02

Check scope id when re-pushing results

376. By Michal Hruby on 2013-05-02

Don't duplicate results on double push

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/libunity9.symbols'
2--- debian/libunity9.symbols 2013-05-01 22:30:59 +0000
3+++ debian/libunity9.symbols 2013-05-03 22:43:33 +0000
4@@ -369,6 +369,7 @@
5 unity_internal_results_synchronizer_prepare_row_buf@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
6 unity_internal_results_synchronizer_remove_provider@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
7 unity_internal_results_synchronizer_set_merge_strategy@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
8+ unity_internal_scope_channel_check_pushed_models@Base 0replaceme
9 unity_internal_scope_channel_construct@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
10 unity_internal_scope_channel_create_channel@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
11 unity_internal_scope_channel_get_filter_by_id@Base 6.91.9daily13.04.10ubuntu.unity.experimental.certified
12
13=== modified file 'src/unity-aggregator-scope-private.vala'
14--- src/unity-aggregator-scope-private.vala 2013-05-03 18:43:12 +0000
15+++ src/unity-aggregator-scope-private.vala 2013-05-03 22:43:33 +0000
16@@ -1454,10 +1454,11 @@
17
18 unowned Variant subscopes_filter_variant = hints[SEARCH_SUBSCOPES_HINT];
19 uint subscope_filter_tag = 0;
20+ string[] enabled_subscopes = {};
21 if (subscopes_filter_variant != null && subscopes_filter_variant.get_type_string () == "as")
22 {
23- string[] subscopes = (string[]) subscopes_filter_variant;
24- subscope_filter_tag = string.joinv (";", subscopes).hash ();
25+ enabled_subscopes = (string[]) subscopes_filter_variant;
26+ subscope_filter_tag = string.joinv (";", enabled_subscopes).hash ();
27 }
28
29 bool invalidate_last_search = filter_row_variant != null;
30@@ -1498,6 +1499,8 @@
31 // that are not searched this time disappear
32 synchronizer.clear ();
33
34+ channel.check_pushed_models (search_string);
35+
36 // if this search will query fewer sources than the last one, there could
37 // be a race where results from the last query start appearing for this
38 // one (cause the sources took a while to complete the search)
39@@ -1579,7 +1582,12 @@
40
41 foreach (var provider in channel.get_pushed_models (search_string))
42 {
43- push_results_internal (synchronizer, provider);
44+ unowned string provider_scope_id = provider.get_data<string> ("scope-id");
45+ if (subscope_filter_tag == 0 ||
46+ (subscope_filter_tag != 0 && provider_scope_id in enabled_subscopes))
47+ {
48+ push_results_internal (synchronizer, provider);
49+ }
50 }
51
52 int64 search_start_time = 0;
53@@ -1893,6 +1901,9 @@
54 throw new ScopeError.REQUEST_FAILED ("Can't deserialize model");
55
56 var provider = model_obj as Dee.SerializableModel;
57+ var synchronizer_tag = new Dee.ModelTag<Dee.ModelIter> (provider);
58+ provider.set_data<Dee.ModelTag<Dee.ModelIter>> ("synchronizer-tag",
59+ synchronizer_tag);
60 provider.set_data<string> ("uid", "remote:%s".printf (source_scope_id));
61 provider.set_data<string> ("scope-id", source_scope_id);
62 var sync = _scopes.get_synchronizer (channel_id);
63@@ -1909,6 +1920,28 @@
64 throw new ScopeError.REQUEST_FAILED ("Merging not implemented");
65 }
66
67+ // are we trying to re-push results for the same scope? if so, remove
68+ // the previous pushed results first
69+ foreach (var pushed_model in channel.get_pushed_models (search_string))
70+ {
71+ if (pushed_model.get_data<string> ("scope-id") == source_scope_id)
72+ {
73+ var tag = pushed_model.get_data<Dee.ModelTag<Dee.ModelIter>> ("synchronizer-tag");
74+ var iter = pushed_model.get_first_iter ();
75+ var end_iter = pushed_model.get_last_iter ();
76+ while (iter != end_iter)
77+ {
78+ var target_iter = tag[pushed_model, iter];
79+ if (target_iter != null)
80+ {
81+ sync.receiver.remove (target_iter);
82+ tag.clear (pushed_model, iter);
83+ }
84+ iter = pushed_model.next (iter);
85+ }
86+ }
87+ }
88+
89 channel.register_pushed_model (search_string, provider);
90
91 push_results_internal (sync, provider);
92@@ -1929,21 +1962,23 @@
93 private void push_results_internal (ResultsSynchronizer synchronizer,
94 Dee.SerializableModel provider)
95 {
96+ var tag = provider.get_data<Dee.ModelTag<Dee.ModelIter>> ("synchronizer-tag");
97 var iter = provider.get_first_iter ();
98 var end = provider.get_last_iter ();
99 /* everything is prepared now, we can push results directly
100 * into the synchronizer */
101+ unowned string source_scope_id = provider.get_data<string> ("scope-id");
102 while (iter != end)
103 {
104- unowned string source_scope_id = provider.get_data<string> ("scope-id");
105 unowned Variant[] row_buf = synchronizer.prepare_row_buf (provider, iter);
106- synchronizer.merge_strategy.merge_result (source_scope_id,
107- synchronizer.receiver, row_buf);
108- // inform the synchronizer (or rather its listeners) about the changes
109- synchronizer.transaction_complete (provider, source_scope_id);
110+ var target_iter = synchronizer.merge_strategy.merge_result (
111+ source_scope_id, synchronizer.receiver, row_buf);
112+ tag[provider, iter] = target_iter;
113
114 iter = provider.next (iter);
115 }
116+ // inform the synchronizer (or rather its listeners) about the changes
117+ synchronizer.transaction_complete (provider, source_scope_id);
118 }
119
120 /* DBus properties */
121
122=== modified file 'src/unity-scope-channel.vala'
123--- src/unity-scope-channel.vala 2013-05-01 20:56:04 +0000
124+++ src/unity-scope-channel.vala 2013-05-03 22:43:33 +0000
125@@ -223,6 +223,15 @@
126 pushed_models.append (model);
127 }
128
129+ public void check_pushed_models (string search_string)
130+ {
131+ if (last_push_search_string != search_string)
132+ {
133+ // invalidate pushed models
134+ pushed_models = new GLib.List<Dee.SerializableModel> ();
135+ }
136+ }
137+
138 public GLib.List<unowned Dee.SerializableModel> get_pushed_models (string search_string)
139 {
140 if (last_push_search_string != search_string)

Subscribers

People subscribed via source and target branches

to all changes: