Merge lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba
- feature-transient_maps
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Matthias Brantner |
Approved revision: | 10851 |
Merged at revision: | 10888 |
Proposed branch: | lp:~zorba-coders/zorba/feature-transient_maps |
Merge into: | lp:zorba |
Diff against target: |
1867 lines (+875/-213) 26 files modified
ChangeLog (+1/-0) modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xq (+74/-30) src/context/dynamic_context.cpp (+69/-0) src/context/dynamic_context.h (+10/-0) src/functions/pregenerated/func_maps.cpp (+45/-0) src/functions/pregenerated/func_maps.h (+36/-0) src/functions/pregenerated/function_enum.h (+2/-0) src/runtime/pregenerated/iterator_enum.h (+2/-0) src/runtime/spec/store/maps.xml (+65/-5) src/runtime/store/maps_impl.cpp (+302/-156) src/runtime/store/pregenerated/maps.cpp (+56/-0) src/runtime/store/pregenerated/maps.h (+66/-1) src/runtime/visitors/pregenerated/planiter_visitor.h (+10/-0) src/runtime/visitors/pregenerated/printer_visitor.cpp (+28/-0) src/runtime/visitors/pregenerated/printer_visitor.h (+6/-0) src/store/api/index.h (+5/-0) src/store/api/store.h (+4/-0) src/store/naive/pul_primitives.cpp (+6/-7) src/store/naive/simple_index_general.cpp (+2/-2) src/store/naive/simple_index_general.h (+26/-3) src/store/naive/store.cpp (+5/-5) src/store/naive/store.h (+4/-4) test/rbkt/ExpQueryResults/zorba/store/unordered-map/map7.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/store/unordered-map/transient-map0.xml.res (+1/-0) test/rbkt/Queries/zorba/store/unordered-map/map7.xq (+22/-0) test/rbkt/Queries/zorba/store/unordered-map/transient-map0.xq (+27/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/feature-transient_maps |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Till Westmann | Approve | ||
Review via email: mp+106287@code.launchpad.net |
Commit message
Added support for transient maps in the unordered-maps module.
Description of the change
Added support for transient maps in the unordered-maps module.
A transient map is only available within the execution of the currently active XQuery program. It is not available to any other program that is running in parallel or after the program that created it.
Transient maps can be created using map:create-
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/feature-transient_maps into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job feature-
finished. The final status was:
No tests were run - build or configure step must have failed.
Not commiting changes.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Pending.
Till Westmann (tillw) wrote : | # |
The docs say that a key can consist of a "set" of atomic values. As the order of the values is relevant "list" or "tuple" might be better.
As the parameters for insert, get, etc. are anyAtomicType? an empty sequence can be passed in, but the doc does not say how that is handled.
I've extended the test to cover a little more of the functionality.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Attempt to merge into lp:zorba failed due to conflicts:
text conflict in ChangeLog
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Needs Fixing, 1 Pending.
Till Westmann (tillw) wrote : | # |
Modified the documentation and added another test.
Unfortunately this test (zorba/
Till Westmann (tillw) wrote : | # |
Fixed the crashing test and addressed all of my review comments.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job feature-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 1 Pending.
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 : | # |
Validation queue job feature-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2012-06-22 08:38:46 +0000 | |||
3 | +++ ChangeLog 2012-06-23 00:29:20 +0000 | |||
4 | @@ -5,6 +5,7 @@ | |||
5 | 5 | 5 | ||
6 | 6 | New Features: | 6 | New Features: |
7 | 7 | * Implemented latest W3C soec for group by clause | 7 | * Implemented latest W3C soec for group by clause |
8 | 8 | * Added support for transient maps to the http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module. | ||
9 | 8 | 9 | ||
10 | 9 | Optimizations: | 10 | Optimizations: |
11 | 10 | * Small optimization of comparison operations. | 11 | * Small optimization of comparison operations. |
12 | 11 | 12 | ||
13 | === modified file 'modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xq' | |||
14 | --- modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xq 2012-06-18 10:06:47 +0000 | |||
15 | +++ modules/com/zorba-xquery/www/modules/store/data-structures/unordered-map.xq 2012-06-23 00:29:20 +0000 | |||
16 | @@ -1,7 +1,6 @@ | |||
17 | 1 | xquery version "3.0"; | 1 | xquery version "3.0"; |
18 | 2 | |||
19 | 3 | (: | 2 | (: |
21 | 4 | : Copyright 2006-2009 The FLWOR Foundation. | 3 | : Copyright 2006-2012 The FLWOR Foundation. |
22 | 5 | : | 4 | : |
23 | 6 | : Licensed under the Apache License, Version 2.0 (the "License"); | 5 | : Licensed under the Apache License, Version 2.0 (the "License"); |
24 | 7 | : you may not use this file except in compliance with the License. | 6 | : you may not use this file except in compliance with the License. |
25 | @@ -17,17 +16,20 @@ | |||
26 | 17 | :) | 16 | :) |
27 | 18 | 17 | ||
28 | 19 | (:~ | 18 | (:~ |
40 | 20 | : This module defines a set of functions for working with | 19 | : <p>This module defines a set of functions for working with maps. A map |
41 | 21 | : maps. A map is identified by a QName and can | 20 | : is identified by a QName and can be created using the map:create or |
42 | 22 | : be created using the map:create function and deleted | 21 | : map:create-transient functions and deleted using the map:delete function, |
43 | 23 | : using the map:delete function, respectively. However, its | 22 | : respectively.</p> |
44 | 24 | : actual lifetime depends on the particular store implementation. | 23 | : |
45 | 25 | : | 24 | : <p>The lifetime of a transient map is limited by the execution of the |
46 | 26 | : The key of a particular entry in the map can consist | 25 | : current XQuery program. A non-transient (or persistent) map lives until |
47 | 27 | : out of a set of atomic values (called attributes). | 26 | : it is explicitly deleted. Accordingly, it's also available |
48 | 28 | : The actual type of each attribute can be determined when the | 27 | : to other XQuery programs.</p> |
49 | 29 | : map is created. The value can be an arbitrary sequence | 28 | : |
50 | 30 | : of items. | 29 | : <p>The key of a particular entry in the map can consist of a tuple of |
51 | 30 | : atomic values (called attributes). The actual type of each attribute | ||
52 | 31 | : is determined when the map is created. The value of each attribute can | ||
53 | 32 | : be an arbitrary sequence of items.</p> | ||
54 | 31 | : | 33 | : |
55 | 32 | : @see <a href="../../html/data_lifecycle.html">Data Lifecycle</a> | 34 | : @see <a href="../../html/data_lifecycle.html">Data Lifecycle</a> |
56 | 33 | : @see <a href="www.zorba-xquery.com_errors.html">http://www.zorba-xquery.com/errors</a> | 35 | : @see <a href="www.zorba-xquery.com_errors.html">http://www.zorba-xquery.com/errors</a> |
57 | @@ -46,11 +48,10 @@ | |||
58 | 46 | declare option ver:module-version "2.0"; | 48 | declare option ver:module-version "2.0"; |
59 | 47 | 49 | ||
60 | 48 | (:~ | 50 | (:~ |
66 | 49 | : Create a map with a given name and a set of types for | 51 | : Create a map with a given name and a set of type identifiers for each key |
67 | 50 | : each key attribute. Note that the function is variadic | 52 | : attribute. Note that the function is variadic and might take an arbitrary |
68 | 51 | : and might take an arbitrary amount of types for the key | 53 | : number of type identifiers for the key attributes. Also note that the |
69 | 52 | : attributes. Also note that the function is sequential | 54 | : function is sequential and immediately creates the map in the store. |
65 | 53 | : and immediately creates the map in the store. | ||
70 | 54 | : | 55 | : |
71 | 55 | : @param $name the name of the map | 56 | : @param $name the name of the map |
72 | 56 | : @param $key-type an arbitrary number of types, one | 57 | : @param $key-type an arbitrary number of types, one |
73 | @@ -68,6 +69,26 @@ | |||
74 | 68 | $key-type as xs:QName) as empty-sequence() external; | 69 | $key-type as xs:QName) as empty-sequence() external; |
75 | 69 | 70 | ||
76 | 70 | (:~ | 71 | (:~ |
77 | 72 | : Create a transient map with a given name and a set of type identifiers | ||
78 | 73 | : for each key attribute. Note that the function is variadic and might | ||
79 | 74 | : take an arbitrary number of type identifiers for the key attributes. | ||
80 | 75 | : | ||
81 | 76 | : @param $name the name of the map | ||
82 | 77 | : @param $key-type an arbitrary number of types, one | ||
83 | 78 | : for each key attribute. | ||
84 | 79 | : | ||
85 | 80 | : @return the function is sequential and immediately creates | ||
86 | 81 | : the corresponding map but returns the empty-sequence. | ||
87 | 82 | : | ||
88 | 83 | : @error err:XPTY0004 if any of the attribute types is not a subtype of | ||
89 | 84 | : xs:anyAtomicType. | ||
90 | 85 | : @error zerr:ZSTR0001 if a map with the given name already exists. | ||
91 | 86 | :) | ||
92 | 87 | declare %an:variadic %an:sequential function map:create-transient( | ||
93 | 88 | $name as xs:QName, | ||
94 | 89 | $key-type as xs:QName) as empty-sequence() external; | ||
95 | 90 | |||
96 | 91 | (:~ | ||
97 | 71 | : Destroys the map with the given name. | 92 | : Destroys the map with the given name. |
98 | 72 | : | 93 | : |
99 | 73 | : @param $name the name of the map to delete | 94 | : @param $name the name of the map to delete |
100 | @@ -81,13 +102,17 @@ | |||
101 | 81 | $name as xs:QName) as empty-sequence() external; | 102 | $name as xs:QName) as empty-sequence() external; |
102 | 82 | 103 | ||
103 | 83 | (:~ | 104 | (:~ |
111 | 84 | : Inserts a new entry into the map with the given | 105 | : Inserts a new entry into the map with the given name. Note that the |
112 | 85 | : name. Note that the function is variadic | 106 | : function is variadic and might take an arbitrary number of key attributes. |
113 | 86 | : and might take an arbitrary amount of key attributes. | 107 | : If an entry with the given key already exists in the map, the value |
114 | 87 | : If an entry with the given key already exists in the | 108 | : sequences of the existing entry and the sequence passed using $value |
115 | 88 | : map, the value sequences of the existing entry and the | 109 | : argument are concatenated. |
116 | 89 | : sequence passed using $value argument are concatenated. | 110 | : |
117 | 90 | : | 111 | : Note that it is possible to insert entries with empty key attributes. |
118 | 112 | : However as the getting the entries is based on the "eq" comparison and | ||
119 | 113 | : as "eq" with an empty sequence always return false, it is not possible | ||
120 | 114 | : to retrieve these entries. | ||
121 | 115 | : | ||
122 | 91 | : @param $name the name of the map | 116 | : @param $name the name of the map |
123 | 92 | : @param $value the value of the entry to insert | 117 | : @param $value the value of the entry to insert |
124 | 93 | : @param $key an arbitrary number of key attributes. | 118 | : @param $key an arbitrary number of key attributes. |
125 | @@ -113,8 +138,12 @@ | |||
126 | 113 | $key as xs:anyAtomicType?) as empty-sequence() external; | 138 | $key as xs:anyAtomicType?) as empty-sequence() external; |
127 | 114 | 139 | ||
128 | 115 | (:~ | 140 | (:~ |
131 | 116 | : Returns the value of the entry with the given key | 141 | : Returns the value of the entry with the given key from the map. |
132 | 117 | : from the map. | 142 | : |
133 | 143 | : Note that it is possible to insert entries with empty key attributes. | ||
134 | 144 | : However as the getting the entries is based on the "eq" comparison and | ||
135 | 145 | : as "eq" with an empty sequence always return false, it is not possible | ||
136 | 146 | : to retrieve these entries. | ||
137 | 118 | : | 147 | : |
138 | 119 | : @param $name the name of the map | 148 | : @param $name the name of the map |
139 | 120 | : @param an arbitrary number of search key attributes. | 149 | : @param an arbitrary number of search key attributes. |
140 | @@ -140,6 +169,11 @@ | |||
141 | 140 | (:~ | 169 | (:~ |
142 | 141 | : Removes an entry identified by the given key from the map. | 170 | : Removes an entry identified by the given key from the map. |
143 | 142 | : | 171 | : |
144 | 172 | : Note that it is possible to insert entries with empty key attributes. | ||
145 | 173 | : However as the removing the entries is based on the "eq" comparison and | ||
146 | 174 | : as "eq" with an empty sequence always return false, it is not possible | ||
147 | 175 | : to remove these entries. | ||
148 | 176 | : | ||
149 | 143 | : @param $name the name of the map | 177 | : @param $name the name of the map |
150 | 144 | : @param an arbitrary number of search key attributes. | 178 | : @param an arbitrary number of search key attributes. |
151 | 145 | : | 179 | : |
152 | @@ -156,7 +190,6 @@ | |||
153 | 156 | : specified when creating the map. | 190 | : specified when creating the map. |
154 | 157 | : | 191 | : |
155 | 158 | : @see map:create | 192 | : @see map:create |
156 | 159 | : | ||
157 | 160 | :) | 193 | :) |
158 | 161 | declare %an:variadic %an:sequential function map:remove( | 194 | declare %an:variadic %an:sequential function map:remove( |
159 | 162 | $name as xs:QName, | 195 | $name as xs:QName, |
160 | @@ -199,8 +232,7 @@ | |||
161 | 199 | : | 232 | : |
162 | 200 | : @error zerr:ZDDY0023 if a map with the given name does not exist. | 233 | : @error zerr:ZDDY0023 if a map with the given name does not exist. |
163 | 201 | :) | 234 | :) |
166 | 202 | declare function map:size( | 235 | declare function map:size($name as xs:QName) as xs:integer external; |
165 | 203 | $name as xs:QName) as xs:integer external; | ||
167 | 204 | 236 | ||
168 | 205 | (:~ | 237 | (:~ |
169 | 206 | : The function returns a sequence of QNames of the maps that are | 238 | : The function returns a sequence of QNames of the maps that are |
170 | @@ -210,3 +242,15 @@ | |||
171 | 210 | : | 242 | : |
172 | 211 | :) | 243 | :) |
173 | 212 | declare function map:available-maps() as xs:QName* external; | 244 | declare function map:available-maps() as xs:QName* external; |
174 | 245 | |||
175 | 246 | (:~ | ||
176 | 247 | : The function returns true if the map identified by the given QName | ||
177 | 248 | : is transient, false otherwise. | ||
178 | 249 | : | ||
179 | 250 | : @param $name the name of the map | ||
180 | 251 | : | ||
181 | 252 | : @return true if the map is transient, false otherwise. | ||
182 | 253 | : | ||
183 | 254 | : @error zerr:ZDDY0023 if a map with the given name does not exist. | ||
184 | 255 | :) | ||
185 | 256 | declare function map:is-transient($name as xs:QName) as xs:boolean external; | ||
186 | 213 | 257 | ||
187 | === modified file 'src/context/dynamic_context.cpp' | |||
188 | --- src/context/dynamic_context.cpp 2012-06-18 10:06:47 +0000 | |||
189 | +++ src/context/dynamic_context.cpp 2012-06-23 00:29:20 +0000 | |||
190 | @@ -130,6 +130,7 @@ | |||
191 | 130 | theParent(NULL), | 130 | theParent(NULL), |
192 | 131 | keymap(NULL), | 131 | keymap(NULL), |
193 | 132 | theAvailableIndices(NULL), | 132 | theAvailableIndices(NULL), |
194 | 133 | theAvailableMaps(NULL), | ||
195 | 133 | theEnvironmentVariables(NULL), | 134 | theEnvironmentVariables(NULL), |
196 | 134 | theDocLoadingUserTime(0.0), | 135 | theDocLoadingUserTime(0.0), |
197 | 135 | theDocLoadingTime(0) | 136 | theDocLoadingTime(0) |
198 | @@ -175,6 +176,9 @@ | |||
199 | 175 | 176 | ||
200 | 176 | if (theAvailableIndices) | 177 | if (theAvailableIndices) |
201 | 177 | delete theAvailableIndices; | 178 | delete theAvailableIndices; |
202 | 179 | |||
203 | 180 | if (theAvailableMaps) | ||
204 | 181 | delete theAvailableMaps; | ||
205 | 178 | } | 182 | } |
206 | 179 | 183 | ||
207 | 180 | 184 | ||
208 | @@ -728,6 +732,71 @@ | |||
209 | 728 | /******************************************************************************* | 732 | /******************************************************************************* |
210 | 729 | 733 | ||
211 | 730 | ********************************************************************************/ | 734 | ********************************************************************************/ |
212 | 735 | store::Index* dynamic_context::getMap(store::Item* qname) const | ||
213 | 736 | { | ||
214 | 737 | if (theAvailableMaps == NULL) | ||
215 | 738 | return NULL; | ||
216 | 739 | |||
217 | 740 | store::Index_t map; | ||
218 | 741 | |||
219 | 742 | if (theAvailableMaps->get(qname, map)) | ||
220 | 743 | { | ||
221 | 744 | return map.getp(); | ||
222 | 745 | } | ||
223 | 746 | else | ||
224 | 747 | { | ||
225 | 748 | return NULL; | ||
226 | 749 | } | ||
227 | 750 | } | ||
228 | 751 | |||
229 | 752 | |||
230 | 753 | /******************************************************************************* | ||
231 | 754 | |||
232 | 755 | ********************************************************************************/ | ||
233 | 756 | void dynamic_context::bindMap( | ||
234 | 757 | store::Item* qname, | ||
235 | 758 | store::Index_t& map) | ||
236 | 759 | { | ||
237 | 760 | if (theAvailableMaps == NULL) | ||
238 | 761 | theAvailableMaps = new IndexMap(HashMapItemPointerCmp(0, NULL), 8, false); | ||
239 | 762 | |||
240 | 763 | if (!theAvailableMaps->insert(qname, map)) | ||
241 | 764 | { | ||
242 | 765 | ZORBA_ASSERT(false); | ||
243 | 766 | } | ||
244 | 767 | } | ||
245 | 768 | |||
246 | 769 | |||
247 | 770 | /******************************************************************************* | ||
248 | 771 | |||
249 | 772 | ********************************************************************************/ | ||
250 | 773 | void dynamic_context::unbindMap(store::Item* qname) | ||
251 | 774 | { | ||
252 | 775 | if (theAvailableMaps != NULL) | ||
253 | 776 | theAvailableMaps->erase(qname); | ||
254 | 777 | } | ||
255 | 778 | |||
256 | 779 | |||
257 | 780 | /******************************************************************************* | ||
258 | 781 | |||
259 | 782 | ********************************************************************************/ | ||
260 | 783 | void dynamic_context::getMapNames(std::vector<store::Item_t>& names) const | ||
261 | 784 | { | ||
262 | 785 | if (theAvailableMaps == NULL) | ||
263 | 786 | return; | ||
264 | 787 | |||
265 | 788 | for (IndexMap::iterator lIter = theAvailableMaps->begin(); | ||
266 | 789 | lIter != theAvailableMaps->end(); | ||
267 | 790 | ++lIter) | ||
268 | 791 | { | ||
269 | 792 | names.push_back(lIter.getKey()); | ||
270 | 793 | } | ||
271 | 794 | } | ||
272 | 795 | |||
273 | 796 | |||
274 | 797 | /******************************************************************************* | ||
275 | 798 | |||
276 | 799 | ********************************************************************************/ | ||
277 | 731 | store::Iterator_t dynamic_context::listActiveICNames() | 800 | store::Iterator_t dynamic_context::listActiveICNames() |
278 | 732 | { | 801 | { |
279 | 733 | return GENV_STORE.listActiveICNames(); | 802 | return GENV_STORE.listActiveICNames(); |
280 | 734 | 803 | ||
281 | === modified file 'src/context/dynamic_context.h' | |||
282 | --- src/context/dynamic_context.h 2012-06-18 10:06:47 +0000 | |||
283 | +++ src/context/dynamic_context.h 2012-06-23 00:29:20 +0000 | |||
284 | @@ -123,6 +123,8 @@ | |||
285 | 123 | 123 | ||
286 | 124 | IndexMap * theAvailableIndices; | 124 | IndexMap * theAvailableIndices; |
287 | 125 | 125 | ||
288 | 126 | IndexMap * theAvailableMaps; | ||
289 | 127 | |||
290 | 126 | //MODIFY | 128 | //MODIFY |
291 | 127 | EnvVarMap * theEnvironmentVariables; | 129 | EnvVarMap * theEnvironmentVariables; |
292 | 128 | 130 | ||
293 | @@ -204,6 +206,14 @@ | |||
294 | 204 | 206 | ||
295 | 205 | void unbindIndex(store::Item* qname); | 207 | void unbindIndex(store::Item* qname); |
296 | 206 | 208 | ||
297 | 209 | store::Index* getMap(store::Item* qname) const; | ||
298 | 210 | |||
299 | 211 | void bindMap(store::Item* qname, store::Index_t& index); | ||
300 | 212 | |||
301 | 213 | void unbindMap(store::Item* qname); | ||
302 | 214 | |||
303 | 215 | void getMapNames(std::vector<store::Item_t>& names) const; | ||
304 | 216 | |||
305 | 207 | /** | 217 | /** |
306 | 208 | * Lists all active integrity constraints. | 218 | * Lists all active integrity constraints. |
307 | 209 | */ | 219 | */ |
308 | 210 | 220 | ||
309 | === modified file 'src/functions/pregenerated/func_maps.cpp' | |||
310 | --- src/functions/pregenerated/func_maps.cpp 2012-06-18 10:06:47 +0000 | |||
311 | +++ src/functions/pregenerated/func_maps.cpp 2012-06-23 00:29:20 +0000 | |||
312 | @@ -41,6 +41,16 @@ | |||
313 | 41 | return new MapCreateIterator(sctx, loc, argv); | 41 | return new MapCreateIterator(sctx, loc, argv); |
314 | 42 | } | 42 | } |
315 | 43 | 43 | ||
316 | 44 | PlanIter_t zorba_store_data_structure_unordered_map_create_transient::codegen( | ||
317 | 45 | CompilerCB*, | ||
318 | 46 | static_context* sctx, | ||
319 | 47 | const QueryLoc& loc, | ||
320 | 48 | std::vector<PlanIter_t>& argv, | ||
321 | 49 | expr& ann) const | ||
322 | 50 | { | ||
323 | 51 | return new MapCreateTransientIterator(sctx, loc, argv); | ||
324 | 52 | } | ||
325 | 53 | |||
326 | 44 | PlanIter_t zorba_store_data_structure_unordered_map_delete::codegen( | 54 | PlanIter_t zorba_store_data_structure_unordered_map_delete::codegen( |
327 | 45 | CompilerCB*, | 55 | CompilerCB*, |
328 | 46 | static_context* sctx, | 56 | static_context* sctx, |
329 | @@ -111,6 +121,16 @@ | |||
330 | 111 | return new AvailableMapsIterator(sctx, loc, argv); | 121 | return new AvailableMapsIterator(sctx, loc, argv); |
331 | 112 | } | 122 | } |
332 | 113 | 123 | ||
333 | 124 | PlanIter_t zorba_store_data_structure_unordered_map_is_transient::codegen( | ||
334 | 125 | CompilerCB*, | ||
335 | 126 | static_context* sctx, | ||
336 | 127 | const QueryLoc& loc, | ||
337 | 128 | std::vector<PlanIter_t>& argv, | ||
338 | 129 | expr& ann) const | ||
339 | 130 | { | ||
340 | 131 | return new MapIsTransientIterator(sctx, loc, argv); | ||
341 | 132 | } | ||
342 | 133 | |||
343 | 114 | void populate_context_maps(static_context* sctx) | 134 | void populate_context_maps(static_context* sctx) |
344 | 115 | { | 135 | { |
345 | 116 | 136 | ||
346 | @@ -129,6 +149,19 @@ | |||
347 | 129 | 149 | ||
348 | 130 | 150 | ||
349 | 131 | { | 151 | { |
350 | 152 | std::vector<xqtref_t> lParamTypes; | ||
351 | 153 | lParamTypes.push_back(GENV_TYPESYSTEM.QNAME_TYPE_ONE); | ||
352 | 154 | lParamTypes.push_back(GENV_TYPESYSTEM.QNAME_TYPE_ONE);DECL_WITH_KIND(sctx, zorba_store_data_structure_unordered_map_create_transient, | ||
353 | 155 | (createQName("http://www.zorba-xquery.com/modules/store/data-structures/unordered-map","","create-transient"), | ||
354 | 156 | lParamTypes, GENV_TYPESYSTEM.EMPTY_TYPE, true), | ||
355 | 157 | FunctionConsts::ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_CREATE_TRANSIENT_N); | ||
356 | 158 | |||
357 | 159 | } | ||
358 | 160 | |||
359 | 161 | |||
360 | 162 | |||
361 | 163 | |||
362 | 164 | { | ||
363 | 132 | DECL_WITH_KIND(sctx, zorba_store_data_structure_unordered_map_delete, | 165 | DECL_WITH_KIND(sctx, zorba_store_data_structure_unordered_map_delete, |
364 | 133 | (createQName("http://www.zorba-xquery.com/modules/store/data-structures/unordered-map","","delete"), | 166 | (createQName("http://www.zorba-xquery.com/modules/store/data-structures/unordered-map","","delete"), |
365 | 134 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, | 167 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, |
366 | @@ -212,6 +245,18 @@ | |||
367 | 212 | 245 | ||
368 | 213 | } | 246 | } |
369 | 214 | 247 | ||
370 | 248 | |||
371 | 249 | |||
372 | 250 | |||
373 | 251 | { | ||
374 | 252 | DECL_WITH_KIND(sctx, zorba_store_data_structure_unordered_map_is_transient, | ||
375 | 253 | (createQName("http://www.zorba-xquery.com/modules/store/data-structures/unordered-map","","is-transient"), | ||
376 | 254 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, | ||
377 | 255 | GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE), | ||
378 | 256 | FunctionConsts::ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_IS_TRANSIENT_1); | ||
379 | 257 | |||
380 | 258 | } | ||
381 | 259 | |||
382 | 215 | } | 260 | } |
383 | 216 | 261 | ||
384 | 217 | 262 | ||
385 | 218 | 263 | ||
386 | === modified file 'src/functions/pregenerated/func_maps.h' | |||
387 | --- src/functions/pregenerated/func_maps.h 2012-06-18 10:06:47 +0000 | |||
388 | +++ src/functions/pregenerated/func_maps.h 2012-06-23 00:29:20 +0000 | |||
389 | @@ -57,6 +57,25 @@ | |||
390 | 57 | }; | 57 | }; |
391 | 58 | 58 | ||
392 | 59 | 59 | ||
393 | 60 | //zorba-store-data-structure-unordered-map:create-transient | ||
394 | 61 | class zorba_store_data_structure_unordered_map_create_transient : public function | ||
395 | 62 | { | ||
396 | 63 | public: | ||
397 | 64 | zorba_store_data_structure_unordered_map_create_transient(const signature& sig, FunctionConsts::FunctionKind kind) | ||
398 | 65 | : | ||
399 | 66 | function(sig, kind) | ||
400 | 67 | { | ||
401 | 68 | |||
402 | 69 | } | ||
403 | 70 | |||
404 | 71 | unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; } | ||
405 | 72 | |||
406 | 73 | bool accessesDynCtx() const { return true; } | ||
407 | 74 | |||
408 | 75 | CODEGEN_DECL(); | ||
409 | 76 | }; | ||
410 | 77 | |||
411 | 78 | |||
412 | 60 | //zorba-store-data-structure-unordered-map:delete | 79 | //zorba-store-data-structure-unordered-map:delete |
413 | 61 | class zorba_store_data_structure_unordered_map_delete : public function | 80 | class zorba_store_data_structure_unordered_map_delete : public function |
414 | 62 | { | 81 | { |
415 | @@ -182,6 +201,23 @@ | |||
416 | 182 | }; | 201 | }; |
417 | 183 | 202 | ||
418 | 184 | 203 | ||
419 | 204 | //zorba-store-data-structure-unordered-map:is-transient | ||
420 | 205 | class zorba_store_data_structure_unordered_map_is_transient : public function | ||
421 | 206 | { | ||
422 | 207 | public: | ||
423 | 208 | zorba_store_data_structure_unordered_map_is_transient(const signature& sig, FunctionConsts::FunctionKind kind) | ||
424 | 209 | : | ||
425 | 210 | function(sig, kind) | ||
426 | 211 | { | ||
427 | 212 | |||
428 | 213 | } | ||
429 | 214 | |||
430 | 215 | bool accessesDynCtx() const { return true; } | ||
431 | 216 | |||
432 | 217 | CODEGEN_DECL(); | ||
433 | 218 | }; | ||
434 | 219 | |||
435 | 220 | |||
436 | 185 | } //namespace zorba | 221 | } //namespace zorba |
437 | 186 | 222 | ||
438 | 187 | 223 | ||
439 | 188 | 224 | ||
440 | === modified file 'src/functions/pregenerated/function_enum.h' | |||
441 | --- src/functions/pregenerated/function_enum.h 2012-06-18 10:06:47 +0000 | |||
442 | +++ src/functions/pregenerated/function_enum.h 2012-06-23 00:29:20 +0000 | |||
443 | @@ -401,6 +401,7 @@ | |||
444 | 401 | ZORBA_STORE_DOCUMENTS_AVAILABLE_DOCUMENTS_0, | 401 | ZORBA_STORE_DOCUMENTS_AVAILABLE_DOCUMENTS_0, |
445 | 402 | ZORBA_STORE_DOCUMENTS_IS_AVAILABLE_DOCUMENT_1, | 402 | ZORBA_STORE_DOCUMENTS_IS_AVAILABLE_DOCUMENT_1, |
446 | 403 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_CREATE_N, | 403 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_CREATE_N, |
447 | 404 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_CREATE_TRANSIENT_N, | ||
448 | 404 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_DELETE_1, | 405 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_DELETE_1, |
449 | 405 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_GET_N, | 406 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_GET_N, |
450 | 406 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_INSERT_N, | 407 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_INSERT_N, |
451 | @@ -408,6 +409,7 @@ | |||
452 | 408 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_KEYS_1, | 409 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_KEYS_1, |
453 | 409 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_SIZE_1, | 410 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_SIZE_1, |
454 | 410 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_AVAILABLE_MAPS_0, | 411 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_AVAILABLE_MAPS_0, |
455 | 412 | ZORBA_STORE_DATA_STRUCTURE_UNORDERED_MAP_IS_TRANSIENT_1, | ||
456 | 411 | FN_CODEPOINTS_TO_STRING_1, | 413 | FN_CODEPOINTS_TO_STRING_1, |
457 | 412 | FN_STRING_TO_CODEPOINTS_1, | 414 | FN_STRING_TO_CODEPOINTS_1, |
458 | 413 | FN_COMPARE_2, | 415 | FN_COMPARE_2, |
459 | 414 | 416 | ||
460 | === modified file 'src/runtime/pregenerated/iterator_enum.h' | |||
461 | --- src/runtime/pregenerated/iterator_enum.h 2012-06-18 10:06:47 +0000 | |||
462 | +++ src/runtime/pregenerated/iterator_enum.h 2012-06-23 00:29:20 +0000 | |||
463 | @@ -300,6 +300,7 @@ | |||
464 | 300 | TYPE_AvailableDocumentsIterator, | 300 | TYPE_AvailableDocumentsIterator, |
465 | 301 | TYPE_IsAvailableDocumentIterator, | 301 | TYPE_IsAvailableDocumentIterator, |
466 | 302 | TYPE_MapCreateIterator, | 302 | TYPE_MapCreateIterator, |
467 | 303 | TYPE_MapCreateTransientIterator, | ||
468 | 303 | TYPE_MapDestroyIterator, | 304 | TYPE_MapDestroyIterator, |
469 | 304 | TYPE_MapGetIterator, | 305 | TYPE_MapGetIterator, |
470 | 305 | TYPE_MapInsertIterator, | 306 | TYPE_MapInsertIterator, |
471 | @@ -307,6 +308,7 @@ | |||
472 | 307 | TYPE_MapKeysIterator, | 308 | TYPE_MapKeysIterator, |
473 | 308 | TYPE_MapSizeIterator, | 309 | TYPE_MapSizeIterator, |
474 | 309 | TYPE_AvailableMapsIterator, | 310 | TYPE_AvailableMapsIterator, |
475 | 311 | TYPE_MapIsTransientIterator, | ||
476 | 310 | TYPE_CodepointsToStringIterator, | 312 | TYPE_CodepointsToStringIterator, |
477 | 311 | TYPE_StringToCodepointsIterator, | 313 | TYPE_StringToCodepointsIterator, |
478 | 312 | TYPE_CompareStrIterator, | 314 | TYPE_CompareStrIterator, |
479 | 313 | 315 | ||
480 | === modified file 'src/runtime/spec/store/maps.xml' | |||
481 | --- src/runtime/spec/store/maps.xml 2012-06-18 10:06:47 +0000 | |||
482 | +++ src/runtime/spec/store/maps.xml 2012-06-23 00:29:20 +0000 | |||
483 | @@ -12,12 +12,13 @@ | |||
484 | 12 | xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd"> | 12 | xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd"> |
485 | 13 | 13 | ||
486 | 14 | <zorba:source> | 14 | <zorba:source> |
489 | 15 | <zorba:include form="Quoted">store/api/iterator.h</zorba:include> | 15 | <zorba:include form="Quoted">store/api/iterator.h</zorba:include> |
490 | 16 | <zorba:include form="Quoted">store/api/index.h</zorba:include> | 16 | <zorba:include form="Quoted">store/api/index.h</zorba:include> |
491 | 17 | </zorba:source> | 17 | </zorba:source> |
492 | 18 | 18 | ||
493 | 19 | <zorba:header> | 19 | <zorba:header> |
495 | 20 | <zorba:include form="Quoted">store/api/index.h</zorba:include> | 20 | <zorba:include form="Quoted">store/api/index.h</zorba:include> |
496 | 21 | <zorba:include form="Angle-bracket">vector</zorba:include> | ||
497 | 21 | </zorba:header> | 22 | </zorba:header> |
498 | 22 | 23 | ||
499 | 23 | 24 | ||
500 | @@ -54,6 +55,35 @@ | |||
501 | 54 | /******************************************************************************* | 55 | /******************************************************************************* |
502 | 55 | ********************************************************************************/ | 56 | ********************************************************************************/ |
503 | 56 | --> | 57 | --> |
504 | 58 | <zorba:iterator name="MapCreateTransientIterator" > | ||
505 | 59 | |||
506 | 60 | <zorba:description author="Matthias Brantner"> | ||
507 | 61 | </zorba:description> | ||
508 | 62 | |||
509 | 63 | <zorba:function> | ||
510 | 64 | |||
511 | 65 | <zorba:signature | ||
512 | 66 | variadic="true" | ||
513 | 67 | localname="create-transient" | ||
514 | 68 | prefix="zorba-store-data-structure-unordered-map"> | ||
515 | 69 | <zorba:param>xs:QName</zorba:param> <!-- name of the hashmap --> | ||
516 | 70 | <zorba:param>xs:QName</zorba:param> <!-- list of key types --> | ||
517 | 71 | <zorba:output>empty-sequence()</zorba:output> | ||
518 | 72 | </zorba:signature> | ||
519 | 73 | |||
520 | 74 | <zorba:methods> | ||
521 | 75 | <zorba:getScriptingKind returnValue="SEQUENTIAL_FUNC_EXPR"/> | ||
522 | 76 | <zorba:accessesDynCtx returnValue="true"/> | ||
523 | 77 | </zorba:methods> | ||
524 | 78 | |||
525 | 79 | </zorba:function> | ||
526 | 80 | |||
527 | 81 | </zorba:iterator> | ||
528 | 82 | |||
529 | 83 | <!-- | ||
530 | 84 | /******************************************************************************* | ||
531 | 85 | ********************************************************************************/ | ||
532 | 86 | --> | ||
533 | 57 | <zorba:iterator name="MapDestroyIterator" > | 87 | <zorba:iterator name="MapDestroyIterator" > |
534 | 58 | 88 | ||
535 | 59 | <zorba:description author="Matthias Brantner"> | 89 | <zorba:description author="Matthias Brantner"> |
536 | @@ -238,10 +268,40 @@ | |||
537 | 238 | </zorba:function> | 268 | </zorba:function> |
538 | 239 | 269 | ||
539 | 240 | <zorba:state generateInit="false" generateReset="false" generateDestructor="false"> | 270 | <zorba:state generateInit="false" generateReset="false" generateDestructor="false"> |
542 | 241 | <zorba:member type="store::Iterator_t" name="nameItState" | 271 | <zorba:member type="store::Iterator_t" |
543 | 242 | brief="the current iterator"/> | 272 | name="persistentMapNamesIter" |
544 | 273 | brief="the current iterator"/> | ||
545 | 274 | <zorba:member type="std::vector<store::Item_t>" | ||
546 | 275 | name="transientMapNames" brief="all the transient map names"/> | ||
547 | 276 | <zorba:member type="std::vector<store::Item_t>::const_iterator" | ||
548 | 277 | name="transientMapNamesIter" | ||
549 | 278 | brief="the current iterator"/> | ||
550 | 243 | </zorba:state> | 279 | </zorba:state> |
551 | 244 | 280 | ||
552 | 245 | </zorba:iterator> | 281 | </zorba:iterator> |
553 | 246 | 282 | ||
554 | 283 | <!-- | ||
555 | 284 | /******************************************************************************* | ||
556 | 285 | ********************************************************************************/ | ||
557 | 286 | --> | ||
558 | 287 | <zorba:iterator name="MapIsTransientIterator" > | ||
559 | 288 | |||
560 | 289 | <zorba:description author="Matthias Brantner"> | ||
561 | 290 | </zorba:description> | ||
562 | 291 | |||
563 | 292 | <zorba:function> | ||
564 | 293 | |||
565 | 294 | <zorba:signature localname="is-transient" prefix="zorba-store-data-structure-unordered-map"> | ||
566 | 295 | <zorba:param>xs:QName</zorba:param> | ||
567 | 296 | <zorba:output>xs:boolean</zorba:output> | ||
568 | 297 | </zorba:signature> | ||
569 | 298 | |||
570 | 299 | <zorba:methods> | ||
571 | 300 | <zorba:accessesDynCtx returnValue="true"/> | ||
572 | 301 | </zorba:methods> | ||
573 | 302 | |||
574 | 303 | </zorba:function> | ||
575 | 304 | |||
576 | 305 | </zorba:iterator> | ||
577 | 306 | |||
578 | 247 | </zorba:iterators> | 307 | </zorba:iterators> |
579 | 248 | 308 | ||
580 | === modified file 'src/runtime/store/maps_impl.cpp' | |||
581 | --- src/runtime/store/maps_impl.cpp 2012-06-18 10:06:47 +0000 | |||
582 | +++ src/runtime/store/maps_impl.cpp 2012-06-23 00:29:20 +0000 | |||
583 | @@ -1,5 +1,5 @@ | |||
584 | 1 | /* | 1 | /* |
586 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | 2 | * Copyright 2006-2012 The FLWOR Foundation. |
587 | 3 | * | 3 | * |
588 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
589 | 5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
590 | @@ -16,6 +16,7 @@ | |||
591 | 16 | #include "stdafx.h" | 16 | #include "stdafx.h" |
592 | 17 | 17 | ||
593 | 18 | #include "diagnostics/assert.h" | 18 | #include "diagnostics/assert.h" |
594 | 19 | #include "diagnostics/util_macros.h" | ||
595 | 19 | #include "diagnostics/xquery_diagnostics.h" | 20 | #include "diagnostics/xquery_diagnostics.h" |
596 | 20 | 21 | ||
597 | 21 | #include "zorbatypes/URI.h" | 22 | #include "zorbatypes/URI.h" |
598 | @@ -25,6 +26,7 @@ | |||
599 | 25 | #include "runtime/store/maps.h" | 26 | #include "runtime/store/maps.h" |
600 | 26 | 27 | ||
601 | 27 | #include "context/static_context.h" | 28 | #include "context/static_context.h" |
602 | 29 | #include "context/dynamic_context.h" | ||
603 | 28 | #include "context/namespace_context.h" | 30 | #include "context/namespace_context.h" |
604 | 29 | 31 | ||
605 | 30 | #include "store/api/pul.h" | 32 | #include "store/api/pul.h" |
606 | @@ -44,12 +46,9 @@ | |||
607 | 44 | 46 | ||
608 | 45 | namespace zorba { | 47 | namespace zorba { |
609 | 46 | 48 | ||
616 | 47 | #define RAISE_ERROR(errcode, loc, params) \ | 49 | /******************************************************************************* |
617 | 48 | throw XQUERY_EXCEPTION(errcode, \ | 50 | ********************************************************************************/ |
618 | 49 | params, \ | 51 | void |
613 | 50 | ERROR_LOC(loc)); | ||
614 | 51 | |||
615 | 52 | static void | ||
619 | 53 | castOrCheckIndexType( | 52 | castOrCheckIndexType( |
620 | 54 | store::Item_t& aKeyItem, | 53 | store::Item_t& aKeyItem, |
621 | 55 | const store::Item_t& aKeyType, | 54 | const store::Item_t& aKeyType, |
622 | @@ -101,50 +100,105 @@ | |||
623 | 101 | } | 100 | } |
624 | 102 | } | 101 | } |
625 | 103 | } | 102 | } |
627 | 104 | 103 | ||
628 | 105 | 104 | ||
629 | 106 | /******************************************************************************* | 105 | /******************************************************************************* |
630 | 107 | ********************************************************************************/ | 106 | ********************************************************************************/ |
635 | 108 | bool | 107 | void |
636 | 109 | MapCreateIterator::nextImpl( | 108 | checkMapTypes( |
637 | 110 | store::Item_t& result, | 109 | std::vector<store::Item_t>& aTypes, |
638 | 111 | PlanState& aPlanState) const | 110 | const store::Item_t& aMapName, |
639 | 111 | const QueryLoc& aLoc) | ||
640 | 112 | { | 112 | { |
641 | 113 | store::Item_t lQName; | ||
642 | 114 | std::vector<store::Item_t> lTypes; | ||
643 | 115 | std::vector<zstring> lCollations; | ||
644 | 116 | std::auto_ptr<store::PUL> lPul; | ||
645 | 117 | long lTimezone = 0; | ||
646 | 118 | xqtref_t lAnyAtomicType, lIndexKeyType; | 113 | xqtref_t lAnyAtomicType, lIndexKeyType; |
657 | 119 | size_t i; | 114 | |
658 | 120 | 115 | for (size_t i = 0; i < aTypes.size(); ++i) | |
649 | 121 | PlanIteratorState* state; | ||
650 | 122 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); | ||
651 | 123 | |||
652 | 124 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | ||
653 | 125 | |||
654 | 126 | lTypes.resize(theChildren.size() - 1); | ||
655 | 127 | lCollations.resize(theChildren.size() - 1); | ||
656 | 128 | for (i = 1; i < theChildren.size(); ++i) | ||
659 | 129 | { | 116 | { |
660 | 130 | consumeNext(lTypes[i-1], theChildren[i].getp(), aPlanState); | ||
661 | 131 | |||
662 | 132 | lAnyAtomicType = GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_ONE; | 117 | lAnyAtomicType = GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_ONE; |
663 | 133 | lIndexKeyType = GENV_TYPESYSTEM.create_named_type( | 118 | lIndexKeyType = GENV_TYPESYSTEM.create_named_type( |
665 | 134 | lTypes[i-1].getp(), TypeConstants::QUANT_ONE, loc); | 119 | aTypes[i].getp(), TypeConstants::QUANT_ONE, aLoc); |
666 | 135 | 120 | ||
667 | 136 | if (lIndexKeyType != NULL && | 121 | if (lIndexKeyType != NULL && |
668 | 137 | !TypeOps::is_subtype(&GENV_TYPESYSTEM, | 122 | !TypeOps::is_subtype(&GENV_TYPESYSTEM, |
669 | 138 | *lIndexKeyType, *lAnyAtomicType)) | 123 | *lIndexKeyType, *lAnyAtomicType)) |
670 | 139 | { | 124 | { |
672 | 140 | RAISE_ERROR(err::XPTY0004, loc, | 125 | RAISE_ERROR(err::XPTY0004, aLoc, |
673 | 141 | ERROR_PARAMS(ZED(SearchKeyTypeMismatch_234), | 126 | ERROR_PARAMS(ZED(SearchKeyTypeMismatch_234), |
674 | 142 | *lAnyAtomicType, | 127 | *lAnyAtomicType, |
676 | 143 | lQName->getStringValue(), | 128 | aMapName->getStringValue(), |
677 | 144 | *lIndexKeyType) | 129 | *lIndexKeyType) |
678 | 145 | ); | 130 | ); |
679 | 146 | } | 131 | } |
680 | 147 | } | 132 | } |
681 | 133 | } | ||
682 | 134 | |||
683 | 135 | |||
684 | 136 | /******************************************************************************* | ||
685 | 137 | ********************************************************************************/ | ||
686 | 138 | bool | ||
687 | 139 | getMap( | ||
688 | 140 | const store::Item_t& aName, | ||
689 | 141 | const QueryLoc& aLoc, | ||
690 | 142 | dynamic_context* aContext, | ||
691 | 143 | store::Index*& aIndex) | ||
692 | 144 | { | ||
693 | 145 | aIndex = GENV_STORE.getMap(aName); | ||
694 | 146 | |||
695 | 147 | if (aIndex) return true; | ||
696 | 148 | |||
697 | 149 | aIndex = aContext->getMap(aName.getp()); | ||
698 | 150 | |||
699 | 151 | if (!aIndex) | ||
700 | 152 | { | ||
701 | 153 | RAISE_ERROR( | ||
702 | 154 | zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, | ||
703 | 155 | aLoc, | ||
704 | 156 | ERROR_PARAMS( aName->getStringValue() ) | ||
705 | 157 | ); | ||
706 | 158 | } | ||
707 | 159 | |||
708 | 160 | return false; | ||
709 | 161 | } | ||
710 | 162 | |||
711 | 163 | |||
712 | 164 | |||
713 | 165 | /******************************************************************************* | ||
714 | 166 | ********************************************************************************/ | ||
715 | 167 | bool | ||
716 | 168 | MapCreateIterator::nextImpl( | ||
717 | 169 | store::Item_t& result, | ||
718 | 170 | PlanState& aPlanState) const | ||
719 | 171 | { | ||
720 | 172 | store::Item_t lQName; | ||
721 | 173 | std::vector<store::Item_t> lTypes; | ||
722 | 174 | std::vector<zstring> lCollations; | ||
723 | 175 | std::auto_ptr<store::PUL> lPul; | ||
724 | 176 | long lTimezone = 0; | ||
725 | 177 | |||
726 | 178 | PlanIteratorState* state; | ||
727 | 179 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); | ||
728 | 180 | |||
729 | 181 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | ||
730 | 182 | |||
731 | 183 | if (GENV_STORE.getMap(lQName) | ||
732 | 184 | || aPlanState.theLocalDynCtx->getMap(lQName.getp())) | ||
733 | 185 | { | ||
734 | 186 | RAISE_ERROR( | ||
735 | 187 | zerr::ZSTR0001_INDEX_ALREADY_EXISTS, | ||
736 | 188 | loc, | ||
737 | 189 | ERROR_PARAMS( lQName->getStringValue() ) | ||
738 | 190 | ); | ||
739 | 191 | } | ||
740 | 192 | |||
741 | 193 | lCollations.resize(theChildren.size() - 1); | ||
742 | 194 | lTypes.resize(theChildren.size() - 1); | ||
743 | 195 | |||
744 | 196 | for (size_t i = 1; i < theChildren.size(); ++i) | ||
745 | 197 | { | ||
746 | 198 | consumeNext(lTypes[i-1], theChildren[i].getp(), aPlanState); | ||
747 | 199 | } | ||
748 | 200 | |||
749 | 201 | checkMapTypes(lTypes, lQName, loc); | ||
750 | 148 | 202 | ||
751 | 149 | lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); | 203 | lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); |
752 | 150 | lPul->addCreateHashMap(&loc, lQName, lTypes, lCollations, lTimezone); | 204 | lPul->addCreateHashMap(&loc, lQName, lTypes, lCollations, lTimezone); |
753 | @@ -165,40 +219,86 @@ | |||
754 | 165 | /******************************************************************************* | 219 | /******************************************************************************* |
755 | 166 | ********************************************************************************/ | 220 | ********************************************************************************/ |
756 | 167 | bool | 221 | bool |
757 | 222 | MapCreateTransientIterator::nextImpl( | ||
758 | 223 | store::Item_t& result, | ||
759 | 224 | PlanState& aPlanState) const | ||
760 | 225 | { | ||
761 | 226 | store::Item_t lQName; | ||
762 | 227 | store::IndexSpecification lSpec; | ||
763 | 228 | store::Index_t lIndex; | ||
764 | 229 | std::vector<std::string> lCollations; | ||
765 | 230 | |||
766 | 231 | PlanIteratorState* state; | ||
767 | 232 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); | ||
768 | 233 | |||
769 | 234 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | ||
770 | 235 | |||
771 | 236 | if (GENV_STORE.getMap(lQName) | ||
772 | 237 | || aPlanState.theLocalDynCtx->getMap(lQName.getp())) | ||
773 | 238 | { | ||
774 | 239 | RAISE_ERROR( | ||
775 | 240 | zerr::ZSTR0001_INDEX_ALREADY_EXISTS, | ||
776 | 241 | loc, | ||
777 | 242 | ERROR_PARAMS( lQName->getStringValue() ) | ||
778 | 243 | ); | ||
779 | 244 | } | ||
780 | 245 | |||
781 | 246 | lCollations.resize(theChildren.size() - 1); | ||
782 | 247 | lSpec.theKeyTypes.resize(theChildren.size() - 1); | ||
783 | 248 | |||
784 | 249 | for (size_t i = 1; i < theChildren.size(); ++i) | ||
785 | 250 | { | ||
786 | 251 | consumeNext(lSpec.theKeyTypes[i-1], theChildren[i].getp(), aPlanState); | ||
787 | 252 | } | ||
788 | 253 | |||
789 | 254 | checkMapTypes(lSpec.theKeyTypes, lQName, loc); | ||
790 | 255 | |||
791 | 256 | lSpec.theNumKeyColumns = lSpec.theKeyTypes.size(); | ||
792 | 257 | lSpec.theIsTemp = true; | ||
793 | 258 | lSpec.theCollations = lCollations; | ||
794 | 259 | lSpec.theTimezone = 0; | ||
795 | 260 | |||
796 | 261 | lIndex = GENV_STORE.createMap(lQName, lSpec); | ||
797 | 262 | |||
798 | 263 | aPlanState.theLocalDynCtx->bindMap(lIndex->getName(), lIndex); | ||
799 | 264 | |||
800 | 265 | result = NULL; | ||
801 | 266 | |||
802 | 267 | STACK_END(state); | ||
803 | 268 | } | ||
804 | 269 | |||
805 | 270 | |||
806 | 271 | /******************************************************************************* | ||
807 | 272 | ********************************************************************************/ | ||
808 | 273 | bool | ||
809 | 168 | MapDestroyIterator::nextImpl( | 274 | MapDestroyIterator::nextImpl( |
810 | 169 | store::Item_t& result, | 275 | store::Item_t& result, |
811 | 170 | PlanState& aPlanState) const | 276 | PlanState& aPlanState) const |
812 | 171 | { | 277 | { |
813 | 172 | store::Item_t lQName; | 278 | store::Item_t lQName; |
816 | 173 | std::auto_ptr<store::PUL> lPul; | 279 | store::Index* lIndex; |
815 | 174 | store::Index_t lIndex; | ||
817 | 175 | 280 | ||
818 | 176 | PlanIteratorState* state; | 281 | PlanIteratorState* state; |
819 | 177 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); | 282 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); |
820 | 178 | 283 | ||
821 | 179 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | 284 | consumeNext(lQName, theChildren[0].getp(), aPlanState); |
822 | 180 | 285 | ||
844 | 181 | lIndex = GENV_STORE.getMap(lQName); | 286 | if (getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex)) |
845 | 182 | 287 | { | |
846 | 183 | if (!lIndex) | 288 | std::auto_ptr<store::PUL> lPul(GENV_ITEMFACTORY->createPendingUpdateList()); |
847 | 184 | { | 289 | lPul->addDestroyHashMap(&loc, lQName); |
848 | 185 | throw XQUERY_EXCEPTION( | 290 | |
849 | 186 | zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, | 291 | apply_updates( |
850 | 187 | ERROR_PARAMS( lQName->getStringValue() ), | 292 | aPlanState.theCompilerCB, |
851 | 188 | ERROR_LOC( loc ) | 293 | aPlanState.theGlobalDynCtx, |
852 | 189 | ); | 294 | theSctx, |
853 | 190 | } | 295 | lPul.get(), |
854 | 191 | 296 | loc); | |
855 | 192 | 297 | } | |
856 | 193 | lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); | 298 | else |
857 | 194 | lPul->addDestroyHashMap(&loc, lQName); | 299 | { |
858 | 195 | 300 | aPlanState.theLocalDynCtx->unbindMap(lQName.getp()); | |
859 | 196 | apply_updates( | 301 | } |
839 | 197 | aPlanState.theCompilerCB, | ||
840 | 198 | aPlanState.theGlobalDynCtx, | ||
841 | 199 | theSctx, | ||
842 | 200 | lPul.get(), | ||
843 | 201 | loc); | ||
860 | 202 | 302 | ||
861 | 203 | result = NULL; | 303 | result = NULL; |
862 | 204 | 304 | ||
863 | @@ -224,29 +324,20 @@ | |||
864 | 224 | 324 | ||
865 | 225 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | 325 | consumeNext(lQName, theChildren[0].getp(), aPlanState); |
866 | 226 | 326 | ||
877 | 227 | lIndex = GENV_STORE.getMap(lQName); | 327 | getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex); |
868 | 228 | |||
869 | 229 | if (!lIndex) | ||
870 | 230 | { | ||
871 | 231 | throw XQUERY_EXCEPTION( | ||
872 | 232 | zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, | ||
873 | 233 | ERROR_PARAMS( lQName->getStringValue() ), | ||
874 | 234 | ERROR_LOC( loc ) | ||
875 | 235 | ); | ||
876 | 236 | } | ||
878 | 237 | 328 | ||
879 | 238 | lSpec = lIndex->getSpecification(); | 329 | lSpec = lIndex->getSpecification(); |
880 | 239 | 330 | ||
881 | 240 | if (lSpec.getNumColumns() != theChildren.size() - 1) | 331 | if (lSpec.getNumColumns() != theChildren.size() - 1) |
882 | 241 | { | 332 | { |
884 | 242 | throw XQUERY_EXCEPTION( | 333 | RAISE_ERROR( |
885 | 243 | zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, | 334 | zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, |
886 | 335 | loc, | ||
887 | 244 | ERROR_PARAMS( | 336 | ERROR_PARAMS( |
888 | 245 | lQName->getStringValue(), | 337 | lQName->getStringValue(), |
889 | 246 | "map", | 338 | "map", |
890 | 247 | theChildren.size() - 1, | 339 | theChildren.size() - 1, |
893 | 248 | lSpec.getNumColumns() ), | 340 | lSpec.getNumColumns() ) |
892 | 249 | ERROR_LOC( loc ) | ||
894 | 250 | ); | 341 | ); |
895 | 251 | } | 342 | } |
896 | 252 | 343 | ||
897 | @@ -293,63 +384,85 @@ | |||
898 | 293 | { | 384 | { |
899 | 294 | store::Item_t lQName; | 385 | store::Item_t lQName; |
900 | 295 | std::vector<store::Item_t> lKey; | 386 | std::vector<store::Item_t> lKey; |
901 | 296 | store::Iterator_t lValue; | ||
902 | 297 | std::auto_ptr<store::PUL> lPul; | ||
903 | 298 | store::IndexSpecification lSpec; | 387 | store::IndexSpecification lSpec; |
905 | 299 | store::Index_t lIndex; | 388 | store::Index* lIndex; |
906 | 389 | bool lPersistent; | ||
907 | 300 | 390 | ||
908 | 301 | PlanIteratorState* state; | 391 | PlanIteratorState* state; |
909 | 302 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); | 392 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); |
910 | 303 | 393 | ||
911 | 304 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | 394 | consumeNext(lQName, theChildren[0].getp(), aPlanState); |
912 | 305 | 395 | ||
923 | 306 | lIndex = GENV_STORE.getMap(lQName); | 396 | lPersistent = getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex); |
914 | 307 | |||
915 | 308 | if (!lIndex) | ||
916 | 309 | { | ||
917 | 310 | throw XQUERY_EXCEPTION( | ||
918 | 311 | zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, | ||
919 | 312 | ERROR_PARAMS( lQName->getStringValue() ), | ||
920 | 313 | ERROR_LOC( loc ) | ||
921 | 314 | ); | ||
922 | 315 | } | ||
924 | 316 | 397 | ||
925 | 317 | lSpec = lIndex->getSpecification(); | 398 | lSpec = lIndex->getSpecification(); |
926 | 318 | 399 | ||
927 | 319 | if (lSpec.getNumColumns() != theChildren.size() - 2) | 400 | if (lSpec.getNumColumns() != theChildren.size() - 2) |
928 | 320 | { | 401 | { |
930 | 321 | throw XQUERY_EXCEPTION( | 402 | RAISE_ERROR( |
931 | 322 | zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, | 403 | zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, |
932 | 404 | loc, | ||
933 | 323 | ERROR_PARAMS( | 405 | ERROR_PARAMS( |
934 | 324 | lQName->getStringValue(), | 406 | lQName->getStringValue(), |
935 | 325 | "map", | 407 | "map", |
936 | 326 | theChildren.size() - 2, | 408 | theChildren.size() - 2, |
939 | 327 | lSpec.getNumColumns() ), | 409 | lSpec.getNumColumns() ) |
938 | 328 | ERROR_LOC( loc ) | ||
940 | 329 | ); | 410 | ); |
941 | 330 | } | 411 | } |
942 | 331 | 412 | ||
943 | 332 | lValue = new PlanIteratorWrapper(theChildren[1], aPlanState); | ||
944 | 333 | |||
945 | 334 | lKey.resize(theChildren.size() - 2); | 413 | lKey.resize(theChildren.size() - 2); |
946 | 335 | for (size_t i = 2; i < theChildren.size(); ++i) | 414 | for (size_t i = 2; i < theChildren.size(); ++i) |
947 | 336 | { | 415 | { |
948 | 337 | if (consumeNext(lKey[i-2], theChildren[i].getp(), aPlanState)) | 416 | if (consumeNext(lKey[i-2], theChildren[i].getp(), aPlanState)) |
949 | 338 | { | 417 | { |
950 | 339 | namespace_context tmp_ctx(theSctx); | 418 | namespace_context tmp_ctx(theSctx); |
964 | 340 | castOrCheckIndexType(lKey[i-2], lSpec.theKeyTypes[i-2], lQName, &tmp_ctx, loc); | 419 | castOrCheckIndexType( |
965 | 341 | } | 420 | lKey[i-2], |
966 | 342 | } | 421 | lSpec.theKeyTypes[i-2], |
967 | 343 | 422 | lQName, | |
968 | 344 | lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); | 423 | &tmp_ctx, |
969 | 345 | lPul->addInsertIntoHashMap(&loc, lQName, lKey, lValue); | 424 | loc); |
970 | 346 | 425 | } | |
971 | 347 | apply_updates( | 426 | } |
972 | 348 | aPlanState.theCompilerCB, | 427 | |
973 | 349 | aPlanState.theGlobalDynCtx, | 428 | if (lPersistent) |
974 | 350 | theSctx, | 429 | { |
975 | 351 | lPul.get(), | 430 | std::auto_ptr<store::PUL> lPul; |
976 | 352 | loc); | 431 | store::Iterator_t lValue |
977 | 432 | = new PlanIteratorWrapper(theChildren[1], aPlanState); | ||
978 | 433 | |||
979 | 434 | lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); | ||
980 | 435 | lPul->addInsertIntoHashMap(&loc, lQName, lKey, lValue); | ||
981 | 436 | |||
982 | 437 | apply_updates( | ||
983 | 438 | aPlanState.theCompilerCB, | ||
984 | 439 | aPlanState.theGlobalDynCtx, | ||
985 | 440 | theSctx, | ||
986 | 441 | lPul.get(), | ||
987 | 442 | loc); | ||
988 | 443 | } | ||
989 | 444 | else | ||
990 | 445 | { | ||
991 | 446 | store::Item_t lValue; | ||
992 | 447 | while (consumeNext(lValue, theChildren[1], aPlanState)) | ||
993 | 448 | { | ||
994 | 449 | std::auto_ptr<store::IndexKey> k(new store::IndexKey()); | ||
995 | 450 | for (std::vector<store::Item_t>::const_iterator lIter = lKey.begin(); | ||
996 | 451 | lIter != lKey.end(); | ||
997 | 452 | ++lIter) | ||
998 | 453 | { | ||
999 | 454 | k->push_back(*lIter); | ||
1000 | 455 | } | ||
1001 | 456 | |||
1002 | 457 | store::IndexKey* lKeyPtr = k.get(); | ||
1003 | 458 | if (!lIndex->insert(lKeyPtr, lValue)) | ||
1004 | 459 | { | ||
1005 | 460 | // the index took the ownership over the key if the index | ||
1006 | 461 | // did _not_ already contain an entry with the same key | ||
1007 | 462 | k.release(); | ||
1008 | 463 | } | ||
1009 | 464 | } | ||
1010 | 465 | } | ||
1011 | 353 | 466 | ||
1012 | 354 | result = NULL; | 467 | result = NULL; |
1013 | 355 | 468 | ||
1014 | @@ -371,36 +484,28 @@ | |||
1015 | 371 | store::Item_t lKeyItem; | 484 | store::Item_t lKeyItem; |
1016 | 372 | std::auto_ptr<store::PUL> lPul; | 485 | std::auto_ptr<store::PUL> lPul; |
1017 | 373 | store::IndexSpecification lSpec; | 486 | store::IndexSpecification lSpec; |
1018 | 487 | bool lPersistent; | ||
1019 | 374 | 488 | ||
1020 | 375 | PlanIteratorState* state; | 489 | PlanIteratorState* state; |
1021 | 376 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); | 490 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); |
1022 | 377 | 491 | ||
1023 | 378 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | 492 | consumeNext(lQName, theChildren[0].getp(), aPlanState); |
1024 | 379 | 493 | ||
1035 | 380 | lIndex = GENV_STORE.getMap(lQName); | 494 | lPersistent = getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex); |
1026 | 381 | |||
1027 | 382 | if (!lIndex) | ||
1028 | 383 | { | ||
1029 | 384 | throw XQUERY_EXCEPTION( | ||
1030 | 385 | zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, | ||
1031 | 386 | ERROR_PARAMS( lQName->getStringValue() ), | ||
1032 | 387 | ERROR_LOC( loc ) | ||
1033 | 388 | ); | ||
1034 | 389 | } | ||
1036 | 390 | 495 | ||
1037 | 391 | lSpec = lIndex->getSpecification(); | 496 | lSpec = lIndex->getSpecification(); |
1038 | 392 | 497 | ||
1039 | 393 | if (lSpec.getNumColumns() != theChildren.size() - 1) | 498 | if (lSpec.getNumColumns() != theChildren.size() - 1) |
1040 | 394 | { | 499 | { |
1042 | 395 | throw XQUERY_EXCEPTION( | 500 | RAISE_ERROR( |
1043 | 396 | zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, | 501 | zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, |
1044 | 502 | loc, | ||
1045 | 397 | ERROR_PARAMS( | 503 | ERROR_PARAMS( |
1046 | 398 | lQName->getStringValue(), | 504 | lQName->getStringValue(), |
1047 | 399 | "map", | 505 | "map", |
1048 | 400 | theChildren.size() - 1, | 506 | theChildren.size() - 1, |
1049 | 401 | lSpec.getNumColumns() | 507 | lSpec.getNumColumns() |
1052 | 402 | ), | 508 | ) |
1051 | 403 | ERROR_LOC( loc ) | ||
1053 | 404 | ); | 509 | ); |
1054 | 405 | } | 510 | } |
1055 | 406 | 511 | ||
1056 | @@ -414,15 +519,30 @@ | |||
1057 | 414 | } | 519 | } |
1058 | 415 | } | 520 | } |
1059 | 416 | 521 | ||
1062 | 417 | lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); | 522 | if (lPersistent) |
1063 | 418 | lPul->addRemoveFromHashMap(&loc, lQName, lKey); | 523 | { |
1064 | 524 | lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); | ||
1065 | 525 | lPul->addRemoveFromHashMap(&loc, lQName, lKey); | ||
1066 | 419 | 526 | ||
1073 | 420 | apply_updates( | 527 | apply_updates( |
1074 | 421 | aPlanState.theCompilerCB, | 528 | aPlanState.theCompilerCB, |
1075 | 422 | aPlanState.theGlobalDynCtx, | 529 | aPlanState.theGlobalDynCtx, |
1076 | 423 | theSctx, | 530 | theSctx, |
1077 | 424 | lPul.get(), | 531 | lPul.get(), |
1078 | 425 | loc); | 532 | loc); |
1079 | 533 | } | ||
1080 | 534 | else | ||
1081 | 535 | { | ||
1082 | 536 | store::IndexKey k; | ||
1083 | 537 | for (std::vector<store::Item_t>::const_iterator lIter = lKey.begin(); | ||
1084 | 538 | lIter != lKey.end(); | ||
1085 | 539 | ++lIter) | ||
1086 | 540 | { | ||
1087 | 541 | k.push_back(*lIter); | ||
1088 | 542 | } | ||
1089 | 543 | store::Item_t lValue; | ||
1090 | 544 | lIndex->remove(&k, lValue, true); | ||
1091 | 545 | } | ||
1092 | 426 | 546 | ||
1093 | 427 | result = NULL; | 547 | result = NULL; |
1094 | 428 | 548 | ||
1095 | @@ -454,16 +574,7 @@ | |||
1096 | 454 | 574 | ||
1097 | 455 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | 575 | consumeNext(lQName, theChildren[0].getp(), aPlanState); |
1098 | 456 | 576 | ||
1109 | 457 | lIndex = GENV_STORE.getMap(lQName); | 577 | getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex); |
1100 | 458 | |||
1101 | 459 | if (!lIndex) | ||
1102 | 460 | { | ||
1103 | 461 | throw XQUERY_EXCEPTION( | ||
1104 | 462 | zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, | ||
1105 | 463 | ERROR_PARAMS( lQName->getStringValue() ), | ||
1106 | 464 | ERROR_LOC( loc ) | ||
1107 | 465 | ); | ||
1108 | 466 | } | ||
1110 | 467 | 578 | ||
1111 | 468 | state->theIter = lIndex->keys(); | 579 | state->theIter = lIndex->keys(); |
1112 | 469 | 580 | ||
1113 | @@ -494,18 +605,23 @@ | |||
1114 | 494 | static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS, | 605 | static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS, |
1115 | 495 | "", "attribute"); | 606 | "", "attribute"); |
1116 | 496 | 607 | ||
1117 | 497 | GENV_ITEMFACTORY->createQName(lValueAttrName, | ||
1118 | 498 | "", "", "value"); | ||
1119 | 499 | |||
1120 | 500 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | 608 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; |
1121 | 501 | 609 | ||
1122 | 502 | GENV_ITEMFACTORY->createElementNode( | 610 | GENV_ITEMFACTORY->createElementNode( |
1123 | 503 | lAttrElem, result, lAttrNodeName, lTypeName, | 611 | lAttrElem, result, lAttrNodeName, lTypeName, |
1124 | 504 | true, false, theNSBindings, lBaseURI); | 612 | true, false, theNSBindings, lBaseURI); |
1125 | 505 | 613 | ||
1129 | 506 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | 614 | store::Item_t& lValue = (*lIter); |
1130 | 507 | GENV_ITEMFACTORY->createAttributeNode( | 615 | if (! lValue.isNull()) |
1131 | 508 | lValueAttr, lAttrElem.getp(), lValueAttrName, lTypeName, (*lIter)); | 616 | { |
1132 | 617 | GENV_ITEMFACTORY->createQName(lValueAttrName, | ||
1133 | 618 | "", "", "value"); | ||
1134 | 619 | |||
1135 | 620 | lTypeName = lValue->getType(); | ||
1136 | 621 | |||
1137 | 622 | GENV_ITEMFACTORY->createAttributeNode( | ||
1138 | 623 | lValueAttr, lAttrElem.getp(), lValueAttrName, lTypeName, lValue); | ||
1139 | 624 | } | ||
1140 | 509 | } | 625 | } |
1141 | 510 | STACK_PUSH(true, state); | 626 | STACK_PUSH(true, state); |
1142 | 511 | } | 627 | } |
1143 | @@ -529,16 +645,7 @@ | |||
1144 | 529 | 645 | ||
1145 | 530 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | 646 | consumeNext(lQName, theChildren[0].getp(), aPlanState); |
1146 | 531 | 647 | ||
1157 | 532 | lIndex = GENV_STORE.getMap(lQName); | 648 | getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex); |
1148 | 533 | |||
1149 | 534 | if (!lIndex) | ||
1150 | 535 | { | ||
1151 | 536 | throw XQUERY_EXCEPTION( | ||
1152 | 537 | zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, | ||
1153 | 538 | ERROR_PARAMS( lQName->getStringValue() ), | ||
1154 | 539 | ERROR_LOC( loc ) | ||
1155 | 540 | ); | ||
1156 | 541 | } | ||
1158 | 542 | 649 | ||
1159 | 543 | GENV_ITEMFACTORY->createInteger(result, xs_integer(lIndex->size())); | 650 | GENV_ITEMFACTORY->createInteger(result, xs_integer(lIndex->size())); |
1160 | 544 | 651 | ||
1161 | @@ -547,33 +654,36 @@ | |||
1162 | 547 | STACK_END(state); | 654 | STACK_END(state); |
1163 | 548 | } | 655 | } |
1164 | 549 | 656 | ||
1165 | 657 | |||
1166 | 550 | /******************************************************************************* | 658 | /******************************************************************************* |
1167 | 551 | 659 | ||
1168 | 552 | ********************************************************************************/ | 660 | ********************************************************************************/ |
1169 | 553 | AvailableMapsIteratorState::~AvailableMapsIteratorState() | 661 | AvailableMapsIteratorState::~AvailableMapsIteratorState() |
1170 | 554 | { | 662 | { |
1172 | 555 | if ( nameItState != NULL ) | 663 | if ( persistentMapNamesIter != NULL ) |
1173 | 556 | { | 664 | { |
1176 | 557 | nameItState->close(); | 665 | persistentMapNamesIter->close(); |
1177 | 558 | nameItState = NULL; | 666 | persistentMapNamesIter = NULL; |
1178 | 559 | } | 667 | } |
1179 | 668 | transientMapNames.clear(); | ||
1180 | 560 | } | 669 | } |
1181 | 561 | 670 | ||
1182 | 562 | 671 | ||
1183 | 563 | void AvailableMapsIteratorState::init(PlanState& planState) | 672 | void AvailableMapsIteratorState::init(PlanState& planState) |
1184 | 564 | { | 673 | { |
1185 | 565 | PlanIteratorState::init(planState); | 674 | PlanIteratorState::init(planState); |
1187 | 566 | nameItState = NULL; | 675 | persistentMapNamesIter = NULL; |
1188 | 567 | } | 676 | } |
1189 | 568 | 677 | ||
1190 | 569 | 678 | ||
1191 | 570 | void AvailableMapsIteratorState::reset(PlanState& planState) | 679 | void AvailableMapsIteratorState::reset(PlanState& planState) |
1192 | 571 | { | 680 | { |
1193 | 572 | PlanIteratorState::reset(planState); | 681 | PlanIteratorState::reset(planState); |
1197 | 573 | if ( nameItState != NULL ) { | 682 | if ( persistentMapNamesIter != NULL ) { |
1198 | 574 | nameItState->close(); | 683 | persistentMapNamesIter->close(); |
1199 | 575 | nameItState = NULL; | 684 | persistentMapNamesIter = NULL; |
1200 | 576 | } | 685 | } |
1201 | 686 | transientMapNames.clear(); | ||
1202 | 577 | } | 687 | } |
1203 | 578 | 688 | ||
1204 | 579 | 689 | ||
1205 | @@ -585,18 +695,54 @@ | |||
1206 | 585 | 695 | ||
1207 | 586 | DEFAULT_STACK_INIT(AvailableMapsIteratorState, state, planState); | 696 | DEFAULT_STACK_INIT(AvailableMapsIteratorState, state, planState); |
1208 | 587 | 697 | ||
1211 | 588 | for ((state->nameItState = GENV_STORE.listMapNames())->open (); | 698 | for ((state->persistentMapNamesIter = GENV_STORE.listMapNames())->open (); |
1212 | 589 | state->nameItState->next(nameItem); ) | 699 | state->persistentMapNamesIter->next(nameItem); ) |
1213 | 590 | { | 700 | { |
1214 | 591 | result = nameItem; | 701 | result = nameItem; |
1215 | 592 | STACK_PUSH( true, state); | 702 | STACK_PUSH( true, state); |
1216 | 593 | } | 703 | } |
1217 | 594 | 704 | ||
1219 | 595 | state->nameItState->close(); | 705 | state->persistentMapNamesIter->close(); |
1220 | 706 | |||
1221 | 707 | planState.theLocalDynCtx->getMapNames(state->transientMapNames); | ||
1222 | 708 | |||
1223 | 709 | for (state->transientMapNamesIter = state->transientMapNames.begin(); | ||
1224 | 710 | state->transientMapNamesIter != state->transientMapNames.end(); | ||
1225 | 711 | ++state->transientMapNamesIter) | ||
1226 | 712 | { | ||
1227 | 713 | result = *state->transientMapNamesIter; | ||
1228 | 714 | STACK_PUSH( true, state); | ||
1229 | 715 | } | ||
1230 | 596 | 716 | ||
1231 | 597 | STACK_END (state); | 717 | STACK_END (state); |
1232 | 598 | } | 718 | } |
1233 | 599 | 719 | ||
1234 | 600 | 720 | ||
1235 | 721 | /******************************************************************************* | ||
1236 | 722 | ********************************************************************************/ | ||
1237 | 723 | bool | ||
1238 | 724 | MapIsTransientIterator::nextImpl( | ||
1239 | 725 | store::Item_t& result, | ||
1240 | 726 | PlanState& aPlanState) const | ||
1241 | 727 | { | ||
1242 | 728 | store::Item_t lQName; | ||
1243 | 729 | store::Index* lIndex; | ||
1244 | 730 | bool lPersistent; | ||
1245 | 731 | |||
1246 | 732 | PlanIteratorState* state; | ||
1247 | 733 | DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState); | ||
1248 | 734 | |||
1249 | 735 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | ||
1250 | 736 | |||
1251 | 737 | lPersistent = getMap(lQName, loc, aPlanState.theLocalDynCtx, lIndex); | ||
1252 | 738 | |||
1253 | 739 | GENV_ITEMFACTORY->createBoolean(result, !lPersistent); | ||
1254 | 740 | |||
1255 | 741 | STACK_PUSH(true, state); | ||
1256 | 742 | |||
1257 | 743 | STACK_END(state); | ||
1258 | 744 | } | ||
1259 | 745 | |||
1260 | 746 | |||
1261 | 601 | } // namespace zorba | 747 | } // namespace zorba |
1262 | 602 | /* vim:set et sw=2 ts=2: */ | 748 | /* vim:set et sw=2 ts=2: */ |
1263 | 603 | 749 | ||
1264 | === modified file 'src/runtime/store/pregenerated/maps.cpp' | |||
1265 | --- src/runtime/store/pregenerated/maps.cpp 2012-06-18 10:06:47 +0000 | |||
1266 | +++ src/runtime/store/pregenerated/maps.cpp 2012-06-23 00:29:20 +0000 | |||
1267 | @@ -62,6 +62,34 @@ | |||
1268 | 62 | // </MapCreateIterator> | 62 | // </MapCreateIterator> |
1269 | 63 | 63 | ||
1270 | 64 | 64 | ||
1271 | 65 | // <MapCreateTransientIterator> | ||
1272 | 66 | SERIALIZABLE_CLASS_VERSIONS(MapCreateTransientIterator) | ||
1273 | 67 | |||
1274 | 68 | void MapCreateTransientIterator::serialize(::zorba::serialization::Archiver& ar) | ||
1275 | 69 | { | ||
1276 | 70 | serialize_baseclass(ar, | ||
1277 | 71 | (NaryBaseIterator<MapCreateTransientIterator, PlanIteratorState>*)this); | ||
1278 | 72 | } | ||
1279 | 73 | |||
1280 | 74 | |||
1281 | 75 | void MapCreateTransientIterator::accept(PlanIterVisitor& v) const | ||
1282 | 76 | { | ||
1283 | 77 | v.beginVisit(*this); | ||
1284 | 78 | |||
1285 | 79 | std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); | ||
1286 | 80 | std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); | ||
1287 | 81 | for ( ; lIter != lEnd; ++lIter ){ | ||
1288 | 82 | (*lIter)->accept(v); | ||
1289 | 83 | } | ||
1290 | 84 | |||
1291 | 85 | v.endVisit(*this); | ||
1292 | 86 | } | ||
1293 | 87 | |||
1294 | 88 | MapCreateTransientIterator::~MapCreateTransientIterator() {} | ||
1295 | 89 | |||
1296 | 90 | // </MapCreateTransientIterator> | ||
1297 | 91 | |||
1298 | 92 | |||
1299 | 65 | // <MapDestroyIterator> | 93 | // <MapDestroyIterator> |
1300 | 66 | SERIALIZABLE_CLASS_VERSIONS(MapDestroyIterator) | 94 | SERIALIZABLE_CLASS_VERSIONS(MapDestroyIterator) |
1301 | 67 | 95 | ||
1302 | @@ -286,6 +314,34 @@ | |||
1303 | 286 | // </AvailableMapsIterator> | 314 | // </AvailableMapsIterator> |
1304 | 287 | 315 | ||
1305 | 288 | 316 | ||
1306 | 317 | // <MapIsTransientIterator> | ||
1307 | 318 | SERIALIZABLE_CLASS_VERSIONS(MapIsTransientIterator) | ||
1308 | 319 | |||
1309 | 320 | void MapIsTransientIterator::serialize(::zorba::serialization::Archiver& ar) | ||
1310 | 321 | { | ||
1311 | 322 | serialize_baseclass(ar, | ||
1312 | 323 | (NaryBaseIterator<MapIsTransientIterator, PlanIteratorState>*)this); | ||
1313 | 324 | } | ||
1314 | 325 | |||
1315 | 326 | |||
1316 | 327 | void MapIsTransientIterator::accept(PlanIterVisitor& v) const | ||
1317 | 328 | { | ||
1318 | 329 | v.beginVisit(*this); | ||
1319 | 330 | |||
1320 | 331 | std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); | ||
1321 | 332 | std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); | ||
1322 | 333 | for ( ; lIter != lEnd; ++lIter ){ | ||
1323 | 334 | (*lIter)->accept(v); | ||
1324 | 335 | } | ||
1325 | 336 | |||
1326 | 337 | v.endVisit(*this); | ||
1327 | 338 | } | ||
1328 | 339 | |||
1329 | 340 | MapIsTransientIterator::~MapIsTransientIterator() {} | ||
1330 | 341 | |||
1331 | 342 | // </MapIsTransientIterator> | ||
1332 | 343 | |||
1333 | 344 | |||
1334 | 289 | 345 | ||
1335 | 290 | } | 346 | } |
1336 | 291 | 347 | ||
1337 | 292 | 348 | ||
1338 | === modified file 'src/runtime/store/pregenerated/maps.h' | |||
1339 | --- src/runtime/store/pregenerated/maps.h 2012-06-18 10:06:47 +0000 | |||
1340 | +++ src/runtime/store/pregenerated/maps.h 2012-06-23 00:29:20 +0000 | |||
1341 | @@ -29,6 +29,7 @@ | |||
1342 | 29 | 29 | ||
1343 | 30 | 30 | ||
1344 | 31 | #include "runtime/base/narybase.h" | 31 | #include "runtime/base/narybase.h" |
1345 | 32 | #include <vector> | ||
1346 | 32 | #include "store/api/index.h" | 33 | #include "store/api/index.h" |
1347 | 33 | 34 | ||
1348 | 34 | 35 | ||
1349 | @@ -70,6 +71,37 @@ | |||
1350 | 70 | * | 71 | * |
1351 | 71 | * Author: Matthias Brantner | 72 | * Author: Matthias Brantner |
1352 | 72 | */ | 73 | */ |
1353 | 74 | class MapCreateTransientIterator : public NaryBaseIterator<MapCreateTransientIterator, PlanIteratorState> | ||
1354 | 75 | { | ||
1355 | 76 | public: | ||
1356 | 77 | SERIALIZABLE_CLASS(MapCreateTransientIterator); | ||
1357 | 78 | |||
1358 | 79 | SERIALIZABLE_CLASS_CONSTRUCTOR2T(MapCreateTransientIterator, | ||
1359 | 80 | NaryBaseIterator<MapCreateTransientIterator, PlanIteratorState>); | ||
1360 | 81 | |||
1361 | 82 | void serialize( ::zorba::serialization::Archiver& ar); | ||
1362 | 83 | |||
1363 | 84 | MapCreateTransientIterator( | ||
1364 | 85 | static_context* sctx, | ||
1365 | 86 | const QueryLoc& loc, | ||
1366 | 87 | std::vector<PlanIter_t>& children) | ||
1367 | 88 | : | ||
1368 | 89 | NaryBaseIterator<MapCreateTransientIterator, PlanIteratorState>(sctx, loc, children) | ||
1369 | 90 | {} | ||
1370 | 91 | |||
1371 | 92 | virtual ~MapCreateTransientIterator(); | ||
1372 | 93 | |||
1373 | 94 | void accept(PlanIterVisitor& v) const; | ||
1374 | 95 | |||
1375 | 96 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; | ||
1376 | 97 | }; | ||
1377 | 98 | |||
1378 | 99 | |||
1379 | 100 | /** | ||
1380 | 101 | * | ||
1381 | 102 | * | ||
1382 | 103 | * Author: Matthias Brantner | ||
1383 | 104 | */ | ||
1384 | 73 | class MapDestroyIterator : public NaryBaseIterator<MapDestroyIterator, PlanIteratorState> | 105 | class MapDestroyIterator : public NaryBaseIterator<MapDestroyIterator, PlanIteratorState> |
1385 | 74 | { | 106 | { |
1386 | 75 | public: | 107 | public: |
1387 | @@ -289,7 +321,9 @@ | |||
1388 | 289 | class AvailableMapsIteratorState : public PlanIteratorState | 321 | class AvailableMapsIteratorState : public PlanIteratorState |
1389 | 290 | { | 322 | { |
1390 | 291 | public: | 323 | public: |
1392 | 292 | store::Iterator_t nameItState; //the current iterator | 324 | store::Iterator_t persistentMapNamesIter; //the current iterator |
1393 | 325 | std::vector<store::Item_t> transientMapNames; //all the transient map names | ||
1394 | 326 | std::vector<store::Item_t>::const_iterator transientMapNamesIter; //the current iterator | ||
1395 | 293 | 327 | ||
1396 | 294 | AvailableMapsIteratorState(); | 328 | AvailableMapsIteratorState(); |
1397 | 295 | 329 | ||
1398 | @@ -325,6 +359,37 @@ | |||
1399 | 325 | }; | 359 | }; |
1400 | 326 | 360 | ||
1401 | 327 | 361 | ||
1402 | 362 | /** | ||
1403 | 363 | * | ||
1404 | 364 | * | ||
1405 | 365 | * Author: Matthias Brantner | ||
1406 | 366 | */ | ||
1407 | 367 | class MapIsTransientIterator : public NaryBaseIterator<MapIsTransientIterator, PlanIteratorState> | ||
1408 | 368 | { | ||
1409 | 369 | public: | ||
1410 | 370 | SERIALIZABLE_CLASS(MapIsTransientIterator); | ||
1411 | 371 | |||
1412 | 372 | SERIALIZABLE_CLASS_CONSTRUCTOR2T(MapIsTransientIterator, | ||
1413 | 373 | NaryBaseIterator<MapIsTransientIterator, PlanIteratorState>); | ||
1414 | 374 | |||
1415 | 375 | void serialize( ::zorba::serialization::Archiver& ar); | ||
1416 | 376 | |||
1417 | 377 | MapIsTransientIterator( | ||
1418 | 378 | static_context* sctx, | ||
1419 | 379 | const QueryLoc& loc, | ||
1420 | 380 | std::vector<PlanIter_t>& children) | ||
1421 | 381 | : | ||
1422 | 382 | NaryBaseIterator<MapIsTransientIterator, PlanIteratorState>(sctx, loc, children) | ||
1423 | 383 | {} | ||
1424 | 384 | |||
1425 | 385 | virtual ~MapIsTransientIterator(); | ||
1426 | 386 | |||
1427 | 387 | void accept(PlanIterVisitor& v) const; | ||
1428 | 388 | |||
1429 | 389 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; | ||
1430 | 390 | }; | ||
1431 | 391 | |||
1432 | 392 | |||
1433 | 328 | } | 393 | } |
1434 | 329 | #endif | 394 | #endif |
1435 | 330 | /* | 395 | /* |
1436 | 331 | 396 | ||
1437 | === modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h' | |||
1438 | --- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-06-18 10:06:47 +0000 | |||
1439 | +++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-06-23 00:29:20 +0000 | |||
1440 | @@ -621,6 +621,8 @@ | |||
1441 | 621 | 621 | ||
1442 | 622 | class MapCreateIterator; | 622 | class MapCreateIterator; |
1443 | 623 | 623 | ||
1444 | 624 | class MapCreateTransientIterator; | ||
1445 | 625 | |||
1446 | 624 | class MapDestroyIterator; | 626 | class MapDestroyIterator; |
1447 | 625 | 627 | ||
1448 | 626 | class MapGetIterator; | 628 | class MapGetIterator; |
1449 | @@ -635,6 +637,8 @@ | |||
1450 | 635 | 637 | ||
1451 | 636 | class AvailableMapsIterator; | 638 | class AvailableMapsIterator; |
1452 | 637 | 639 | ||
1453 | 640 | class MapIsTransientIterator; | ||
1454 | 641 | |||
1455 | 638 | class CodepointsToStringIterator; | 642 | class CodepointsToStringIterator; |
1456 | 639 | 643 | ||
1457 | 640 | class StringToCodepointsIterator; | 644 | class StringToCodepointsIterator; |
1458 | @@ -1580,6 +1584,9 @@ | |||
1459 | 1580 | virtual void beginVisit ( const MapCreateIterator& ) = 0; | 1584 | virtual void beginVisit ( const MapCreateIterator& ) = 0; |
1460 | 1581 | virtual void endVisit ( const MapCreateIterator& ) = 0; | 1585 | virtual void endVisit ( const MapCreateIterator& ) = 0; |
1461 | 1582 | 1586 | ||
1462 | 1587 | virtual void beginVisit ( const MapCreateTransientIterator& ) = 0; | ||
1463 | 1588 | virtual void endVisit ( const MapCreateTransientIterator& ) = 0; | ||
1464 | 1589 | |||
1465 | 1583 | virtual void beginVisit ( const MapDestroyIterator& ) = 0; | 1590 | virtual void beginVisit ( const MapDestroyIterator& ) = 0; |
1466 | 1584 | virtual void endVisit ( const MapDestroyIterator& ) = 0; | 1591 | virtual void endVisit ( const MapDestroyIterator& ) = 0; |
1467 | 1585 | 1592 | ||
1468 | @@ -1601,6 +1608,9 @@ | |||
1469 | 1601 | virtual void beginVisit ( const AvailableMapsIterator& ) = 0; | 1608 | virtual void beginVisit ( const AvailableMapsIterator& ) = 0; |
1470 | 1602 | virtual void endVisit ( const AvailableMapsIterator& ) = 0; | 1609 | virtual void endVisit ( const AvailableMapsIterator& ) = 0; |
1471 | 1603 | 1610 | ||
1472 | 1611 | virtual void beginVisit ( const MapIsTransientIterator& ) = 0; | ||
1473 | 1612 | virtual void endVisit ( const MapIsTransientIterator& ) = 0; | ||
1474 | 1613 | |||
1475 | 1604 | virtual void beginVisit ( const CodepointsToStringIterator& ) = 0; | 1614 | virtual void beginVisit ( const CodepointsToStringIterator& ) = 0; |
1476 | 1605 | virtual void endVisit ( const CodepointsToStringIterator& ) = 0; | 1615 | virtual void endVisit ( const CodepointsToStringIterator& ) = 0; |
1477 | 1606 | 1616 | ||
1478 | 1607 | 1617 | ||
1479 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' | |||
1480 | --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-06-18 10:06:47 +0000 | |||
1481 | +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-06-23 00:29:20 +0000 | |||
1482 | @@ -4064,6 +4064,20 @@ | |||
1483 | 4064 | // </MapCreateIterator> | 4064 | // </MapCreateIterator> |
1484 | 4065 | 4065 | ||
1485 | 4066 | 4066 | ||
1486 | 4067 | // <MapCreateTransientIterator> | ||
1487 | 4068 | void PrinterVisitor::beginVisit ( const MapCreateTransientIterator& a) { | ||
1488 | 4069 | thePrinter.startBeginVisit("MapCreateTransientIterator", ++theId); | ||
1489 | 4070 | printCommons( &a, theId ); | ||
1490 | 4071 | thePrinter.endBeginVisit( theId ); | ||
1491 | 4072 | } | ||
1492 | 4073 | |||
1493 | 4074 | void PrinterVisitor::endVisit ( const MapCreateTransientIterator& ) { | ||
1494 | 4075 | thePrinter.startEndVisit(); | ||
1495 | 4076 | thePrinter.endEndVisit(); | ||
1496 | 4077 | } | ||
1497 | 4078 | // </MapCreateTransientIterator> | ||
1498 | 4079 | |||
1499 | 4080 | |||
1500 | 4067 | // <MapDestroyIterator> | 4081 | // <MapDestroyIterator> |
1501 | 4068 | void PrinterVisitor::beginVisit ( const MapDestroyIterator& a) { | 4082 | void PrinterVisitor::beginVisit ( const MapDestroyIterator& a) { |
1502 | 4069 | thePrinter.startBeginVisit("MapDestroyIterator", ++theId); | 4083 | thePrinter.startBeginVisit("MapDestroyIterator", ++theId); |
1503 | @@ -4162,6 +4176,20 @@ | |||
1504 | 4162 | // </AvailableMapsIterator> | 4176 | // </AvailableMapsIterator> |
1505 | 4163 | 4177 | ||
1506 | 4164 | 4178 | ||
1507 | 4179 | // <MapIsTransientIterator> | ||
1508 | 4180 | void PrinterVisitor::beginVisit ( const MapIsTransientIterator& a) { | ||
1509 | 4181 | thePrinter.startBeginVisit("MapIsTransientIterator", ++theId); | ||
1510 | 4182 | printCommons( &a, theId ); | ||
1511 | 4183 | thePrinter.endBeginVisit( theId ); | ||
1512 | 4184 | } | ||
1513 | 4185 | |||
1514 | 4186 | void PrinterVisitor::endVisit ( const MapIsTransientIterator& ) { | ||
1515 | 4187 | thePrinter.startEndVisit(); | ||
1516 | 4188 | thePrinter.endEndVisit(); | ||
1517 | 4189 | } | ||
1518 | 4190 | // </MapIsTransientIterator> | ||
1519 | 4191 | |||
1520 | 4192 | |||
1521 | 4165 | // <CodepointsToStringIterator> | 4193 | // <CodepointsToStringIterator> |
1522 | 4166 | void PrinterVisitor::beginVisit ( const CodepointsToStringIterator& a) { | 4194 | void PrinterVisitor::beginVisit ( const CodepointsToStringIterator& a) { |
1523 | 4167 | thePrinter.startBeginVisit("CodepointsToStringIterator", ++theId); | 4195 | thePrinter.startBeginVisit("CodepointsToStringIterator", ++theId); |
1524 | 4168 | 4196 | ||
1525 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.h' | |||
1526 | --- src/runtime/visitors/pregenerated/printer_visitor.h 2012-06-18 10:06:47 +0000 | |||
1527 | +++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-06-23 00:29:20 +0000 | |||
1528 | @@ -949,6 +949,9 @@ | |||
1529 | 949 | void beginVisit( const MapCreateIterator& ); | 949 | void beginVisit( const MapCreateIterator& ); |
1530 | 950 | void endVisit ( const MapCreateIterator& ); | 950 | void endVisit ( const MapCreateIterator& ); |
1531 | 951 | 951 | ||
1532 | 952 | void beginVisit( const MapCreateTransientIterator& ); | ||
1533 | 953 | void endVisit ( const MapCreateTransientIterator& ); | ||
1534 | 954 | |||
1535 | 952 | void beginVisit( const MapDestroyIterator& ); | 955 | void beginVisit( const MapDestroyIterator& ); |
1536 | 953 | void endVisit ( const MapDestroyIterator& ); | 956 | void endVisit ( const MapDestroyIterator& ); |
1537 | 954 | 957 | ||
1538 | @@ -970,6 +973,9 @@ | |||
1539 | 970 | void beginVisit( const AvailableMapsIterator& ); | 973 | void beginVisit( const AvailableMapsIterator& ); |
1540 | 971 | void endVisit ( const AvailableMapsIterator& ); | 974 | void endVisit ( const AvailableMapsIterator& ); |
1541 | 972 | 975 | ||
1542 | 976 | void beginVisit( const MapIsTransientIterator& ); | ||
1543 | 977 | void endVisit ( const MapIsTransientIterator& ); | ||
1544 | 978 | |||
1545 | 973 | void beginVisit( const CodepointsToStringIterator& ); | 979 | void beginVisit( const CodepointsToStringIterator& ); |
1546 | 974 | void endVisit ( const CodepointsToStringIterator& ); | 980 | void endVisit ( const CodepointsToStringIterator& ); |
1547 | 975 | 981 | ||
1548 | 976 | 982 | ||
1549 | === modified file 'src/store/api/index.h' | |||
1550 | --- src/store/api/index.h 2012-06-18 10:06:47 +0000 | |||
1551 | +++ src/store/api/index.h 2012-06-23 00:29:20 +0000 | |||
1552 | @@ -427,6 +427,11 @@ | |||
1553 | 427 | * a general index | 427 | * a general index |
1554 | 428 | */ | 428 | */ |
1555 | 429 | virtual bool insert(store::IndexKey*& key, store::Item_t& item) = 0; | 429 | virtual bool insert(store::IndexKey*& key, store::Item_t& item) = 0; |
1556 | 430 | |||
1557 | 431 | virtual bool remove( | ||
1558 | 432 | const store::IndexKey* key, | ||
1559 | 433 | const store::Item_t& item, | ||
1560 | 434 | bool all = false) = 0; | ||
1561 | 430 | }; | 435 | }; |
1562 | 431 | 436 | ||
1563 | 432 | 437 | ||
1564 | 433 | 438 | ||
1565 | === modified file 'src/store/api/store.h' | |||
1566 | --- src/store/api/store.h 2012-06-18 10:06:47 +0000 | |||
1567 | +++ src/store/api/store.h 2012-06-23 00:29:20 +0000 | |||
1568 | @@ -320,6 +320,10 @@ | |||
1569 | 320 | 320 | ||
1570 | 321 | /* --------------------------- Map Management ------------------------------*/ | 321 | /* --------------------------- Map Management ------------------------------*/ |
1571 | 322 | 322 | ||
1572 | 323 | virtual Index_t createMap( | ||
1573 | 324 | const Item_t& qname, | ||
1574 | 325 | const IndexSpecification& spec) = 0; | ||
1575 | 326 | |||
1576 | 323 | virtual Index* getMap(const Item* aQName) const = 0; | 327 | virtual Index* getMap(const Item* aQName) const = 0; |
1577 | 324 | 328 | ||
1578 | 325 | virtual Iterator_t listMapNames() = 0; | 329 | virtual Iterator_t listMapNames() = 0; |
1579 | 326 | 330 | ||
1580 | === modified file 'src/store/naive/pul_primitives.cpp' | |||
1581 | --- src/store/naive/pul_primitives.cpp 2012-06-18 10:06:47 +0000 | |||
1582 | +++ src/store/naive/pul_primitives.cpp 2012-06-23 00:29:20 +0000 | |||
1583 | @@ -1734,7 +1734,7 @@ | |||
1584 | 1734 | lSpec.theTimezone = theTimezone; | 1734 | lSpec.theTimezone = theTimezone; |
1585 | 1735 | 1735 | ||
1586 | 1736 | 1736 | ||
1588 | 1737 | GET_STORE().createHashMap(theQName, lSpec); | 1737 | GET_STORE().createMap(theQName, lSpec); |
1589 | 1738 | theIsApplied = true; | 1738 | theIsApplied = true; |
1590 | 1739 | } | 1739 | } |
1591 | 1740 | 1740 | ||
1592 | @@ -1743,7 +1743,7 @@ | |||
1593 | 1743 | { | 1743 | { |
1594 | 1744 | if (theIsApplied) | 1744 | if (theIsApplied) |
1595 | 1745 | { | 1745 | { |
1597 | 1746 | GET_STORE().destroyHashMap(theQName); | 1746 | GET_STORE().destroyMap(theQName); |
1598 | 1747 | } | 1747 | } |
1599 | 1748 | } | 1748 | } |
1600 | 1749 | 1749 | ||
1601 | @@ -1763,7 +1763,7 @@ | |||
1602 | 1763 | 1763 | ||
1603 | 1764 | void UpdDestroyHashMap::apply() | 1764 | void UpdDestroyHashMap::apply() |
1604 | 1765 | { | 1765 | { |
1606 | 1766 | theMap = GET_STORE().destroyHashMap(theQName); | 1766 | theMap = GET_STORE().destroyMap(theQName); |
1607 | 1767 | theIsApplied = true; | 1767 | theIsApplied = true; |
1608 | 1768 | } | 1768 | } |
1609 | 1769 | 1769 | ||
1610 | @@ -1772,7 +1772,7 @@ | |||
1611 | 1772 | { | 1772 | { |
1612 | 1773 | if (theIsApplied) | 1773 | if (theIsApplied) |
1613 | 1774 | { | 1774 | { |
1615 | 1775 | GET_STORE().addHashMap(theMap); | 1775 | GET_STORE().addMap(theMap); |
1616 | 1776 | } | 1776 | } |
1617 | 1777 | } | 1777 | } |
1618 | 1778 | 1778 | ||
1619 | @@ -1796,7 +1796,7 @@ | |||
1620 | 1796 | 1796 | ||
1621 | 1797 | void UpdInsertIntoHashMap::apply() | 1797 | void UpdInsertIntoHashMap::apply() |
1622 | 1798 | { | 1798 | { |
1624 | 1799 | store::Index_t lMap = GET_STORE().getHashMap(theQName); | 1799 | store::Index_t lMap = GET_STORE().getMap(theQName); |
1625 | 1800 | 1800 | ||
1626 | 1801 | if (!lMap) | 1801 | if (!lMap) |
1627 | 1802 | { | 1802 | { |
1628 | @@ -1809,7 +1809,6 @@ | |||
1629 | 1809 | theValue->open(); | 1809 | theValue->open(); |
1630 | 1810 | store::Item_t lValue; | 1810 | store::Item_t lValue; |
1631 | 1811 | 1811 | ||
1632 | 1812 | store::IndexKey lKeyPtr; | ||
1633 | 1813 | while (theValue->next(lValue)) | 1812 | while (theValue->next(lValue)) |
1634 | 1814 | { | 1813 | { |
1635 | 1815 | std::auto_ptr<store::IndexKey> lKey(new store::IndexKey()); | 1814 | std::auto_ptr<store::IndexKey> lKey(new store::IndexKey()); |
1636 | @@ -1853,7 +1852,7 @@ | |||
1637 | 1853 | 1852 | ||
1638 | 1854 | void UpdRemoveFromHashMap::apply() | 1853 | void UpdRemoveFromHashMap::apply() |
1639 | 1855 | { | 1854 | { |
1641 | 1856 | store::Index_t lMap = GET_STORE().getHashMap(theQName); | 1855 | store::Index_t lMap = GET_STORE().getMap(theQName); |
1642 | 1857 | 1856 | ||
1643 | 1858 | if (!lMap) | 1857 | if (!lMap) |
1644 | 1859 | { | 1858 | { |
1645 | 1860 | 1859 | ||
1646 | === modified file 'src/store/naive/simple_index_general.cpp' | |||
1647 | --- src/store/naive/simple_index_general.cpp 2012-06-18 10:06:47 +0000 | |||
1648 | +++ src/store/naive/simple_index_general.cpp 2012-06-23 00:29:20 +0000 | |||
1649 | @@ -747,7 +747,7 @@ | |||
1650 | 747 | *******************************************************************************/ | 747 | *******************************************************************************/ |
1651 | 748 | bool GeneralHashIndex::remove( | 748 | bool GeneralHashIndex::remove( |
1652 | 749 | const store::Item_t& key, | 749 | const store::Item_t& key, |
1654 | 750 | store::Item_t& item, | 750 | const store::Item_t& item, |
1655 | 751 | bool all) | 751 | bool all) |
1656 | 752 | { | 752 | { |
1657 | 753 | assert(false); | 753 | assert(false); |
1658 | @@ -922,7 +922,7 @@ | |||
1659 | 922 | *******************************************************************************/ | 922 | *******************************************************************************/ |
1660 | 923 | bool GeneralTreeIndex::remove( | 923 | bool GeneralTreeIndex::remove( |
1661 | 924 | const store::Item_t& key, | 924 | const store::Item_t& key, |
1663 | 925 | store::Item_t& item, | 925 | const store::Item_t& item, |
1664 | 926 | bool all) | 926 | bool all) |
1665 | 927 | { | 927 | { |
1666 | 928 | return true; | 928 | return true; |
1667 | 929 | 929 | ||
1668 | === modified file 'src/store/naive/simple_index_general.h' | |||
1669 | --- src/store/naive/simple_index_general.h 2012-06-18 10:06:47 +0000 | |||
1670 | +++ src/store/naive/simple_index_general.h 2012-06-23 00:29:20 +0000 | |||
1671 | @@ -176,7 +176,12 @@ | |||
1672 | 176 | 176 | ||
1673 | 177 | bool insert(store::IndexKey*& key, store::Item_t& value); | 177 | bool insert(store::IndexKey*& key, store::Item_t& value); |
1674 | 178 | 178 | ||
1676 | 179 | virtual bool remove(const store::Item_t& key, store::Item_t& item, bool all) = 0; | 179 | virtual bool remove(const store::Item_t& key, const store::Item_t& item, bool all) = 0; |
1677 | 180 | |||
1678 | 181 | virtual bool remove( | ||
1679 | 182 | const store::IndexKey* key, | ||
1680 | 183 | const store::Item_t& item, | ||
1681 | 184 | bool all = false) = 0; | ||
1682 | 180 | }; | 185 | }; |
1683 | 181 | 186 | ||
1684 | 182 | 187 | ||
1685 | @@ -237,7 +242,16 @@ | |||
1686 | 237 | 242 | ||
1687 | 238 | Index::KeyIterator_t keys() const; | 243 | Index::KeyIterator_t keys() const; |
1688 | 239 | 244 | ||
1690 | 240 | bool remove(const store::Item_t& key, store::Item_t& item, bool); | 245 | bool remove(const store::Item_t& key, const store::Item_t& item, bool); |
1691 | 246 | |||
1692 | 247 | bool remove( | ||
1693 | 248 | const store::IndexKey* key, | ||
1694 | 249 | const store::Item_t& item, | ||
1695 | 250 | bool all = false) | ||
1696 | 251 | { | ||
1697 | 252 | assert(key->size() == 1); | ||
1698 | 253 | return remove(((*key)[0]), item, all); | ||
1699 | 254 | } | ||
1700 | 241 | 255 | ||
1701 | 242 | void clear(); | 256 | void clear(); |
1702 | 243 | }; | 257 | }; |
1703 | @@ -292,7 +306,16 @@ | |||
1704 | 292 | 306 | ||
1705 | 293 | Index::KeyIterator_t keys() const; | 307 | Index::KeyIterator_t keys() const; |
1706 | 294 | 308 | ||
1708 | 295 | bool remove(const store::Item_t& key, store::Item_t& item, bool all); | 309 | bool remove(const store::Item_t& key, const store::Item_t& item, bool all); |
1709 | 310 | |||
1710 | 311 | bool remove( | ||
1711 | 312 | const store::IndexKey* key, | ||
1712 | 313 | const store::Item_t& item, | ||
1713 | 314 | bool all = false) | ||
1714 | 315 | { | ||
1715 | 316 | assert(key->size() == 1); | ||
1716 | 317 | return remove(((*key)[0]), item, all); | ||
1717 | 318 | } | ||
1718 | 296 | 319 | ||
1719 | 297 | void clear(); | 320 | void clear(); |
1720 | 298 | }; | 321 | }; |
1721 | 299 | 322 | ||
1722 | === modified file 'src/store/naive/store.cpp' | |||
1723 | --- src/store/naive/store.cpp 2012-06-22 08:19:01 +0000 | |||
1724 | +++ src/store/naive/store.cpp 2012-06-23 00:29:20 +0000 | |||
1725 | @@ -889,7 +889,7 @@ | |||
1726 | 889 | 889 | ||
1727 | 890 | ********************************************************************************/ | 890 | ********************************************************************************/ |
1728 | 891 | store::Index_t | 891 | store::Index_t |
1730 | 892 | Store::createHashMap( | 892 | Store::createMap( |
1731 | 893 | const store::Item_t& aQName, | 893 | const store::Item_t& aQName, |
1732 | 894 | const store::IndexSpecification& aSpec) | 894 | const store::IndexSpecification& aSpec) |
1733 | 895 | { | 895 | { |
1734 | @@ -905,7 +905,7 @@ | |||
1735 | 905 | 905 | ||
1736 | 906 | lIndex = new ValueHashIndex(aQName, aSpec); | 906 | lIndex = new ValueHashIndex(aQName, aSpec); |
1737 | 907 | 907 | ||
1739 | 908 | addHashMap(lIndex); | 908 | if (!aSpec.theIsTemp) addMap(lIndex); |
1740 | 909 | 909 | ||
1741 | 910 | return lIndex; | 910 | return lIndex; |
1742 | 911 | } | 911 | } |
1743 | @@ -915,7 +915,7 @@ | |||
1744 | 915 | 915 | ||
1745 | 916 | ********************************************************************************/ | 916 | ********************************************************************************/ |
1746 | 917 | store::Index_t | 917 | store::Index_t |
1748 | 918 | Store::destroyHashMap(const store::Item_t& aQName) | 918 | Store::destroyMap(const store::Item_t& aQName) |
1749 | 919 | { | 919 | { |
1750 | 920 | store::Index_t lIndex; | 920 | store::Index_t lIndex; |
1751 | 921 | if (!theHashMaps.get(aQName.getp(), lIndex)) | 921 | if (!theHashMaps.get(aQName.getp(), lIndex)) |
1752 | @@ -950,7 +950,7 @@ | |||
1753 | 950 | 950 | ||
1754 | 951 | ********************************************************************************/ | 951 | ********************************************************************************/ |
1755 | 952 | store::Index_t | 952 | store::Index_t |
1757 | 953 | Store::getHashMap(const store::Item_t& aQName) const | 953 | Store::getMap(const store::Item_t& aQName) const |
1758 | 954 | { | 954 | { |
1759 | 955 | store::Index_t lIndex; | 955 | store::Index_t lIndex; |
1760 | 956 | if (const_cast<IndexSet*>(&theHashMaps)->get(aQName.getp(), lIndex)) | 956 | if (const_cast<IndexSet*>(&theHashMaps)->get(aQName.getp(), lIndex)) |
1761 | @@ -968,7 +968,7 @@ | |||
1762 | 968 | 968 | ||
1763 | 969 | ********************************************************************************/ | 969 | ********************************************************************************/ |
1764 | 970 | void | 970 | void |
1766 | 971 | Store::addHashMap(const store::Index_t& aIndex) | 971 | Store::addMap(const store::Index_t& aIndex) |
1767 | 972 | { | 972 | { |
1768 | 973 | store::Item* lName = aIndex->getName(); | 973 | store::Item* lName = aIndex->getName(); |
1769 | 974 | store::Index_t lIndex = aIndex; | 974 | store::Index_t lIndex = aIndex; |
1770 | 975 | 975 | ||
1771 | === modified file 'src/store/naive/store.h' | |||
1772 | --- src/store/naive/store.h 2012-06-18 10:06:47 +0000 | |||
1773 | +++ src/store/naive/store.h 2012-06-23 00:29:20 +0000 | |||
1774 | @@ -342,17 +342,17 @@ | |||
1775 | 342 | 342 | ||
1776 | 343 | /*------------------------------------- Maps ---------------------------------*/ | 343 | /*------------------------------------- Maps ---------------------------------*/ |
1777 | 344 | public: | 344 | public: |
1779 | 345 | virtual store::Index_t createHashMap( | 345 | virtual store::Index_t createMap( |
1780 | 346 | const store::Item_t& aQName, | 346 | const store::Item_t& aQName, |
1781 | 347 | const store::IndexSpecification& aSpec); | 347 | const store::IndexSpecification& aSpec); |
1782 | 348 | 348 | ||
1784 | 349 | virtual store::Index_t destroyHashMap(const store::Item_t& aQName); | 349 | virtual store::Index_t destroyMap(const store::Item_t& aQName); |
1785 | 350 | 350 | ||
1786 | 351 | virtual store::Index* getMap(const store::Item* aQName) const; | 351 | virtual store::Index* getMap(const store::Item* aQName) const; |
1787 | 352 | 352 | ||
1789 | 353 | virtual store::Index_t getHashMap(const store::Item_t& aQName) const; | 353 | virtual store::Index_t getMap(const store::Item_t& aQName) const; |
1790 | 354 | 354 | ||
1792 | 355 | virtual void addHashMap(const store::Index_t& aMap); | 355 | virtual void addMap(const store::Index_t& aMap); |
1793 | 356 | 356 | ||
1794 | 357 | virtual store::Iterator_t listMapNames(); | 357 | virtual store::Iterator_t listMapNames(); |
1795 | 358 | 358 | ||
1796 | 359 | 359 | ||
1797 | === added file 'test/rbkt/ExpQueryResults/zorba/store/unordered-map/map7.xml.res' | |||
1798 | --- test/rbkt/ExpQueryResults/zorba/store/unordered-map/map7.xml.res 1970-01-01 00:00:00 +0000 | |||
1799 | +++ test/rbkt/ExpQueryResults/zorba/store/unordered-map/map7.xml.res 2012-06-23 00:29:20 +0000 | |||
1800 | @@ -0,0 +1,1 @@ | |||
1801 | 1 | true true 1 key1 value1 true false 3 true true 5 key5 value5 false true key2 false true key4 false false | ||
1802 | 0 | 2 | ||
1803 | === added file 'test/rbkt/ExpQueryResults/zorba/store/unordered-map/transient-map0.xml.res' | |||
1804 | --- test/rbkt/ExpQueryResults/zorba/store/unordered-map/transient-map0.xml.res 1970-01-01 00:00:00 +0000 | |||
1805 | +++ test/rbkt/ExpQueryResults/zorba/store/unordered-map/transient-map0.xml.res 2012-06-23 00:29:20 +0000 | |||
1806 | @@ -0,0 +1,1 @@ | |||
1807 | 1 | <avail>first</avail><contains>value5</contains><contains></contains><avail></avail> | ||
1808 | 0 | \ No newline at end of file | 2 | \ No newline at end of file |
1809 | 1 | 3 | ||
1810 | === added file 'test/rbkt/Queries/zorba/store/unordered-map/map7.xq' | |||
1811 | --- test/rbkt/Queries/zorba/store/unordered-map/map7.xq 1970-01-01 00:00:00 +0000 | |||
1812 | +++ test/rbkt/Queries/zorba/store/unordered-map/map7.xq 2012-06-23 00:29:20 +0000 | |||
1813 | @@ -0,0 +1,22 @@ | |||
1814 | 1 | import module namespace map = "http://www.zorba-xquery.com/modules/store/data-structures/unordered-map"; | ||
1815 | 2 | |||
1816 | 3 | variable $name := fn:QName("http://www.zorba-xquery.com/map", "first"); | ||
1817 | 4 | variable $xs-integer := fn:QName("http://www.w3.org/2001/XMLSchema", "xs:integer"); | ||
1818 | 5 | variable $xs-string := fn:QName("http://www.w3.org/2001/XMLSchema", "xs:string"); | ||
1819 | 6 | |||
1820 | 7 | map:create($name, $xs-integer, $xs-string); | ||
1821 | 8 | |||
1822 | 9 | for $i in 1 to 6 | ||
1823 | 10 | let $value := concat("value", $i), | ||
1824 | 11 | $key1 := if ($i mod 2 ne 0) then $i else (), | ||
1825 | 12 | $key2 := if ($i mod 3 ne 0) then concat("key", $i) else () | ||
1826 | 13 | return | ||
1827 | 14 | map:insert($name, $value, $key1, $key2); | ||
1828 | 15 | |||
1829 | 16 | for $k in map:keys($name) | ||
1830 | 17 | let $key1 := data($k/map:attribute[1]/@value), | ||
1831 | 18 | $key2 := data($k/map:attribute[2]/@value) | ||
1832 | 19 | order by $key1, $key2 | ||
1833 | 20 | return | ||
1834 | 21 | ($key1 instance of xs:integer, $key2 instance of xs:string, | ||
1835 | 22 | $key1, $key2, map:get($name, $key1, $key2)) | ||
1836 | 0 | 23 | ||
1837 | === added file 'test/rbkt/Queries/zorba/store/unordered-map/transient-map0.xq' | |||
1838 | --- test/rbkt/Queries/zorba/store/unordered-map/transient-map0.xq 1970-01-01 00:00:00 +0000 | |||
1839 | +++ test/rbkt/Queries/zorba/store/unordered-map/transient-map0.xq 2012-06-23 00:29:20 +0000 | |||
1840 | @@ -0,0 +1,27 @@ | |||
1841 | 1 | import module namespace map = "http://www.zorba-xquery.com/modules/store/data-structures/unordered-map"; | ||
1842 | 2 | |||
1843 | 3 | |||
1844 | 4 | let $name := fn:QName("http://www.zorba-xquery.com/map", "first") | ||
1845 | 5 | let $type := fn:QName("http://www.w3.org/2001/XMLSchema", "xs:integer") | ||
1846 | 6 | return | ||
1847 | 7 | { | ||
1848 | 8 | map:create-transient($name, $type); | ||
1849 | 9 | |||
1850 | 10 | ( | ||
1851 | 11 | for $i in 1 to 1000 | ||
1852 | 12 | return map:insert($name, concat("value", $i), $i) | ||
1853 | 13 | ); | ||
1854 | 14 | |||
1855 | 15 | variable $res := <avail>{ map:available-maps() }</avail>; | ||
1856 | 16 | |||
1857 | 17 | $res := ($res, <contains>{ map:get($name, 5) }</contains>); | ||
1858 | 18 | |||
1859 | 19 | map:remove($name, 5); | ||
1860 | 20 | |||
1861 | 21 | $res := ($res, <contains>{ map:get($name, 5) }</contains>); | ||
1862 | 22 | |||
1863 | 23 | map:delete($name); | ||
1864 | 24 | |||
1865 | 25 | ($res, <avail>{ map:available-maps() }</avail>) | ||
1866 | 26 | } | ||
1867 | 27 |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ feature- transient_ maps-2012- 05-18T00- 03-10.458Z/ log.html
Log at: http://