Merge lp:~zorba-coders/zorba/unordered-collection-tests into lp:zorba

Proposed by Ghislain Fourny on 2012-04-10
Status: Merged
Approved by: Markos Zaharioudakis on 2012-04-16
Approved revision: 10750
Merged at revision: 10764
Proposed branch: lp:~zorba-coders/zorba/unordered-collection-tests
Merge into: lp:zorba
Diff against target: 211 lines (+39/-23)
12 files modified
test/rbkt/ExpQueryResults/zorba/xqddf/daniel/ric6.xml.res (+2/-2)
test/rbkt/ExpQueryResults/zorba/xqddf/ic-foreignKey.xml.res (+1/-1)
test/rbkt/Queries/zorba/collections/modifier_3.xq (+1/-1)
test/rbkt/Queries/zorba/xqddf/daniel/i1.xq (+1/-1)
test/rbkt/Queries/zorba/xqddf/daniel/i2.xq (+1/-1)
test/rbkt/Queries/zorba/xqddf/daniel/i3.xq (+1/-1)
test/rbkt/Queries/zorba/xqddf/daniel/i4.xq (+1/-1)
test/rbkt/Queries/zorba/xqddf/daniel/i5.xq (+2/-2)
test/rbkt/Queries/zorba/xqddf/daniel/i6.xq (+4/-4)
test/rbkt/Queries/zorba/xqddf/daniel/ric6.xq (+8/-4)
test/rbkt/Queries/zorba/xqddf/daniel/undo1.xq (+7/-3)
test/rbkt/Queries/zorba/xqddf/ic-foreignKey.xq (+10/-2)
To merge this branch: bzr merge lp:~zorba-coders/zorba/unordered-collection-tests
Reviewer Review Type Date Requested Status
Markos Zaharioudakis 2012-04-10 Approve on 2012-04-16
Till Westmann 2012-04-10 Approve on 2012-04-10
Review via email: mp+101374@code.launchpad.net

Commit message

Fixed tests involving unordered collections, though assuming order for test results.

Description of the change

Fixed tests involving unordered collections, though assuming order for test results.

To post a comment you must log in.
Till Westmann (tillw) wrote :

Looks good to me and they work for me.

review: Approve
Markos Zaharioudakis (markos-za) wrote :

I do not understand this change. Even for unordered collections, there is a order, which is the order in which the nodes are returned by the collection() function. According to the XQDDF spec, the collection() function is stable, i.e., within a snapshot will always return the results in the same order, which by definition, coincides with the document order for the nodes in the collection. Furthermore, the XQDDF spec says that the result of idex probing functions is always in document order.

What is the problem that this change is supposed to fix?

review: Needs Information
Till Westmann (tillw) wrote :

Maybe I don't understand this right but I thought that
1) there is an order in a collection (within a snapshot)
2) this order extends to the document order for nodes that are descendants of different nodes in the collection.
However, the nodes that are inserted into a collection are copied and thus have a new identify and the order in the collection does not have to be
a) the document order of the source document or
b) the insertion order.

These tests take the nodes from fn:doc("auction.xml")//item, insert them into a collection and assume that the result of reading this collection is still in the document order found in auction.xml. I think that there is no reason why this order has to "survive" the insertion into and extraction from the collection.

Markos Zaharioudakis (markos-za) wrote :

> Maybe I don't understand this right but I thought that
> 1) there is an order in a collection (within a snapshot)
> 2) this order extends to the document order for nodes that are descendants of
> different nodes in the collection.
> However, the nodes that are inserted into a collection are copied and thus
> have a new identify and the order in the collection does not have to be
> a) the document order of the source document or
> b) the insertion order.
>
> These tests take the nodes from fn:doc("auction.xml")//item, insert them into
> a collection and assume that the result of reading this collection is still in
> the document order found in auction.xml. I think that there is no reason why
> this order has to "survive" the insertion into and extraction from the
> collection.

I agree with all of the above, but my point was that an expression like:

let $x as element() := dml:collection($ns:coll_1)[1]

