Merge lp:~davidagraf/zorba/paging_with_refs into lp:zorba
- paging_with_refs
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | David Graf |
Approved revision: | 10996 |
Merged at revision: | 11037 |
Proposed branch: | lp:~davidagraf/zorba/paging_with_refs |
Merge into: | lp:zorba |
Diff against target: |
697 lines (+278/-53) 27 files modified
include/zorba/pregenerated/diagnostic_list.h (+2/-0) modules/com/zorba-xquery/www/modules/pregenerated/errors.xq (+4/-0) modules/com/zorba-xquery/www/modules/store/dynamic/collections/dml.xq (+29/-0) modules/com/zorba-xquery/www/modules/store/static/collections/dml.xq (+27/-0) src/diagnostics/diagnostic_en.xml (+4/-0) src/diagnostics/pregenerated/diagnostic_list.cpp (+3/-0) src/diagnostics/pregenerated/dict_en.cpp (+1/-0) src/functions/func_sequences_impl.cpp (+13/-10) src/functions/pregenerated/func_collections.cpp (+28/-0) src/functions/pregenerated/function_enum.h (+2/-0) src/runtime/collections/collections_impl.cpp (+41/-13) src/runtime/collections/pregenerated/collections.h (+2/-0) src/runtime/spec/collections/collections.xml (+27/-7) src/store/api/collection.h (+4/-2) src/store/naive/collection.h (+3/-1) src/store/naive/simple_collection.cpp (+32/-4) src/store/naive/simple_collection.h (+6/-2) test/rbkt/ExpQueryResults/zorba/collections/paging_1.xml.res (+1/-1) test/rbkt/ExpQueryResults/zorba/collections/paging_2.xml.res (+1/-1) test/rbkt/ExpQueryResults/zorba/collections/paging_3.xml.res (+1/-1) test/rbkt/ExpQueryResults/zorba/collections/paging_4.xml.res (+1/-1) test/rbkt/Queries/zorba/collections/paging_1.xq (+12/-3) test/rbkt/Queries/zorba/collections/paging_2.xq (+4/-2) test/rbkt/Queries/zorba/collections/paging_3.xq (+5/-3) test/rbkt/Queries/zorba/collections/paging_4.xq (+4/-2) test/rbkt/Queries/zorba/collections/paging_5.spec (+1/-0) test/rbkt/Queries/zorba/collections/paging_5.xq (+20/-0) |
To merge this branch: | bzr merge lp:~davidagraf/zorba/paging_with_refs |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Till Westmann | Approve | ||
Review via email: mp+123509@code.launchpad.net |
This proposal supersedes a proposal from 2012-08-14.
Commit message
feature: skipping nodes in a collection using a node-reference
Description of the change
Resubmit to trigger patchqueue.
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal | # |
David Graf (davidagraf) wrote : Posted in a previous version of this proposal | # |
> - Given the documentation, I was not able to figure out why the collection
> function takes the $start and $skip parameters. Is one of the ignored if
> the other one is given? Does skipping start at the item identified by
> $start? If so, would it make sense to separate the two ways of skipping
> into separate functions?
No, none is ignored. If you don't wanna skip, you pass 0. If you wanna skip only, you use db:collection(
But as already mentioned in a yammer message, I am thinking about replacing the $skip parameter with an optimisation for fn:subsequence(
>
Fixed everything below:
> - improved
> The reference to first node to return
> =>
> A reference to the first node to return.
>
> - What does "order is implementation dependent" mean for ordered collections?
>
> - Error message can be improved according to Paul's style:
>
> Node reference $1 doesn't reference a node in collection $2
> =>
> $1: doesn't reference a node in collection ($2)
>
> - typo:
> if the passed reference $start doesn't reference
> a _not_ from the collection identified by $name.
>
> - the documentation mention zerr:ZAPI0028 if the given URI
> is not a valid node reference
Till Westmann (tillw) wrote : Posted in a previous version of this proposal | # |
There are a few small fixes that I've sent as a patch via email as I could not push them into this branch. Once this patch is applied this branch works for me.
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal | # |
The patch looks great.
As far as I can tell, the documentation should also mention the error zerr:ZAPI0028.
David Graf (davidagraf) wrote : Posted in a previous version of this proposal | # |
> There are a few small fixes that I've sent as a patch via email as I could not
> push them into this branch. Once this patch is applied this branch works for
> me.
I patched you patch. Unfortunately, I needed to do it by hand. Did you create the patch with bzr diff?
David Graf (davidagraf) wrote : Posted in a previous version of this proposal | # |
> The patch looks great.
>
> As far as I can tell, the documentation should also mention the error
> zerr:ZAPI0028.
done
Till Westmann (tillw) : Posted in a previous version of this proposal | # |
Matthias Brantner (matthias-brantner) : Posted in a previous version of this proposal | # |
Till Westmann (tillw) : | # |
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~davidagraf/zorba/paging_with_refs into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job paging_
The final status was:
2 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~davidagraf/zorba/paging_with_refs into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job paging_
The final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job paging_
All tests succeeded!
Preview Diff
1 | === modified file 'include/zorba/pregenerated/diagnostic_list.h' | |||
2 | --- include/zorba/pregenerated/diagnostic_list.h 2012-09-12 08:06:26 +0000 | |||
3 | +++ include/zorba/pregenerated/diagnostic_list.h 2012-09-12 11:09:20 +0000 | |||
4 | @@ -750,6 +750,8 @@ | |||
5 | 750 | 750 | ||
6 | 751 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0065_STRINGS_IN_POOL; | 751 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0065_STRINGS_IN_POOL; |
7 | 752 | 752 | ||
8 | 753 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0066_REFERENCED_NODE_NOT_IN_COLLECTION; | ||
9 | 754 | |||
10 | 753 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode XSST0001; | 755 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode XSST0001; |
11 | 754 | 756 | ||
12 | 755 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode XSST0002; | 757 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode XSST0002; |
13 | 756 | 758 | ||
14 | === modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq' | |||
15 | --- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2012-09-10 22:53:04 +0000 | |||
16 | +++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2012-09-12 11:09:20 +0000 | |||
17 | @@ -781,6 +781,10 @@ | |||
18 | 781 | 781 | ||
19 | 782 | (:~ | 782 | (:~ |
20 | 783 | :) | 783 | :) |
21 | 784 | declare variable $zerr:ZSTR0066 as xs:QName := fn:QName($zerr:NS, "zerr:ZSTR0066"); | ||
22 | 785 | |||
23 | 786 | (:~ | ||
24 | 787 | :) | ||
25 | 784 | declare variable $zerr:XSST0001 as xs:QName := fn:QName($zerr:NS, "zerr:XSST0001"); | 788 | declare variable $zerr:XSST0001 as xs:QName := fn:QName($zerr:NS, "zerr:XSST0001"); |
26 | 785 | 789 | ||
27 | 786 | (:~ | 790 | (:~ |
28 | 787 | 791 | ||
29 | === modified file 'modules/com/zorba-xquery/www/modules/store/dynamic/collections/dml.xq' | |||
30 | --- modules/com/zorba-xquery/www/modules/store/dynamic/collections/dml.xq 2012-09-10 22:53:04 +0000 | |||
31 | +++ modules/com/zorba-xquery/www/modules/store/dynamic/collections/dml.xq 2012-09-12 11:09:20 +0000 | |||
32 | @@ -632,6 +632,35 @@ | |||
33 | 632 | 632 | ||
34 | 633 | 633 | ||
35 | 634 | (:~ | 634 | (:~ |
36 | 635 | : The collection function returns the sequence of nodes and/or json items | ||
37 | 636 | : that belong to the collection identified by the given name. | ||
38 | 637 | : The parameters $start and $skip can be used to skip over some items at | ||
39 | 638 | : the beginning of the collection. If both are given, both are applied: | ||
40 | 639 | : first $start to skip to the referenced item and then $skip to skip an | ||
41 | 640 | : additional number of items. | ||
42 | 641 | : | ||
43 | 642 | : @param $name The name of the collection. | ||
44 | 643 | : @param $start A reference to the first item to return. All items before | ||
45 | 644 | are skipped. | ||
46 | 645 | : @param $skip The number of collection items to skip. | ||
47 | 646 | : | ||
48 | 647 | : @return The sequence contained in the given collection. | ||
49 | 648 | : | ||
50 | 649 | : @error zerr:ZAPI0028 If the given URI is not a valid node | ||
51 | 650 | : position computed by the <tt>np:node-position</tt> function. | ||
52 | 651 | : @error zerr:ZDDY0003 If available collections does not provide a mapping | ||
53 | 652 | : for the expanded QName $name. | ||
54 | 653 | : @error zerr:ZSTR0066 If the passed reference $start does not reference | ||
55 | 654 | : a node from the collection identified by $name. | ||
56 | 655 | : | ||
57 | 656 | :) | ||
58 | 657 | declare function | ||
59 | 658 | dml:collection($name as xs:QName, | ||
60 | 659 | $start as xs:anyURI, | ||
61 | 660 | $skip as xs:integer) as item()* external; | ||
62 | 661 | |||
63 | 662 | |||
64 | 663 | (:~ | ||
65 | 635 | : The collection-name function returns the name of the collection the given | 664 | : The collection-name function returns the name of the collection the given |
66 | 636 | : item (node or json item) belongs to. | 665 | : item (node or json item) belongs to. |
67 | 637 | : | 666 | : |
68 | 638 | 667 | ||
69 | === modified file 'modules/com/zorba-xquery/www/modules/store/static/collections/dml.xq' | |||
70 | --- modules/com/zorba-xquery/www/modules/store/static/collections/dml.xq 2012-09-10 22:53:04 +0000 | |||
71 | +++ modules/com/zorba-xquery/www/modules/store/static/collections/dml.xq 2012-09-12 11:09:20 +0000 | |||
72 | @@ -884,6 +884,33 @@ | |||
73 | 884 | 884 | ||
74 | 885 | 885 | ||
75 | 886 | (:~ | 886 | (:~ |
76 | 887 | : The collection function returns the sequence of nodes and/or json items | ||
77 | 888 | : that belong to the collection identified by the given name. | ||
78 | 889 | : The parameters $start and $skip can be used to skip over some items at | ||
79 | 890 | : the beginning of the collection. If both are given, both are applied: | ||
80 | 891 | : first $start to skip to the referenced item and then $skip to skip an | ||
81 | 892 | : additional number of items. | ||
82 | 893 | : | ||
83 | 894 | : @param $name The name of the collection. | ||
84 | 895 | : @param $start The reference to the first item to return. All items before | ||
85 | 896 | are skipped. | ||
86 | 897 | : @param $skip The number of collection items to skip. | ||
87 | 898 | : | ||
88 | 899 | : @return The sequence contained in the given collection. | ||
89 | 900 | : | ||
90 | 901 | : @error zerr:ZAPI0028 If the given URI is not a valid node | ||
91 | 902 | : position computed by the <tt>np:node-position</tt> function. | ||
92 | 903 | : @error zerr:ZDDY0001 if the collection identified by $name is not declared. | ||
93 | 904 | : @error zerr:ZDDY0003 if the collection identified by $name is not available. | ||
94 | 905 | : @error zerr:ZSTR0066 if the passed reference $start does not reference | ||
95 | 906 | : a node from the collection identified by $name. | ||
96 | 907 | : | ||
97 | 908 | :) | ||
98 | 909 | declare function | ||
99 | 910 | cdml:collection($name as xs:QName, | ||
100 | 911 | $start as xs:anyURI, | ||
101 | 912 | $skip as xs:integer) as item()* external; | ||
102 | 913 | (:~ | ||
103 | 887 | : The collection-name function returns the name of the collection the given | 914 | : The collection-name function returns the name of the collection the given |
104 | 888 | : item (node or json item) belongs to. | 915 | : item (node or json item) belongs to. |
105 | 889 | : | 916 | : |
106 | 890 | 917 | ||
107 | === modified file 'src/diagnostics/diagnostic_en.xml' | |||
108 | --- src/diagnostics/diagnostic_en.xml 2012-09-12 08:06:26 +0000 | |||
109 | +++ src/diagnostics/diagnostic_en.xml 2012-09-12 11:09:20 +0000 | |||
110 | @@ -2433,6 +2433,10 @@ | |||
111 | 2433 | <value>Zorba did not close properly, objects may still in memory.\n$1 referenced URI(s) remain in the string pool.\nFor help avoiding this message please refer to http://www.zorba-xquery.com/html/documentation in section General Architecture -> Memory Leaks.</value> | 2433 | <value>Zorba did not close properly, objects may still in memory.\n$1 referenced URI(s) remain in the string pool.\nFor help avoiding this message please refer to http://www.zorba-xquery.com/html/documentation in section General Architecture -> Memory Leaks.</value> |
112 | 2434 | </diagnostic> | 2434 | </diagnostic> |
113 | 2435 | 2435 | ||
114 | 2436 | <diagnostic code="ZSTR0066" name="REFERENCED_NODE_NOT_IN_COLLECTION"> | ||
115 | 2437 | <value>$1: does not reference a node in collection $2.</value> | ||
116 | 2438 | </diagnostic> | ||
117 | 2439 | |||
118 | 2436 | <!--////////// XQuery Scripting ////////////////////////////////////////--> | 2440 | <!--////////// XQuery Scripting ////////////////////////////////////////--> |
119 | 2437 | 2441 | ||
120 | 2438 | <diagnostic code="XSST0001"> | 2442 | <diagnostic code="XSST0001"> |
121 | 2439 | 2443 | ||
122 | === modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp' | |||
123 | --- src/diagnostics/pregenerated/diagnostic_list.cpp 2012-09-12 08:06:26 +0000 | |||
124 | +++ src/diagnostics/pregenerated/diagnostic_list.cpp 2012-09-12 11:09:20 +0000 | |||
125 | @@ -1103,6 +1103,9 @@ | |||
126 | 1103 | ZorbaErrorCode ZSTR0065_STRINGS_IN_POOL( "ZSTR0065" ); | 1103 | ZorbaErrorCode ZSTR0065_STRINGS_IN_POOL( "ZSTR0065" ); |
127 | 1104 | 1104 | ||
128 | 1105 | 1105 | ||
129 | 1106 | ZorbaErrorCode ZSTR0066_REFERENCED_NODE_NOT_IN_COLLECTION( "ZSTR0066" ); | ||
130 | 1107 | |||
131 | 1108 | |||
132 | 1106 | ZorbaErrorCode XSST0001( "XSST0001" ); | 1109 | ZorbaErrorCode XSST0001( "XSST0001" ); |
133 | 1107 | 1110 | ||
134 | 1108 | 1111 | ||
135 | 1109 | 1112 | ||
136 | === modified file 'src/diagnostics/pregenerated/dict_en.cpp' | |||
137 | --- src/diagnostics/pregenerated/dict_en.cpp 2012-09-12 08:06:26 +0000 | |||
138 | +++ src/diagnostics/pregenerated/dict_en.cpp 2012-09-12 11:09:20 +0000 | |||
139 | @@ -453,6 +453,7 @@ | |||
140 | 453 | { "ZSTR0055", "streamable string has already been consumed" }, | 453 | { "ZSTR0055", "streamable string has already been consumed" }, |
141 | 454 | { "ZSTR0060", "out of range: $1" }, | 454 | { "ZSTR0060", "out of range: $1" }, |
142 | 455 | { "ZSTR0065", "Zorba did not close properly, objects may still in memory.\n$1 referenced URI(s) remain in the string pool.\nFor help avoiding this message please refer to http://www.zorba-xquery.com/html/documentation in section General Architecture -> Memory Leaks." }, | 455 | { "ZSTR0065", "Zorba did not close properly, objects may still in memory.\n$1 referenced URI(s) remain in the string pool.\nFor help avoiding this message please refer to http://www.zorba-xquery.com/html/documentation in section General Architecture -> Memory Leaks." }, |
143 | 456 | { "ZSTR0066", "$1: does not reference a node in collection $2." }, | ||
144 | 456 | { "ZWST0002", "\"$1\": unknown or unsupported annotation" }, | 457 | { "ZWST0002", "\"$1\": unknown or unsupported annotation" }, |
145 | 457 | { "ZWST0003", "\"$1\": function declared sequential, but has non-sequential body" }, | 458 | { "ZWST0003", "\"$1\": function declared sequential, but has non-sequential body" }, |
146 | 458 | { "ZWST0004", "Sequential FLWOR expr may not have the semantics you expect" }, | 459 | { "ZWST0004", "Sequential FLWOR expr may not have the semantics you expect" }, |
147 | 459 | 460 | ||
148 | === modified file 'src/functions/func_sequences_impl.cpp' | |||
149 | --- src/functions/func_sequences_impl.cpp 2012-09-10 22:53:04 +0000 | |||
150 | +++ src/functions/func_sequences_impl.cpp 2012-09-12 11:09:20 +0000 | |||
151 | @@ -543,16 +543,19 @@ | |||
152 | 543 | ZorbaCollectionIterator& collection = | 543 | ZorbaCollectionIterator& collection = |
153 | 544 | static_cast<ZorbaCollectionIterator&>(*argv[0]); | 544 | static_cast<ZorbaCollectionIterator&>(*argv[0]); |
154 | 545 | 545 | ||
165 | 546 | return new CountCollectionIterator( | 546 | if (collection.isCountOptimizable()) |
166 | 547 | sctx, | 547 | { |
167 | 548 | loc, | 548 | return new CountCollectionIterator( |
168 | 549 | collection.getChildren(), | 549 | sctx, |
169 | 550 | ( | 550 | loc, |
170 | 551 | collection.isDynamic() | 551 | collection.getChildren(), |
171 | 552 | ? CountCollectionIterator::ZORBADYNAMIC | 552 | ( |
172 | 553 | : CountCollectionIterator::ZORBASTATIC | 553 | collection.isDynamic() |
173 | 554 | ) | 554 | ? CountCollectionIterator::ZORBADYNAMIC |
174 | 555 | ); | 555 | : CountCollectionIterator::ZORBASTATIC |
175 | 556 | ) | ||
176 | 557 | ); | ||
177 | 558 | } | ||
178 | 556 | } | 559 | } |
179 | 557 | else if (typeid(FnCollectionIterator) == counted_type) | 560 | else if (typeid(FnCollectionIterator) == counted_type) |
180 | 558 | { | 561 | { |
181 | 559 | 562 | ||
182 | === modified file 'src/functions/pregenerated/func_collections.cpp' | |||
183 | --- src/functions/pregenerated/func_collections.cpp 2012-09-10 22:53:04 +0000 | |||
184 | +++ src/functions/pregenerated/func_collections.cpp 2012-09-12 11:09:20 +0000 | |||
185 | @@ -355,6 +355,20 @@ | |||
186 | 355 | 355 | ||
187 | 356 | { | 356 | { |
188 | 357 | DECL_WITH_KIND(sctx, static_collections_dml_collection, | 357 | DECL_WITH_KIND(sctx, static_collections_dml_collection, |
189 | 358 | (createQName("http://www.zorba-xquery.com/modules/store/static/collections/dml","","collection"), | ||
190 | 359 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, | ||
191 | 360 | GENV_TYPESYSTEM.ANY_URI_TYPE_ONE, | ||
192 | 361 | GENV_TYPESYSTEM.INTEGER_TYPE_ONE, | ||
193 | 362 | GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR), | ||
194 | 363 | FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_3); | ||
195 | 364 | |||
196 | 365 | } | ||
197 | 366 | |||
198 | 367 | |||
199 | 368 | |||
200 | 369 | |||
201 | 370 | { | ||
202 | 371 | DECL_WITH_KIND(sctx, static_collections_dml_collection, | ||
203 | 358 | (createQName("http://www.zorba-xquery.com/modules/store/dynamic/collections/dml","","collection"), | 372 | (createQName("http://www.zorba-xquery.com/modules/store/dynamic/collections/dml","","collection"), |
204 | 359 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, | 373 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, |
205 | 360 | GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR), | 374 | GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR), |
206 | @@ -379,6 +393,20 @@ | |||
207 | 379 | 393 | ||
208 | 380 | 394 | ||
209 | 381 | { | 395 | { |
210 | 396 | DECL_WITH_KIND(sctx, static_collections_dml_collection, | ||
211 | 397 | (createQName("http://www.zorba-xquery.com/modules/store/dynamic/collections/dml","","collection"), | ||
212 | 398 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, | ||
213 | 399 | GENV_TYPESYSTEM.ANY_URI_TYPE_ONE, | ||
214 | 400 | GENV_TYPESYSTEM.INTEGER_TYPE_ONE, | ||
215 | 401 | GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR), | ||
216 | 402 | FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_3); | ||
217 | 403 | |||
218 | 404 | } | ||
219 | 405 | |||
220 | 406 | |||
221 | 407 | |||
222 | 408 | |||
223 | 409 | { | ||
224 | 382 | DECL_WITH_KIND(sctx, static_collections_dml_collection_name, | 410 | DECL_WITH_KIND(sctx, static_collections_dml_collection_name, |
225 | 383 | (createQName("http://www.zorba-xquery.com/modules/store/static/collections/dml","","collection-name"), | 411 | (createQName("http://www.zorba-xquery.com/modules/store/static/collections/dml","","collection-name"), |
226 | 384 | GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_ONE, | 412 | GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_ONE, |
227 | 385 | 413 | ||
228 | === modified file 'src/functions/pregenerated/function_enum.h' | |||
229 | --- src/functions/pregenerated/function_enum.h 2012-09-11 16:33:21 +0000 | |||
230 | +++ src/functions/pregenerated/function_enum.h 2012-09-12 11:09:20 +0000 | |||
231 | @@ -55,8 +55,10 @@ | |||
232 | 55 | FN_COLLECTION_1, | 55 | FN_COLLECTION_1, |
233 | 56 | STATIC_COLLECTIONS_DML_COLLECTION_1, | 56 | STATIC_COLLECTIONS_DML_COLLECTION_1, |
234 | 57 | STATIC_COLLECTIONS_DML_COLLECTION_2, | 57 | STATIC_COLLECTIONS_DML_COLLECTION_2, |
235 | 58 | STATIC_COLLECTIONS_DML_COLLECTION_3, | ||
236 | 58 | DYNAMIC_COLLECTIONS_DML_COLLECTION_1, | 59 | DYNAMIC_COLLECTIONS_DML_COLLECTION_1, |
237 | 59 | DYNAMIC_COLLECTIONS_DML_COLLECTION_2, | 60 | DYNAMIC_COLLECTIONS_DML_COLLECTION_2, |
238 | 61 | DYNAMIC_COLLECTIONS_DML_COLLECTION_3, | ||
239 | 60 | STATIC_COLLECTIONS_DML_COLLECTION_NAME_1, | 62 | STATIC_COLLECTIONS_DML_COLLECTION_NAME_1, |
240 | 61 | DYNAMIC_COLLECTIONS_DML_COLLECTION_NAME_1, | 63 | DYNAMIC_COLLECTIONS_DML_COLLECTION_NAME_1, |
241 | 62 | STATIC_COLLECTIONS_DML_INDEX_OF_1, | 64 | STATIC_COLLECTIONS_DML_INDEX_OF_1, |
242 | 63 | 65 | ||
243 | === modified file 'src/runtime/collections/collections_impl.cpp' | |||
244 | --- src/runtime/collections/collections_impl.cpp 2012-09-10 22:53:04 +0000 | |||
245 | +++ src/runtime/collections/collections_impl.cpp 2012-09-12 11:09:20 +0000 | |||
246 | @@ -367,6 +367,12 @@ | |||
247 | 367 | } | 367 | } |
248 | 368 | } | 368 | } |
249 | 369 | 369 | ||
250 | 370 | bool ZorbaCollectionIterator::isCountOptimizable() const | ||
251 | 371 | { | ||
252 | 372 | // if ref is passed to the collections function, count cannot be | ||
253 | 373 | // optimized anymore. | ||
254 | 374 | return theChildren.size() <= 2; | ||
255 | 375 | } | ||
256 | 370 | 376 | ||
257 | 371 | bool ZorbaCollectionIterator::nextImpl( | 377 | bool ZorbaCollectionIterator::nextImpl( |
258 | 372 | store::Item_t& result, | 378 | store::Item_t& result, |
259 | @@ -375,6 +381,7 @@ | |||
260 | 375 | store::Item_t name; | 381 | store::Item_t name; |
261 | 376 | store::Collection_t collection; | 382 | store::Collection_t collection; |
262 | 377 | xs_integer lSkip; | 383 | xs_integer lSkip; |
263 | 384 | zstring lStart; | ||
264 | 378 | 385 | ||
265 | 379 | ZorbaCollectionIteratorState* state; | 386 | ZorbaCollectionIteratorState* state; |
266 | 380 | DEFAULT_STACK_INIT(ZorbaCollectionIteratorState, state, planState); | 387 | DEFAULT_STACK_INIT(ZorbaCollectionIteratorState, state, planState); |
267 | @@ -383,21 +390,42 @@ | |||
268 | 383 | 390 | ||
269 | 384 | (void)getCollection(theSctx, name, loc, theIsDynamic, collection); | 391 | (void)getCollection(theSctx, name, loc, theIsDynamic, collection); |
270 | 385 | 392 | ||
274 | 386 | if (theChildren.size() > 1) | 393 | if (theChildren.size() == 1) |
275 | 387 | { | 394 | { |
276 | 388 | // skip parameter passed | 395 | state->theIterator = collection->getIterator(); |
277 | 396 | } | ||
278 | 397 | else | ||
279 | 398 | { | ||
280 | 399 | bool lRefPassed = theChildren.size() >= 3; | ||
281 | 400 | |||
282 | 401 | // read positional skip parameter | ||
283 | 389 | store::Item_t lSkipItem; | 402 | store::Item_t lSkipItem; |
285 | 390 | consumeNext(lSkipItem, theChildren[1].getp(), planState); | 403 | consumeNext(lSkipItem, theChildren[(lRefPassed ? 2 : 1)].getp(), planState); |
286 | 391 | lSkip = lSkipItem->getIntegerValue(); | 404 | lSkip = lSkipItem->getIntegerValue(); |
296 | 392 | // negative is transformed into 0 | 405 | // negative skip is not allowed |
297 | 393 | state->theIterator = ( lSkip > xs_integer::zero() | 406 | if (lSkip < xs_integer::zero()) |
298 | 394 | ? collection->getIterator(lSkip) | 407 | { |
299 | 395 | : collection->getIterator() | 408 | lSkip = xs_integer::zero(); |
300 | 396 | ); | 409 | } |
301 | 397 | } | 410 | if (!lRefPassed) |
302 | 398 | else | 411 | { |
303 | 399 | { | 412 | state->theIterator = collection->getIterator(lSkip); |
304 | 400 | state->theIterator = collection->getIterator(); | 413 | } |
305 | 414 | else | ||
306 | 415 | { | ||
307 | 416 | store::Item_t lRefItem; | ||
308 | 417 | consumeNext(lRefItem, theChildren[1].getp(), planState); | ||
309 | 418 | lStart = lRefItem->getString(); | ||
310 | 419 | try | ||
311 | 420 | { | ||
312 | 421 | state->theIterator = collection->getIterator(lSkip, lStart); | ||
313 | 422 | } | ||
314 | 423 | catch (ZorbaException& e) | ||
315 | 424 | { | ||
316 | 425 | set_source(e, loc); | ||
317 | 426 | throw; | ||
318 | 427 | } | ||
319 | 428 | } | ||
320 | 401 | } | 429 | } |
321 | 402 | 430 | ||
322 | 403 | ZORBA_ASSERT(state->theIterator != NULL); | 431 | ZORBA_ASSERT(state->theIterator != NULL); |
323 | 404 | 432 | ||
324 | === modified file 'src/runtime/collections/pregenerated/collections.h' | |||
325 | --- src/runtime/collections/pregenerated/collections.h 2012-09-10 22:53:04 +0000 | |||
326 | +++ src/runtime/collections/pregenerated/collections.h 2012-09-12 11:09:20 +0000 | |||
327 | @@ -285,6 +285,8 @@ | |||
328 | 285 | 285 | ||
329 | 286 | bool isDynamic() const { return theIsDynamic; } | 286 | bool isDynamic() const { return theIsDynamic; } |
330 | 287 | 287 | ||
331 | 288 | public: | ||
332 | 289 | bool isCountOptimizable() const; | ||
333 | 288 | void accept(PlanIterVisitor& v) const; | 290 | void accept(PlanIterVisitor& v) const; |
334 | 289 | 291 | ||
335 | 290 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; | 292 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; |
336 | 291 | 293 | ||
337 | === modified file 'src/runtime/spec/collections/collections.xml' | |||
338 | --- src/runtime/spec/collections/collections.xml 2012-09-10 22:53:04 +0000 | |||
339 | +++ src/runtime/spec/collections/collections.xml 2012-09-12 11:09:20 +0000 | |||
340 | @@ -255,13 +255,29 @@ | |||
341 | 255 | <zorba:output>structured-item()*</zorba:output> | 255 | <zorba:output>structured-item()*</zorba:output> |
342 | 256 | </zorba:signature> | 256 | </zorba:signature> |
343 | 257 | 257 | ||
351 | 258 | <zorba:signature localname="collection" prefix="dynamic-collections-dml"> | 258 | <zorba:signature localname="collection" |
352 | 259 | <zorba:param>xs:QName</zorba:param> | 259 | prefix="static-collections-dml"> |
353 | 260 | <zorba:output>structured-item()*</zorba:output> | 260 | <zorba:param>xs:QName</zorba:param> |
354 | 261 | </zorba:signature> | 261 | <zorba:param>xs:anyURI</zorba:param><!-- start ref --> |
355 | 262 | 262 | <zorba:param>xs:integer</zorba:param><!-- nodes to skip --> | |
356 | 263 | <zorba:signature localname="collection" prefix="dynamic-collections-dml"> | 263 | <zorba:output>structured-item()*</zorba:output> |
357 | 264 | <zorba:param>xs:QName</zorba:param> | 264 | </zorba:signature> |
358 | 265 | |||
359 | 266 | <zorba:signature localname="collection" prefix="dynamic-collections-dml"> | ||
360 | 267 | <zorba:param>xs:QName</zorba:param> | ||
361 | 268 | <zorba:output>structured-item()*</zorba:output> | ||
362 | 269 | </zorba:signature> | ||
363 | 270 | |||
364 | 271 | <zorba:signature localname="collection" prefix="dynamic-collections-dml"> | ||
365 | 272 | <zorba:param>xs:QName</zorba:param> | ||
366 | 273 | <zorba:param>xs:integer</zorba:param><!-- start to skip --> | ||
367 | 274 | <zorba:output>structured-item()*</zorba:output> | ||
368 | 275 | </zorba:signature> | ||
369 | 276 | |||
370 | 277 | <zorba:signature localname="collection" | ||
371 | 278 | prefix="dynamic-collections-dml"> | ||
372 | 279 | <zorba:param>xs:QName</zorba:param> | ||
373 | 280 | <zorba:param>xs:anyURI</zorba:param><!-- node ref--> | ||
374 | 265 | <zorba:param>xs:integer</zorba:param><!-- nodes to skip --> | 281 | <zorba:param>xs:integer</zorba:param><!-- nodes to skip --> |
375 | 266 | <zorba:output>structured-item()*</zorba:output> | 282 | <zorba:output>structured-item()*</zorba:output> |
376 | 267 | </zorba:signature> | 283 | </zorba:signature> |
377 | @@ -281,6 +297,10 @@ | |||
378 | 281 | 297 | ||
379 | 282 | <zorba:member type="bool" name="theIsDynamic" getterName="isDynamic"/> | 298 | <zorba:member type="bool" name="theIsDynamic" getterName="isDynamic"/> |
380 | 283 | 299 | ||
381 | 300 | <zorba:method const="true" | ||
382 | 301 | name="isCountOptimizable" | ||
383 | 302 | return="bool" /> | ||
384 | 303 | |||
385 | 284 | <zorba:state generateInit="false" generateReset="false" generateDestructor="false"> | 304 | <zorba:state generateInit="false" generateReset="false" generateDestructor="false"> |
386 | 285 | <zorba:member type="store::Iterator_t" name="theIterator"/> | 305 | <zorba:member type="store::Iterator_t" name="theIterator"/> |
387 | 286 | <zorba:member type="bool" name="theIteratorOpened" defaultValue="false"/> | 306 | <zorba:member type="bool" name="theIteratorOpened" defaultValue="false"/> |
388 | 287 | 307 | ||
389 | === modified file 'src/store/api/collection.h' | |||
390 | --- src/store/api/collection.h 2012-09-10 22:53:04 +0000 | |||
391 | +++ src/store/api/collection.h 2012-09-12 11:09:20 +0000 | |||
392 | @@ -54,11 +54,13 @@ | |||
393 | 54 | * It is allowed to have several concurrent iterators on the same Collection, | 54 | * It is allowed to have several concurrent iterators on the same Collection, |
394 | 55 | * but each iterator should be used by a single thread only. | 55 | * but each iterator should be used by a single thread only. |
395 | 56 | * | 56 | * |
397 | 57 | * @param aSkip The number of collection entries to skip. | 57 | * @param aSkip The number of collection items to skip. |
398 | 58 | * @param aStart The reference to the first node. All nodes before are skipped. | ||
399 | 58 | * @return Iterator | 59 | * @return Iterator |
400 | 59 | */ | 60 | */ |
401 | 60 | virtual Iterator_t getIterator( | 61 | virtual Iterator_t getIterator( |
403 | 61 | const xs_integer& aSkip = xs_integer::zero()) = 0; | 62 | const xs_integer& aSkip = xs_integer::zero(), |
404 | 63 | const zstring& aStart = "") = 0; | ||
405 | 62 | 64 | ||
406 | 63 | /** | 65 | /** |
407 | 64 | * Get the node at the given position in the collection. | 66 | * Get the node at the given position in the collection. |
408 | 65 | 67 | ||
409 | === modified file 'src/store/naive/collection.h' | |||
410 | --- src/store/naive/collection.h 2012-09-10 22:53:04 +0000 | |||
411 | +++ src/store/naive/collection.h 2012-09-12 11:09:20 +0000 | |||
412 | @@ -54,7 +54,9 @@ | |||
413 | 54 | 54 | ||
414 | 55 | zorba::xs_integer size() const = 0; | 55 | zorba::xs_integer size() const = 0; |
415 | 56 | 56 | ||
417 | 57 | zorba::store::Iterator_t getIterator(const xs_integer& aSkip) = 0; | 57 | zorba::store::Iterator_t getIterator( |
418 | 58 | const xs_integer& aSkip, | ||
419 | 59 | const zstring& aStart) = 0; | ||
420 | 58 | 60 | ||
421 | 59 | virtual zorba::store::Item_t nodeAt(xs_integer position) = 0; | 61 | virtual zorba::store::Item_t nodeAt(xs_integer position) = 0; |
422 | 60 | 62 | ||
423 | 61 | 63 | ||
424 | === modified file 'src/store/naive/simple_collection.cpp' | |||
425 | --- src/store/naive/simple_collection.cpp 2012-09-10 22:53:04 +0000 | |||
426 | +++ src/store/naive/simple_collection.cpp 2012-09-12 11:09:20 +0000 | |||
427 | @@ -81,9 +81,22 @@ | |||
428 | 81 | Note: it is allowed to have several concurrent iterators on the same collection | 81 | Note: it is allowed to have several concurrent iterators on the same collection |
429 | 82 | but each iterator should be used by a single thread only. | 82 | but each iterator should be used by a single thread only. |
430 | 83 | ********************************************************************************/ | 83 | ********************************************************************************/ |
432 | 84 | store::Iterator_t SimpleCollection::getIterator(const xs_integer& aSkip) | 84 | store::Iterator_t SimpleCollection::getIterator(const xs_integer& aSkip, |
433 | 85 | const zstring& aStart) | ||
434 | 85 | { | 86 | { |
436 | 86 | return new CollectionIter(this, aSkip); | 87 | store::Item_t lReferencedNode; |
437 | 88 | xs_integer lReferencedPosition = xs_integer::zero(); | ||
438 | 89 | if (aStart.size() != 0 | ||
439 | 90 | && (!GET_STORE().getNodeByReference(lReferencedNode, aStart) | ||
440 | 91 | || !findNode(lReferencedNode.getp(), lReferencedPosition))) | ||
441 | 92 | { | ||
442 | 93 | throw ZORBA_EXCEPTION(zerr::ZSTR0066_REFERENCED_NODE_NOT_IN_COLLECTION, | ||
443 | 94 | ERROR_PARAMS(aStart, theName->getStringValue())); | ||
444 | 95 | } | ||
445 | 96 | |||
446 | 97 | return new CollectionIter( | ||
447 | 98 | this, | ||
448 | 99 | aSkip + lReferencedPosition); | ||
449 | 87 | } | 100 | } |
450 | 88 | 101 | ||
451 | 89 | 102 | ||
452 | @@ -596,6 +609,21 @@ | |||
453 | 596 | theCollection->theLatch.unlock();) | 609 | theCollection->theLatch.unlock();) |
454 | 597 | } | 610 | } |
455 | 598 | 611 | ||
456 | 612 | void SimpleCollection::CollectionIter::skip() | ||
457 | 613 | { | ||
458 | 614 | // skip by position | ||
459 | 615 | long lToSkip = to_xs_long(theSkip); | ||
460 | 616 | if (theSkip >= theCollection->size()) | ||
461 | 617 | { | ||
462 | 618 | // we need to skip more then possible -> jump to the end | ||
463 | 619 | theIterator = theEnd; | ||
464 | 620 | } | ||
465 | 621 | else | ||
466 | 622 | { | ||
467 | 623 | theIterator += to_xs_long(theSkip); | ||
468 | 624 | } | ||
469 | 625 | } | ||
470 | 626 | |||
471 | 599 | 627 | ||
472 | 600 | /******************************************************************************* | 628 | /******************************************************************************* |
473 | 601 | 629 | ||
474 | @@ -606,8 +634,8 @@ | |||
475 | 606 | theHaveLock = true; | 634 | theHaveLock = true; |
476 | 607 | 635 | ||
477 | 608 | theIterator = theCollection->theXmlTrees.begin(); | 636 | theIterator = theCollection->theXmlTrees.begin(); |
478 | 609 | theIterator += to_xs_long(theSkip); | ||
479 | 610 | theEnd = theCollection->theXmlTrees.end(); | 637 | theEnd = theCollection->theXmlTrees.end(); |
480 | 638 | skip(); | ||
481 | 611 | } | 639 | } |
482 | 612 | 640 | ||
483 | 613 | 641 | ||
484 | @@ -641,8 +669,8 @@ | |||
485 | 641 | void SimpleCollection::CollectionIter::reset() | 669 | void SimpleCollection::CollectionIter::reset() |
486 | 642 | { | 670 | { |
487 | 643 | theIterator = theCollection->theXmlTrees.begin(); | 671 | theIterator = theCollection->theXmlTrees.begin(); |
488 | 644 | theIterator += to_xs_long(theSkip); | ||
489 | 645 | theEnd = theCollection->theXmlTrees.end(); | 672 | theEnd = theCollection->theXmlTrees.end(); |
490 | 673 | skip(); | ||
491 | 646 | } | 674 | } |
492 | 647 | 675 | ||
493 | 648 | 676 | ||
494 | 649 | 677 | ||
495 | === modified file 'src/store/naive/simple_collection.h' | |||
496 | --- src/store/naive/simple_collection.h 2012-09-10 22:53:04 +0000 | |||
497 | +++ src/store/naive/simple_collection.h 2012-09-12 11:09:20 +0000 | |||
498 | @@ -57,7 +57,8 @@ | |||
499 | 57 | xs_integer theSkip; | 57 | xs_integer theSkip; |
500 | 58 | 58 | ||
501 | 59 | public: | 59 | public: |
503 | 60 | CollectionIter(SimpleCollection* collection, const xs_integer& aSkip); | 60 | CollectionIter(SimpleCollection* collection, |
504 | 61 | const xs_integer& aSkip); | ||
505 | 61 | 62 | ||
506 | 62 | ~CollectionIter(); | 63 | ~CollectionIter(); |
507 | 63 | 64 | ||
508 | @@ -65,6 +66,8 @@ | |||
509 | 65 | bool next(store::Item_t& result); | 66 | bool next(store::Item_t& result); |
510 | 66 | void reset(); | 67 | void reset(); |
511 | 67 | void close(); | 68 | void close(); |
512 | 69 | private: | ||
513 | 70 | void skip(); | ||
514 | 68 | }; | 71 | }; |
515 | 69 | 72 | ||
516 | 70 | 73 | ||
517 | @@ -110,7 +113,8 @@ | |||
518 | 110 | 113 | ||
519 | 111 | TreeId createTreeId(); | 114 | TreeId createTreeId(); |
520 | 112 | 115 | ||
522 | 113 | store::Iterator_t getIterator(const xs_integer& aSkip); | 116 | store::Iterator_t getIterator(const xs_integer& aSkip, |
523 | 117 | const zstring& aStart); | ||
524 | 114 | 118 | ||
525 | 115 | void addNode(store::Item* node, xs_integer position = xs_integer(-1)); | 119 | void addNode(store::Item* node, xs_integer position = xs_integer(-1)); |
526 | 116 | 120 | ||
527 | 117 | 121 | ||
528 | === modified file 'test/rbkt/ExpQueryResults/zorba/collections/paging_1.xml.res' | |||
529 | --- test/rbkt/ExpQueryResults/zorba/collections/paging_1.xml.res 2012-06-28 18:19:34 +0000 | |||
530 | +++ test/rbkt/ExpQueryResults/zorba/collections/paging_1.xml.res 2012-09-12 11:09:20 +0000 | |||
531 | @@ -1,1 +1,1 @@ | |||
533 | 1 | <d/><e/><a/><b/><c/><d/><e/> | 1 | <d/><e/><delim/><a/><b/><c/><d/><e/><delim/><c/><d/><e/> |
534 | 2 | 2 | ||
535 | === modified file 'test/rbkt/ExpQueryResults/zorba/collections/paging_2.xml.res' | |||
536 | --- test/rbkt/ExpQueryResults/zorba/collections/paging_2.xml.res 2012-06-28 18:19:34 +0000 | |||
537 | +++ test/rbkt/ExpQueryResults/zorba/collections/paging_2.xml.res 2012-09-12 11:09:20 +0000 | |||
538 | @@ -1,1 +1,1 @@ | |||
540 | 1 | 2 5 0 | 1 | 2 5 0 3 |
541 | 2 | 2 | ||
542 | === modified file 'test/rbkt/ExpQueryResults/zorba/collections/paging_3.xml.res' | |||
543 | --- test/rbkt/ExpQueryResults/zorba/collections/paging_3.xml.res 2012-06-28 18:19:34 +0000 | |||
544 | +++ test/rbkt/ExpQueryResults/zorba/collections/paging_3.xml.res 2012-09-12 11:09:20 +0000 | |||
545 | @@ -1,1 +1,1 @@ | |||
547 | 1 | <d/><e/><a/><b/><c/><d/><e/> | 1 | <d/><e/><delim/><a/><b/><c/><d/><e/><delim/><c/><d/><e/> |
548 | 2 | 2 | ||
549 | === modified file 'test/rbkt/ExpQueryResults/zorba/collections/paging_4.xml.res' | |||
550 | --- test/rbkt/ExpQueryResults/zorba/collections/paging_4.xml.res 2012-06-28 18:19:34 +0000 | |||
551 | +++ test/rbkt/ExpQueryResults/zorba/collections/paging_4.xml.res 2012-09-12 11:09:20 +0000 | |||
552 | @@ -1,1 +1,1 @@ | |||
554 | 1 | 2 5 0 | 1 | 2 5 0 3 |
555 | 2 | 2 | ||
556 | === modified file 'test/rbkt/Queries/zorba/collections/paging_1.xq' | |||
557 | --- test/rbkt/Queries/zorba/collections/paging_1.xq 2012-06-28 18:19:34 +0000 | |||
558 | +++ test/rbkt/Queries/zorba/collections/paging_1.xq 2012-09-12 11:09:20 +0000 | |||
559 | @@ -1,9 +1,17 @@ | |||
560 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; |
561 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; |
562 | 3 | import module namespace ns = "http://example.org/datamodule/" at "collections.xqdata"; | 3 | import module namespace ns = "http://example.org/datamodule/" at "collections.xqdata"; |
563 | 4 | import module namespace ref = "http://www.zorba-xquery.com/modules/node-reference"; | ||
564 | 4 | 5 | ||
565 | 5 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; | 6 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; |
566 | 6 | 7 | ||
567 | 8 | declare function local:order($items) | ||
568 | 9 | { | ||
569 | 10 | for $item in $items | ||
570 | 11 | order by fn:local-name($item) | ||
571 | 12 | return $item | ||
572 | 13 | }; | ||
573 | 14 | |||
574 | 7 | declare %ann:sequential function local:test() | 15 | declare %ann:sequential function local:test() |
575 | 8 | { | 16 | { |
576 | 9 | ddl:create(xs:QName("ns:test2")); | 17 | ddl:create(xs:QName("ns:test2")); |
577 | @@ -11,10 +19,11 @@ | |||
578 | 11 | dml:insert-nodes(xs:QName("ns:test2"), <b/>); | 19 | dml:insert-nodes(xs:QName("ns:test2"), <b/>); |
579 | 12 | dml:insert-nodes(xs:QName("ns:test2"), (<c/>, <d/>, <e/>)); | 20 | dml:insert-nodes(xs:QName("ns:test2"), (<c/>, <d/>, <e/>)); |
580 | 13 | ( | 21 | ( |
583 | 14 | dml:collection(xs:QName("ns:test2"), 3), | 22 | local:order(dml:collection(xs:QName("ns:test2"), 3)), <delim/>, |
584 | 15 | dml:collection(xs:QName("ns:test2"), -1) | 23 | local:order(dml:collection(xs:QName("ns:test2"), -1)), <delim/>, |
585 | 24 | let $ref := ref:node-reference(dml:collection(xs:QName("ns:test2"))[3]) | ||
586 | 25 | return local:order(dml:collection(xs:QName("ns:test2"), $ref, 0)) | ||
587 | 16 | ) | 26 | ) |
588 | 17 | }; | 27 | }; |
589 | 18 | 28 | ||
590 | 19 | local:test() | 29 | local:test() |
591 | 20 | |||
592 | 21 | 30 | ||
593 | === modified file 'test/rbkt/Queries/zorba/collections/paging_2.xq' | |||
594 | --- test/rbkt/Queries/zorba/collections/paging_2.xq 2012-06-28 18:19:34 +0000 | |||
595 | +++ test/rbkt/Queries/zorba/collections/paging_2.xq 2012-09-12 11:09:20 +0000 | |||
596 | @@ -1,6 +1,7 @@ | |||
597 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; |
598 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; |
599 | 3 | import module namespace ns = "http://example.org/datamodule/" at "collections.xqdata"; | 3 | import module namespace ns = "http://example.org/datamodule/" at "collections.xqdata"; |
600 | 4 | import module namespace ref = "http://www.zorba-xquery.com/modules/node-reference"; | ||
601 | 4 | 5 | ||
602 | 5 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; | 6 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; |
603 | 6 | 7 | ||
604 | @@ -13,9 +14,10 @@ | |||
605 | 13 | ( | 14 | ( |
606 | 14 | fn:count(dml:collection(xs:QName("ns:test2"), 3)), | 15 | fn:count(dml:collection(xs:QName("ns:test2"), 3)), |
607 | 15 | fn:count(dml:collection(xs:QName("ns:test2"), -1)), | 16 | fn:count(dml:collection(xs:QName("ns:test2"), -1)), |
609 | 16 | fn:count(dml:collection(xs:QName("ns:test2"), 100)) | 17 | fn:count(dml:collection(xs:QName("ns:test2"), 100)), |
610 | 18 | let $ref := ref:node-reference(dml:collection(xs:QName("ns:test2"))[3]) | ||
611 | 19 | return fn:count(dml:collection(xs:QName("ns:test2"), $ref, 0)) | ||
612 | 17 | ) | 20 | ) |
613 | 18 | }; | 21 | }; |
614 | 19 | 22 | ||
615 | 20 | local:test() | 23 | local:test() |
616 | 21 | |||
617 | 22 | 24 | ||
618 | === modified file 'test/rbkt/Queries/zorba/collections/paging_3.xq' | |||
619 | --- test/rbkt/Queries/zorba/collections/paging_3.xq 2012-06-28 18:19:34 +0000 | |||
620 | +++ test/rbkt/Queries/zorba/collections/paging_3.xq 2012-09-12 11:09:20 +0000 | |||
621 | @@ -1,5 +1,6 @@ | |||
622 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl"; | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl"; |
623 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml"; | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml"; |
624 | 3 | import module namespace ref = "http://www.zorba-xquery.com/modules/node-reference"; | ||
625 | 3 | 4 | ||
626 | 4 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; | 5 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; |
627 | 5 | declare namespace ns = "http://www.zorba-xquery.com/test"; | 6 | declare namespace ns = "http://www.zorba-xquery.com/test"; |
628 | @@ -11,10 +12,11 @@ | |||
629 | 11 | dml:insert-nodes-last(xs:QName("ns:test2"), <b/>); | 12 | dml:insert-nodes-last(xs:QName("ns:test2"), <b/>); |
630 | 12 | dml:insert-nodes-last(xs:QName("ns:test2"), (<c/>, <d/>, <e/>)); | 13 | dml:insert-nodes-last(xs:QName("ns:test2"), (<c/>, <d/>, <e/>)); |
631 | 13 | ( | 14 | ( |
634 | 14 | dml:collection(xs:QName("ns:test2"), 3), | 15 | dml:collection(xs:QName("ns:test2"), 3), <delim/>, |
635 | 15 | dml:collection(xs:QName("ns:test2"), -1) | 16 | dml:collection(xs:QName("ns:test2"), -1), <delim/>, |
636 | 17 | let $ref := ref:node-reference(dml:collection(xs:QName("ns:test2"))[3]) | ||
637 | 18 | return dml:collection(xs:QName("ns:test2"), $ref, 0) | ||
638 | 16 | ) | 19 | ) |
639 | 17 | }; | 20 | }; |
640 | 18 | 21 | ||
641 | 19 | local:test() | 22 | local:test() |
642 | 20 | |||
643 | 21 | 23 | ||
644 | === modified file 'test/rbkt/Queries/zorba/collections/paging_4.xq' | |||
645 | --- test/rbkt/Queries/zorba/collections/paging_4.xq 2012-06-28 18:19:34 +0000 | |||
646 | +++ test/rbkt/Queries/zorba/collections/paging_4.xq 2012-09-12 11:09:20 +0000 | |||
647 | @@ -1,5 +1,6 @@ | |||
648 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl"; | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl"; |
649 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml"; | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml"; |
650 | 3 | import module namespace ref = "http://www.zorba-xquery.com/modules/node-reference"; | ||
651 | 3 | 4 | ||
652 | 4 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; | 5 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; |
653 | 5 | declare namespace ns = "http://www.zorba-xquery.com/test"; | 6 | declare namespace ns = "http://www.zorba-xquery.com/test"; |
654 | @@ -13,9 +14,10 @@ | |||
655 | 13 | ( | 14 | ( |
656 | 14 | fn:count(dml:collection(xs:QName("ns:test2"), 3)), | 15 | fn:count(dml:collection(xs:QName("ns:test2"), 3)), |
657 | 15 | fn:count(dml:collection(xs:QName("ns:test2"), -1)), | 16 | fn:count(dml:collection(xs:QName("ns:test2"), -1)), |
659 | 16 | fn:count(dml:collection(xs:QName("ns:test2"), 100)) | 17 | fn:count(dml:collection(xs:QName("ns:test2"), 100)), |
660 | 18 | let $ref := ref:node-reference(dml:collection(xs:QName("ns:test2"))[3]) | ||
661 | 19 | return fn:count(dml:collection(xs:QName("ns:test2"), $ref, 0)) | ||
662 | 17 | ) | 20 | ) |
663 | 18 | }; | 21 | }; |
664 | 19 | 22 | ||
665 | 20 | local:test() | 23 | local:test() |
666 | 21 | |||
667 | 22 | 24 | ||
668 | === added file 'test/rbkt/Queries/zorba/collections/paging_5.spec' | |||
669 | --- test/rbkt/Queries/zorba/collections/paging_5.spec 1970-01-01 00:00:00 +0000 | |||
670 | +++ test/rbkt/Queries/zorba/collections/paging_5.spec 2012-09-12 11:09:20 +0000 | |||
671 | @@ -0,0 +1,1 @@ | |||
672 | 1 | Error: http://www.zorba-xquery.com/errors:ZSTR0066 | ||
673 | 0 | 2 | ||
674 | === added file 'test/rbkt/Queries/zorba/collections/paging_5.xq' | |||
675 | --- test/rbkt/Queries/zorba/collections/paging_5.xq 1970-01-01 00:00:00 +0000 | |||
676 | +++ test/rbkt/Queries/zorba/collections/paging_5.xq 2012-09-12 11:09:20 +0000 | |||
677 | @@ -0,0 +1,20 @@ | |||
678 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl"; | ||
679 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml"; | ||
680 | 3 | import module namespace ref = "http://www.zorba-xquery.com/modules/node-reference"; | ||
681 | 4 | |||
682 | 5 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; | ||
683 | 6 | declare namespace ns = "http://www.zorba-xquery.com/test"; | ||
684 | 7 | |||
685 | 8 | declare %ann:sequential function local:test() | ||
686 | 9 | { | ||
687 | 10 | ddl:create(xs:QName("ns:test2")); | ||
688 | 11 | dml:insert-nodes-last(xs:QName("ns:test2"), <a/>); | ||
689 | 12 | dml:insert-nodes-last(xs:QName("ns:test2"), <b/>); | ||
690 | 13 | dml:insert-nodes-last(xs:QName("ns:test2"), (<c/>, <d/>, <e/>)); | ||
691 | 14 | |||
692 | 15 | dml:collection( | ||
693 | 16 | xs:QName("ns:test2"), | ||
694 | 17 | xs:anyURI("urn:uuid:aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"), 0) | ||
695 | 18 | }; | ||
696 | 19 | |||
697 | 20 | local:test() |
- Given the documentation, I was not able to figure out why the collection
function takes the $start and $skip parameters. Is one of the ignored if
the other one is given? Does skipping start at the item identified by
$start? If so, would it make sense to separate the two ways of skipping
into separate functions?
- improved
The reference to first node to return
=>
A reference to the first node to return.
- What does "order is implementation dependent" mean for ordered collections?
- Error message can be improved according to Paul's style:
Node reference $1 doesn't reference a node in collection $2
=>
$1: doesn't reference a node in collection ($2)
- typo:
if the passed reference $start doesn't reference
a _not_ from the collection identified by $name.
- the documentation mention zerr:ZAPI0028 if the given URI
is not a valid node reference