is perfectly valid and returns a stable result, even if the collection is unordered. It is true that the result may be different depending on the underlying store (i.e., the result is implementation-dependent), but this is not a reason to forbid such tests from our test suite.

I guess the reason for this change is that the sausalito store returns a different result, right? If so, a better solution is to add the sausalito result as an alternative expected result. I believe the testdriver has the ability to handle multiple expectected result, and that this is done via the .spec files, but I do not remember the details.

review: Needs Fixing
Ghislain Fourny (gislenius) wrote :

Hi Markos, I mostly agree with your analysis, just not quite on the conclusion. I think that the issue is precisely that it is implementation-dependent (and stable), but not implementation-defined, which means that there is no, and should not be any (documented) rule in the Sausalito store that says which one comes first. If we go in the direction of adding expected results, I am afraid we might need to add all of the possibly returned nodes.

When suggesting these changes, I had the feeling that specifying an id instead of a position did not decrease the relevancy of the test (which test, for instance, index probing), while keeping the test result deterministic in spite of the "unorderedness" of the collection.

I would be fine either way, there are just more changes involved with the first direction.

Does it make sense?

Markos Zaharioudakis (markos-za) wrote :

ok, I (relunctantly) aprove.

review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job unordered-collection-tests-2012-04-16T13-34-01.133Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/rbkt/ExpQueryResults/zorba/xqddf/daniel/ric6.xml.res'
2--- test/rbkt/ExpQueryResults/zorba/xqddf/daniel/ric6.xml.res 2012-03-28 05:19:57 +0000
3+++ test/rbkt/ExpQueryResults/zorba/xqddf/daniel/ric6.xml.res 2012-04-10 13:15:27 +0000
4@@ -1,5 +1,5 @@
5 <?xml version="1.0" encoding="UTF-8"?>
6 <newline/><name>duteous nine eighteen </name><name>great </name><name>scarce brook </name><name>abhorr execution beckon rue </name><name>lived unsur </name><name>wine prevention </name><name>waters derive </name><name>subornation precepts laboured gentleman </name><name>secure desires </name><name>choughs stains </name><name>shall ingenious </name><name>heart </name><name>lessens promise </name><name>nearer conquerors over pays </name><name>abominable confession greet heaven </name><name>mole bonfires </name><name>compact paper </name><name>sake </name><name>strive octavius seals happiness </name><name>gaze wages proving english </name><name>practice space commune women </name><name>holds perhaps despair amorous </name><newline> a
7 </newline><name>duteous nine eighteen </name><name>great </name><name>scarce brook </name><name>abhorr execution beckon rue </name><name>lived unsur </name><name>wine prevention </name><name>waters derive </name><name>subornation precepts laboured gentleman </name><name>secure desires </name><name>choughs stains </name><name>shall ingenious </name><name>heart </name><name>lessens promise </name><name>nearer conquerors over pays </name><name>abominable confession greet heaven </name><name>mole bonfires </name><name>compact paper </name><name>sake </name><name>strive octavius seals happiness </name><name>gaze wages proving english </name><name>practice space commune women </name><name>holds perhaps despair amorous </name><newline> a
8-</newline><name>duteous nine eighteen </name><name>great </name><name>scarce brook </name><name>abhorr execution beckon rue </name><name>lived unsur </name><name>wine prevention </name><name>waters derive </name><name>subornation precepts laboured gentleman </name><name>secure desires </name><name>choughs stains </name><name>shall ingenious </name><name>heart </name><name>lessens promise </name><name>nearer conquerors over pays </name><name>abominable confession greet heaven </name><name>mole bonfires </name><name>compact paper </name><name>sake </name><name>strive octavius seals happiness </name><name>gaze wages proving english </name><name>practice space commune women </name><name>holds perhaps despair amorous </name><newline> a
9-</newline><name>great </name><name>scarce brook </name><name>abhorr execution beckon rue </name><name>lived unsur </name><name>wine prevention </name><name>waters derive </name><name>subornation precepts laboured gentleman </name><name>secure desires </name><name>choughs stains </name><name>shall ingenious </name><name>heart </name><name>lessens promise </name><name>nearer conquerors over pays </name><name>abominable confession greet heaven </name><name>mole bonfires </name><name>compact paper </name><name>sake </name><name>strive octavius seals happiness </name><name>gaze wages proving english </name><name>practice space commune women </name><name>holds perhaps despair amorous </name><name>duteous nine eighteen </name>
10\ No newline at end of file
11+</newline><name>duteous nine eighteen </name><name>great </name><name>shall ingenious </name><name>heart </name><name>lessens promise </name><name>nearer conquerors over pays </name><name>abominable confession greet heaven </name><name>mole bonfires </name><name>compact paper </name><name>sake </name><name>strive octavius seals happiness </name><name>gaze wages proving english </name><name>scarce brook </name><name>practice space commune women </name><name>holds perhaps despair amorous </name><name>abhorr execution beckon rue </name><name>lived unsur </name><name>wine prevention </name><name>waters derive </name><name>subornation precepts laboured gentleman </name><name>secure desires </name><name>choughs stains </name><newline> a
12+</newline><name>duteous nine eighteen </name><name>great </name><name>shall ingenious </name><name>heart </name><name>lessens promise </name><name>nearer conquerors over pays </name><name>abominable confession greet heaven </name><name>mole bonfires </name><name>compact paper </name><name>sake </name><name>strive octavius seals happiness </name><name>gaze wages proving english </name><name>scarce brook </name><name>practice space commune women </name><name>holds perhaps despair amorous </name><name>abhorr execution beckon rue </name><name>lived unsur </name><name>wine prevention </name><name>waters derive </name><name>subornation precepts laboured gentleman </name><name>secure desires </name><name>choughs stains </name>
13\ No newline at end of file
14
15=== modified file 'test/rbkt/ExpQueryResults/zorba/xqddf/ic-foreignKey.xml.res'
16--- test/rbkt/ExpQueryResults/zorba/xqddf/ic-foreignKey.xml.res 2012-03-28 05:19:57 +0000
17+++ test/rbkt/ExpQueryResults/zorba/xqddf/ic-foreignKey.xml.res 2012-04-10 13:15:27 +0000
18@@ -1,2 +1,2 @@
19 <?xml version="1.0" encoding="UTF-8"?>
20-<emps>1 2 3</emps><sales>1 2 1</sales>true
21\ No newline at end of file
22+<emps>1 2 3</emps><sales>1 1 2</sales>true
23
24=== modified file 'test/rbkt/Queries/zorba/collections/modifier_3.xq'
25--- test/rbkt/Queries/zorba/collections/modifier_3.xq 2012-03-28 05:19:57 +0000
26+++ test/rbkt/Queries/zorba/collections/modifier_3.xq 2012-04-10 13:15:27 +0000
27@@ -48,7 +48,7 @@
28 declare %ann:sequential function local:test4() {
29 try {
30 {
31- let $x as element() := dml:collection($ns:coll_1)[1]
32+ let $x as element() := dml:collection($ns:coll_1)[name() eq "a"]
33 return
34 replace node $x/x with <y/>;
35 }
36
37=== modified file 'test/rbkt/Queries/zorba/xqddf/daniel/i1.xq'
38--- test/rbkt/Queries/zorba/xqddf/daniel/i1.xq 2012-03-28 05:19:57 +0000
39+++ test/rbkt/Queries/zorba/xqddf/daniel/i1.xq 2012-04-10 13:15:27 +0000
40@@ -14,4 +14,4 @@
41 index_ddl:create($xqddf-test:index1);
42 (:xqddf:collection($xqddf-test:white-collection);:)
43
44-index_dml:probe-index-point-value($xqddf-test:index1, "United States")[1]
45+index_dml:probe-index-point-value($xqddf-test:index1, "United States")[@id="item0"]
46
47=== modified file 'test/rbkt/Queries/zorba/xqddf/daniel/i2.xq'
48--- test/rbkt/Queries/zorba/xqddf/daniel/i2.xq 2012-03-28 05:19:57 +0000
49+++ test/rbkt/Queries/zorba/xqddf/daniel/i2.xq 2012-04-10 13:15:27 +0000
50@@ -17,4 +17,4 @@
51
52 (:xqddf:collection($xqddf-test:white-collection);:)
53
54-index_dml:probe-index-point-value($xqddf-test:index1, "United States")[1]
55+index_dml:probe-index-point-value($xqddf-test:index1, "United States")[@id="item0"]
56
57=== modified file 'test/rbkt/Queries/zorba/xqddf/daniel/i3.xq'
58--- test/rbkt/Queries/zorba/xqddf/daniel/i3.xq 2012-03-28 05:19:57 +0000
59+++ test/rbkt/Queries/zorba/xqddf/daniel/i3.xq 2012-04-10 13:15:27 +0000
60@@ -17,4 +17,4 @@
61 index_dml:refresh-index($xqddf-test:index2);
62 (:xqddf:collection($xqddf-test:white-collection);:)
63
64-index_dml:probe-index-point-value($xqddf-test:index2, 2)[1]
65+index_dml:probe-index-point-value($xqddf-test:index2, 2)[@id="item2"]
66
67=== modified file 'test/rbkt/Queries/zorba/xqddf/daniel/i4.xq'
68--- test/rbkt/Queries/zorba/xqddf/daniel/i4.xq 2012-03-28 05:19:57 +0000
69+++ test/rbkt/Queries/zorba/xqddf/daniel/i4.xq 2012-04-10 13:15:27 +0000
70@@ -18,4 +18,4 @@
71 (:xqddf:collection($xqddf-test:white-collection);:)
72
73 index_dml:probe-index-range-value($xqddf-test:index2,
74- 1, 3, fn:true(), fn:true(), fn:true(), fn:false())[1]
75+ 1, 3, fn:true(), fn:true(), fn:true(), fn:false())[@id="item2"]
76
77=== modified file 'test/rbkt/Queries/zorba/xqddf/daniel/i5.xq'
78--- test/rbkt/Queries/zorba/xqddf/daniel/i5.xq 2012-03-28 05:19:57 +0000
79+++ test/rbkt/Queries/zorba/xqddf/daniel/i5.xq 2012-04-10 13:15:27 +0000
80@@ -19,10 +19,10 @@
81 (:xqddf:collection($xqddf-test:white-collection);:)
82
83 {
84-index_dml:probe-index-point-value($xqddf-test:index1, "United States")[1]
85+index_dml:probe-index-point-value($xqddf-test:index1, "United States")[@id="item0"]
86 },
87
88 {
89 index_dml:probe-index-range-value($xqddf-test:index2,
90- 1, 3, fn:true(), fn:true(), fn:true(), fn:false())[1]
91+ 1, 3, fn:true(), fn:true(), fn:true(), fn:false())[@id="item2"]
92 }
93
94=== modified file 'test/rbkt/Queries/zorba/xqddf/daniel/i6.xq'
95--- test/rbkt/Queries/zorba/xqddf/daniel/i6.xq 2012-03-28 05:19:57 +0000
96+++ test/rbkt/Queries/zorba/xqddf/daniel/i6.xq 2012-04-10 13:15:27 +0000
97@@ -23,14 +23,14 @@
98 },
99
100 {
101-index_dml:probe-index-point-value($xqddf-test:index1, "United States")[1]/name
102+index_dml:probe-index-point-value($xqddf-test:index1, "United States")[@id="item0"]/name
103 },
104
105 {
106-index_dml:probe-index-range-value($xqddf-test:index2, 1, 3, fn:true(), fn:true(), fn:true(), fn:false())[1]
107+index_dml:probe-index-range-value($xqddf-test:index2, 1, 3, fn:true(), fn:true(), fn:true(), fn:false())[@id="item2"]
108 },
109 {
110-rename node dml:collection($xqddf-test:white-collection)[1]/location as "location2";
111+rename node dml:collection($xqddf-test:white-collection)[@id="item0"]/location as "location2";
112 },
113 {
114 <newline> a
115@@ -38,5 +38,5 @@
116 },
117
118 {
119-index_dml:probe-index-point-value($xqddf-test:index1, "United States")[1]/name
120+index_dml:probe-index-point-value($xqddf-test:index1, "United States")[@id="item1"]/name
121 }
122
123=== modified file 'test/rbkt/Queries/zorba/xqddf/daniel/ric6.xq'
124--- test/rbkt/Queries/zorba/xqddf/daniel/ric6.xq 2012-03-28 05:19:57 +0000
125+++ test/rbkt/Queries/zorba/xqddf/daniel/ric6.xq 2012-04-10 13:15:27 +0000
126@@ -30,8 +30,8 @@
127 },
128 {
129 try{
130- (dml:insert-nodes($xqddf-test:blue-collection, (fn:doc("auction.xml")//item)[1]),
131- dml:delete-nodes(dml:collection($xqddf-test:blue-collection)[1]));
132+ (dml:insert-nodes($xqddf-test:blue-collection, (fn:doc("auction.xml")//item)[@id="item0"]),
133+ dml:delete-nodes(dml:collection($xqddf-test:blue-collection)[@id="item0"]));
134 }
135 catch * { "
136 cannot delete first item in blue collection";
137@@ -42,12 +42,16 @@
138 </newline>
139 },
140 {
141-dml:collection($xqddf-test:white-collection)/name
142+for $x in dml:collection($xqddf-test:white-collection)
143+order by $x/@id
144+return $x/name
145 },
146 {
147 <newline> a
148 </newline>
149 },
150 {
151-dml:collection($xqddf-test:blue-collection)/name
152+for $x in dml:collection($xqddf-test:blue-collection)
153+order by $x/@id
154+return $x/name
155 }
156
157=== modified file 'test/rbkt/Queries/zorba/xqddf/daniel/undo1.xq'
158--- test/rbkt/Queries/zorba/xqddf/daniel/undo1.xq 2012-03-28 05:19:57 +0000
159+++ test/rbkt/Queries/zorba/xqddf/daniel/undo1.xq 2012-04-10 13:15:27 +0000
160@@ -33,7 +33,7 @@
161 {
162 {
163 dml:insert-nodes($xqddf-test:blue-collection, <newnode/>);
164- dml:delete-nodes(dml:collection($xqddf-test:blue-collection)[1]);
165+ dml:delete-nodes(dml:collection($xqddf-test:blue-collection)[@id="item0"]);
166 ()
167 }
168 }
169@@ -46,12 +46,16 @@
170 </newline>
171 },
172 {
173-dml:collection($xqddf-test:white-collection)/name
174+for $x in dml:collection($xqddf-test:white-collection)
175+order by number(substring-after($x/@id, "item"))
176+return $x/name
177 },
178 {
179 <newline> a
180 </newline>
181 },
182 {
183-dml:collection($xqddf-test:blue-collection)/name
184+for $x in dml:collection($xqddf-test:blue-collection)
185+order by number(substring-after($x/@id, "item"))
186+return $x/name
187 }
188
189=== modified file 'test/rbkt/Queries/zorba/xqddf/ic-foreignKey.xq'
190--- test/rbkt/Queries/zorba/xqddf/ic-foreignKey.xq 2012-03-28 05:19:57 +0000
191+++ test/rbkt/Queries/zorba/xqddf/ic-foreignKey.xq 2012-04-10 13:15:27 +0000
192@@ -54,9 +54,17 @@
193 );
194
195
196-<emps>{ fn:data(dml:collection($m:empc)/id ) }</emps>
197+<emps>{
198+ for $n in dml:collection($m:empc)
199+ order by $n/id
200+ return fn:data($n/id)
201+}</emps>
202 ,
203-<sales>{ fn:data(dml:collection($m:trnc)/empid ) }</sales>
204+<sales>{
205+ for $n in dml:collection($m:trnc)
206+ order by $n/empid
207+ return fn:data($n/empid)
208+}</sales>
209 ,
210 every $x in dml:collection($m:trnc)
211 satisfies

Subscribers

People subscribed via source and target branches