Merge lp:~zorba-coders/zorba/bug900677 into lp:zorba
- bug900677
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~zorba-coders/zorba/bug900677 | ||||
Merge into: | lp:zorba | ||||
Diff against target: |
970 lines (+702/-42) 22 files modified
ChangeLog (+2/-0) modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq (+25/-0) src/functions/library.cpp (+2/-0) src/functions/pregenerated/func_index_func.cpp (+63/-0) src/functions/pregenerated/func_index_func.h (+66/-0) src/functions/pregenerated/function_enum.h (+1/-0) src/runtime/indexing/index_func_impl.cpp (+103/-0) src/runtime/indexing/index_util.h (+95/-0) src/runtime/indexing/pregenerated/index_func.cpp (+79/-0) src/runtime/indexing/pregenerated/index_func.h (+97/-0) src/runtime/spec/indexing/index_func.xml (+55/-0) src/runtime/store/maps_impl.cpp (+4/-35) src/runtime/visitors/pregenerated/planiter_visitor.h (+5/-0) src/runtime/visitors/pregenerated/printer_visitor.cpp (+15/-0) src/runtime/visitors/pregenerated/printer_visitor.h (+3/-0) src/store/naive/simple_index_value.cpp (+21/-7) src/store/naive/simple_index_value.h (+5/-0) test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res (+1/-0) test/rbkt/Queries/zorba/index/keys1.xq (+22/-0) test/rbkt/Queries/zorba/index/keys2.xq (+22/-0) test/rbkt/Queries/zorba/index/keys_mod.xqlib (+15/-0) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug900677 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Pending | ||
William Candillon | Pending | ||
Review via email: mp+88972@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-01-18.
Commit message
Added a keys() function to the index dml module. This fixes bug #900677.
Description of the change
Added a keys() function to the index dml module. This fixes bug #900677.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug900677 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug900677-2012-01-
final status was:
No tests were run - build or configure step must have failed.
Not commiting changes.
Error in read script: /home/ceej/
- 10622. By Matthias Brantner
-
Fixed a bug when a key attribute in an index is the empty sequence. Also, improved the
documentation for the idml:keys function. - 10623. By Matthias Brantner
-
merge
- 10624. By David Graf
-
merged trunk
- 10625. By David Graf
-
regenerated stuff
- 10626. By David Graf
-
fixed merge bug
- 10627. By David Graf
-
commit of work in progress - keys function for general indices does work. Cleanup and more tests needed.
- 10628. By David Graf
-
index-keys function test for general index
- 10629. By David Graf
-
added some comments
- 10630. By Matthias Brantner
-
merge with trunk
- 10631. By Matthias Brantner
-
minor cleanup
- 10632. By David Graf
-
merged trunk
- 10633. By David Graf
-
merged trunk
- 10634. By David Graf
-
merged trunk
- 10635. By David Graf
-
fixed segfault
Unmerged revisions
Preview Diff
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2012-01-11 17:30:25 +0000 | |||
3 | +++ ChangeLog 2012-01-18 01:11:25 +0000 | |||
4 | @@ -21,6 +21,8 @@ | |||
5 | 21 | support. | 21 | support. |
6 | 22 | * zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors | 22 | * zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors |
7 | 23 | * Added API method Item::getNamespaceBindings(). | 23 | * Added API method Item::getNamespaceBindings(). |
8 | 24 | * Added a function to the http://www.zorba-xquery.com/modules/store/static/indexes/dml module which returns | ||
9 | 25 | the value of all keys contained in an index. | ||
10 | 24 | 26 | ||
11 | 25 | version 2.1 | 27 | version 2.1 |
12 | 26 | 28 | ||
13 | 27 | 29 | ||
14 | === modified file 'modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq' | |||
15 | --- modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2011-11-01 15:59:24 +0000 | |||
16 | +++ modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2012-01-18 01:11:25 +0000 | |||
17 | @@ -268,3 +268,28 @@ | |||
18 | 268 | :) | 268 | :) |
19 | 269 | declare updating function idml:refresh-index($name as xs:QName) external; | 269 | declare updating function idml:refresh-index($name as xs:QName) external; |
20 | 270 | 270 | ||
21 | 271 | (:~ | ||
22 | 272 | : The keys function returns a sequence of all keys contained in the | ||
23 | 273 | : index with the given name. | ||
24 | 274 | : | ||
25 | 275 | : @param $name The QName of the index | ||
26 | 276 | : @return The result of the function is sequence of elements each representing | ||
27 | 277 | : one key contained in the index. Each element has the following | ||
28 | 278 | : structure: | ||
29 | 279 | : <pre> | ||
30 | 280 | : <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"> | ||
31 | 281 | : <attribute value="key1_value"/> | ||
32 | 282 | : <attribute value="key2_value"/> | ||
33 | 283 | : <attribute value="key3_value"/> | ||
34 | 284 | : </key> | ||
35 | 285 | : </pre> | ||
36 | 286 | : | ||
37 | 287 | : Note that the order of the attribute elements reflects the order of | ||
38 | 288 | : the keys in the index specification. Also note that the values in | ||
39 | 289 | : these attributes have the type that is declared in the corresponding | ||
40 | 290 | : index specification. | ||
41 | 291 | : | ||
42 | 292 | : @error zerr:ZDDY0021 if the index with name $name is not declared. | ||
43 | 293 | : @error zerr:ZDDY0023 if the index with name $name does not exist. | ||
44 | 294 | :) | ||
45 | 295 | declare function idml:keys($name as xs:QName) as node()* external; | ||
46 | 271 | 296 | ||
47 | === modified file 'src/functions/library.cpp' | |||
48 | --- src/functions/library.cpp 2011-10-14 07:35:51 +0000 | |||
49 | +++ src/functions/library.cpp 2012-01-18 01:11:25 +0000 | |||
50 | @@ -41,6 +41,7 @@ | |||
51 | 41 | #include "functions/func_fnput.h" | 41 | #include "functions/func_fnput.h" |
52 | 42 | #include "functions/func_hoist.h" | 42 | #include "functions/func_hoist.h" |
53 | 43 | #include "functions/func_index_ddl.h" | 43 | #include "functions/func_index_ddl.h" |
54 | 44 | #include "functions/func_index_func.h" | ||
55 | 44 | #include "functions/func_ic_ddl.h" | 45 | #include "functions/func_ic_ddl.h" |
56 | 45 | #include "functions/func_maths.h" | 46 | #include "functions/func_maths.h" |
57 | 46 | #include "functions/func_nodes.h" | 47 | #include "functions/func_nodes.h" |
58 | @@ -106,6 +107,7 @@ | |||
59 | 106 | populate_context_errors_and_diagnostics(sctx); | 107 | populate_context_errors_and_diagnostics(sctx); |
60 | 107 | populate_context_fnput(sctx); | 108 | populate_context_fnput(sctx); |
61 | 108 | populate_context_index_ddl(sctx); | 109 | populate_context_index_ddl(sctx); |
62 | 110 | populate_context_index_func(sctx); | ||
63 | 109 | populate_context_ic_ddl(sctx); | 111 | populate_context_ic_ddl(sctx); |
64 | 110 | populate_context_maths(sctx); | 112 | populate_context_maths(sctx); |
65 | 111 | populate_context_nodes(sctx); | 113 | populate_context_nodes(sctx); |
66 | 112 | 114 | ||
67 | === added file 'src/functions/pregenerated/func_index_func.cpp' | |||
68 | --- src/functions/pregenerated/func_index_func.cpp 1970-01-01 00:00:00 +0000 | |||
69 | +++ src/functions/pregenerated/func_index_func.cpp 2012-01-18 01:11:25 +0000 | |||
70 | @@ -0,0 +1,63 @@ | |||
71 | 1 | /* | ||
72 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
73 | 3 | * | ||
74 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
75 | 5 | * you may not use this file except in compliance with the License. | ||
76 | 6 | * You may obtain a copy of the License at | ||
77 | 7 | * | ||
78 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
79 | 9 | * | ||
80 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
81 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
82 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
83 | 13 | * See the License for the specific language governing permissions and | ||
84 | 14 | * limitations under the License. | ||
85 | 15 | */ | ||
86 | 16 | |||
87 | 17 | // ****************************************** | ||
88 | 18 | // * * | ||
89 | 19 | // * THIS IS A GENERATED FILE. DO NOT EDIT! * | ||
90 | 20 | // * SEE .xml FILE WITH SAME NAME * | ||
91 | 21 | // * * | ||
92 | 22 | // ****************************************** | ||
93 | 23 | |||
94 | 24 | |||
95 | 25 | #include "stdafx.h" | ||
96 | 26 | #include "runtime/indexing/index_func.h" | ||
97 | 27 | #include "functions/func_index_func.h" | ||
98 | 28 | |||
99 | 29 | |||
100 | 30 | namespace zorba{ | ||
101 | 31 | |||
102 | 32 | |||
103 | 33 | |||
104 | 34 | PlanIter_t zorba_store_indexes_static_dml_keys::codegen( | ||
105 | 35 | CompilerCB*, | ||
106 | 36 | static_context* sctx, | ||
107 | 37 | const QueryLoc& loc, | ||
108 | 38 | std::vector<PlanIter_t>& argv, | ||
109 | 39 | AnnotationHolder& ann) const | ||
110 | 40 | { | ||
111 | 41 | return new IndexKeysIterator(sctx, loc, argv); | ||
112 | 42 | } | ||
113 | 43 | |||
114 | 44 | void populate_context_index_func(static_context* sctx) | ||
115 | 45 | { | ||
116 | 46 | { | ||
117 | 47 | |||
118 | 48 | |||
119 | 49 | DECL_WITH_KIND(sctx, zorba_store_indexes_static_dml_keys, | ||
120 | 50 | (createQName("http://www.zorba-xquery.com/modules/store/static/indexes/dml","","keys"), | ||
121 | 51 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, | ||
122 | 52 | GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR), | ||
123 | 53 | FunctionConsts::ZORBA_STORE_INDEXES_STATIC_DML_KEYS_1); | ||
124 | 54 | |||
125 | 55 | } | ||
126 | 56 | |||
127 | 57 | } | ||
128 | 58 | |||
129 | 59 | |||
130 | 60 | } | ||
131 | 61 | |||
132 | 62 | |||
133 | 63 | |||
134 | 0 | 64 | ||
135 | === added file 'src/functions/pregenerated/func_index_func.h' | |||
136 | --- src/functions/pregenerated/func_index_func.h 1970-01-01 00:00:00 +0000 | |||
137 | +++ src/functions/pregenerated/func_index_func.h 2012-01-18 01:11:25 +0000 | |||
138 | @@ -0,0 +1,66 @@ | |||
139 | 1 | /* | ||
140 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
141 | 3 | * | ||
142 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
143 | 5 | * you may not use this file except in compliance with the License. | ||
144 | 6 | * You may obtain a copy of the License at | ||
145 | 7 | * | ||
146 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
147 | 9 | * | ||
148 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
149 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
150 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
151 | 13 | * See the License for the specific language governing permissions and | ||
152 | 14 | * limitations under the License. | ||
153 | 15 | */ | ||
154 | 16 | |||
155 | 17 | // ****************************************** | ||
156 | 18 | // * * | ||
157 | 19 | // * THIS IS A GENERATED FILE. DO NOT EDIT! * | ||
158 | 20 | // * SEE .xml FILE WITH SAME NAME * | ||
159 | 21 | // * * | ||
160 | 22 | // ****************************************** | ||
161 | 23 | |||
162 | 24 | |||
163 | 25 | #ifndef ZORBA_FUNCTIONS_INDEX_FUNC_H | ||
164 | 26 | #define ZORBA_FUNCTIONS_INDEX_FUNC_H | ||
165 | 27 | |||
166 | 28 | |||
167 | 29 | #include "common/shared_types.h" | ||
168 | 30 | #include "functions/function_impl.h" | ||
169 | 31 | |||
170 | 32 | |||
171 | 33 | namespace zorba { | ||
172 | 34 | |||
173 | 35 | |||
174 | 36 | void populate_context_index_func(static_context* sctx); | ||
175 | 37 | |||
176 | 38 | |||
177 | 39 | |||
178 | 40 | |||
179 | 41 | //zorba-store-indexes-static-dml:keys | ||
180 | 42 | class zorba_store_indexes_static_dml_keys : public function | ||
181 | 43 | { | ||
182 | 44 | public: | ||
183 | 45 | zorba_store_indexes_static_dml_keys(const signature& sig, FunctionConsts::FunctionKind kind) | ||
184 | 46 | : | ||
185 | 47 | function(sig, kind) | ||
186 | 48 | { | ||
187 | 49 | |||
188 | 50 | } | ||
189 | 51 | |||
190 | 52 | bool accessesDynCtx() const { return true; } | ||
191 | 53 | |||
192 | 54 | CODEGEN_DECL(); | ||
193 | 55 | }; | ||
194 | 56 | |||
195 | 57 | |||
196 | 58 | } //namespace zorba | ||
197 | 59 | |||
198 | 60 | |||
199 | 61 | #endif | ||
200 | 62 | /* | ||
201 | 63 | * Local variables: | ||
202 | 64 | * mode: c++ | ||
203 | 65 | * End: | ||
204 | 66 | */ | ||
205 | 0 | 67 | ||
206 | === modified file 'src/functions/pregenerated/function_enum.h' | |||
207 | --- src/functions/pregenerated/function_enum.h 2012-01-11 17:30:25 +0000 | |||
208 | +++ src/functions/pregenerated/function_enum.h 2012-01-18 01:11:25 +0000 | |||
209 | @@ -141,6 +141,7 @@ | |||
210 | 141 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1, | 141 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1, |
211 | 142 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_DEACTIVATE_1, | 142 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_DEACTIVATE_1, |
212 | 143 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DML_CHECK_INTEGRITY_CONSTRAINT_1, | 143 | ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DML_CHECK_INTEGRITY_CONSTRAINT_1, |
213 | 144 | ZORBA_STORE_INDEXES_STATIC_DML_KEYS_1, | ||
214 | 144 | FN_ZORBA_INTROSPECT_SCTX_STATICALLY_KNOWN_NAMESPACES_0, | 145 | FN_ZORBA_INTROSPECT_SCTX_STATICALLY_KNOWN_NAMESPACES_0, |
215 | 145 | FN_ZORBA_INTROSPECT_SCTX_DEFAULT_FUNCTION_NAMESPACE_0, | 146 | FN_ZORBA_INTROSPECT_SCTX_DEFAULT_FUNCTION_NAMESPACE_0, |
216 | 146 | FN_ZORBA_INTROSPECT_SCTX_BASE_URI_0, | 147 | FN_ZORBA_INTROSPECT_SCTX_BASE_URI_0, |
217 | 147 | 148 | ||
218 | === added file 'src/runtime/indexing/index_func_impl.cpp' | |||
219 | --- src/runtime/indexing/index_func_impl.cpp 1970-01-01 00:00:00 +0000 | |||
220 | +++ src/runtime/indexing/index_func_impl.cpp 2012-01-18 01:11:25 +0000 | |||
221 | @@ -0,0 +1,103 @@ | |||
222 | 1 | /* | ||
223 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
224 | 3 | * | ||
225 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
226 | 5 | * you may not use this file except in compliance with the License. | ||
227 | 6 | * You may obtain a copy of the License at | ||
228 | 7 | * | ||
229 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
230 | 9 | * | ||
231 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
232 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
233 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
234 | 13 | * See the License for the specific language governing permissions and | ||
235 | 14 | * limitations under the License. | ||
236 | 15 | */ | ||
237 | 16 | #include "stdafx.h" | ||
238 | 17 | |||
239 | 18 | #include "diagnostics/assert.h" | ||
240 | 19 | #include "diagnostics/xquery_diagnostics.h" | ||
241 | 20 | |||
242 | 21 | #include "zorbatypes/URI.h" | ||
243 | 22 | |||
244 | 23 | #include "system/globalenv.h" | ||
245 | 24 | |||
246 | 25 | #include "runtime/indexing/index_func.h" | ||
247 | 26 | #include "runtime/indexing/index_util.h" | ||
248 | 27 | |||
249 | 28 | #include "context/namespace_context.h" | ||
250 | 29 | #include "context/static_context.h" | ||
251 | 30 | |||
252 | 31 | #include "store/api/item.h" | ||
253 | 32 | #include "store/api/index.h" | ||
254 | 33 | |||
255 | 34 | #include "compiler/xqddf/value_index.h" | ||
256 | 35 | |||
257 | 36 | namespace zorba { | ||
258 | 37 | |||
259 | 38 | /******************************************************************************* | ||
260 | 39 | ********************************************************************************/ | ||
261 | 40 | bool | ||
262 | 41 | IndexKeysIterator::nextImpl( | ||
263 | 42 | store::Item_t& result, | ||
264 | 43 | PlanState& aPlanState) const | ||
265 | 44 | { | ||
266 | 45 | store::Item_t lQName; | ||
267 | 46 | IndexDecl_t indexDecl; | ||
268 | 47 | store::Index* lIndex; | ||
269 | 48 | store::IndexKey lKey; | ||
270 | 49 | |||
271 | 50 | store::Item_t lKeyNodeName; | ||
272 | 51 | GENV_ITEMFACTORY->createQName(lKeyNodeName, | ||
273 | 52 | static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS, | ||
274 | 53 | "", "key"); | ||
275 | 54 | |||
276 | 55 | IndexKeysIteratorState* state; | ||
277 | 56 | DEFAULT_STACK_INIT(IndexKeysIteratorState, state, aPlanState); | ||
278 | 57 | |||
279 | 58 | consumeNext(lQName, theChildren[0].getp(), aPlanState); | ||
280 | 59 | |||
281 | 60 | if ((indexDecl = theSctx->lookup_index(lQName)) == NULL) | ||
282 | 61 | { | ||
283 | 62 | throw XQUERY_EXCEPTION( | ||
284 | 63 | zerr::ZDDY0021_INDEX_NOT_DECLARED, | ||
285 | 64 | ERROR_PARAMS( lQName->getStringValue() ), | ||
286 | 65 | ERROR_LOC( loc ) | ||
287 | 66 | ); | ||
288 | 67 | } | ||
289 | 68 | |||
290 | 69 | lIndex = GENV_STORE.getIndex(lQName); | ||
291 | 70 | |||
292 | 71 | if (!lIndex) | ||
293 | 72 | { | ||
294 | 73 | throw XQUERY_EXCEPTION( | ||
295 | 74 | zerr::ZDDY0023_INDEX_DOES_NOT_EXIST, | ||
296 | 75 | ERROR_PARAMS( lQName->getStringValue() ), | ||
297 | 76 | ERROR_LOC( loc ) | ||
298 | 77 | ); | ||
299 | 78 | } | ||
300 | 79 | |||
301 | 80 | state->theIter = lIndex->keys(); | ||
302 | 81 | |||
303 | 82 | state->theIter->open(); | ||
304 | 83 | |||
305 | 84 | // generate result elements of the form | ||
306 | 85 | // <key> | ||
307 | 86 | // <attribute value="key1_value"/> | ||
308 | 87 | // <attribute value="key2_value"/> | ||
309 | 88 | // <attribute value="key3_value"/> | ||
310 | 89 | // </key> | ||
311 | 90 | while (state->theIter->next(lKey)) | ||
312 | 91 | { | ||
313 | 92 | IndexUtil::createIndexKeyElement( | ||
314 | 93 | result, lKey, static_context::ZORBA_STORE_STATIC_INDEXES_DML_FN_NS | ||
315 | 94 | ); | ||
316 | 95 | STACK_PUSH(true, state); | ||
317 | 96 | } | ||
318 | 97 | |||
319 | 98 | STACK_END(state); | ||
320 | 99 | } | ||
321 | 100 | |||
322 | 101 | } // namespace zorba | ||
323 | 102 | /* vim:set et sw=2 ts=2: */ | ||
324 | 103 | |||
325 | 0 | 104 | ||
326 | === added file 'src/runtime/indexing/index_util.h' | |||
327 | --- src/runtime/indexing/index_util.h 1970-01-01 00:00:00 +0000 | |||
328 | +++ src/runtime/indexing/index_util.h 2012-01-18 01:11:25 +0000 | |||
329 | @@ -0,0 +1,95 @@ | |||
330 | 1 | /* | ||
331 | 2 | * Copyright 2006-2012 The FLWOR Foundation. | ||
332 | 3 | * | ||
333 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
334 | 5 | * you may not use this file except in compliance with the License. | ||
335 | 6 | * You may obtain a copy of the License at | ||
336 | 7 | * | ||
337 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
338 | 9 | * | ||
339 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
340 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
341 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
342 | 13 | * See the License for the specific language governing permissions and | ||
343 | 14 | * limitations under the License. | ||
344 | 15 | */ | ||
345 | 16 | #ifndef ZORBA_INDEX_UTIL_H | ||
346 | 17 | #define ZORBA_INDEX_UTIL_H | ||
347 | 18 | |||
348 | 19 | #include "stdafx.h" | ||
349 | 20 | |||
350 | 21 | #include "context/namespace_context.h" | ||
351 | 22 | |||
352 | 23 | #include "store/api/pul.h" | ||
353 | 24 | #include "store/api/store.h" | ||
354 | 25 | #include "store/api/item.h" | ||
355 | 26 | #include "store/api/item_factory.h" | ||
356 | 27 | #include "store/api/iterator.h" | ||
357 | 28 | #include "store/api/index.h" | ||
358 | 29 | |||
359 | 30 | #include "types/typeimpl.h" | ||
360 | 31 | #include "types/typeops.h" | ||
361 | 32 | #include "types/casting.h" | ||
362 | 33 | |||
363 | 34 | namespace zorba { | ||
364 | 35 | |||
365 | 36 | class IndexUtil | ||
366 | 37 | { | ||
367 | 38 | public: | ||
368 | 39 | /******************************************************************************* | ||
369 | 40 | generate result elements of the form | ||
370 | 41 | <aBase:key> | ||
371 | 42 | <aBase:attribute aBase:value="key1_value"/> | ||
372 | 43 | <aBase:attribute aBase:value="key2_value"/> | ||
373 | 44 | <aBase:attribute aBase:value="key3_value"/> | ||
374 | 45 | </aBase:key> | ||
375 | 46 | ********************************************************************************/ | ||
376 | 47 | static void | ||
377 | 48 | createIndexKeyElement( | ||
378 | 49 | store::Item_t& result, | ||
379 | 50 | store::IndexKey& aKey, | ||
380 | 51 | const zstring& aBase) | ||
381 | 52 | { | ||
382 | 53 | store::Item_t lKeyNodeName; | ||
383 | 54 | GENV_ITEMFACTORY->createQName(lKeyNodeName, | ||
384 | 55 | aBase, "", "key"); | ||
385 | 56 | |||
386 | 57 | zstring lBase = aBase; | ||
387 | 58 | |||
388 | 59 | store::Item_t lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | ||
389 | 60 | |||
390 | 61 | const store::NsBindings lBindings; | ||
391 | 62 | |||
392 | 63 | GENV_ITEMFACTORY->createElementNode( | ||
393 | 64 | result, NULL, lKeyNodeName, lTypeName, | ||
394 | 65 | true, false, lBindings, lBase); | ||
395 | 66 | |||
396 | 67 | for (store::ItemVector::iterator lIter = aKey.begin(); | ||
397 | 68 | lIter != aKey.end(); | ||
398 | 69 | ++lIter) | ||
399 | 70 | { | ||
400 | 71 | store::Item_t lAttrElem, lAttrNodeName; | ||
401 | 72 | store::Item_t lNameAttr, lValueAttr, lValueAttrName; | ||
402 | 73 | |||
403 | 74 | GENV_ITEMFACTORY->createQName(lAttrNodeName, | ||
404 | 75 | lBase, "", "attribute"); | ||
405 | 76 | |||
406 | 77 | GENV_ITEMFACTORY->createQName(lValueAttrName, | ||
407 | 78 | "", "", "value"); | ||
408 | 79 | |||
409 | 80 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | ||
410 | 81 | |||
411 | 82 | GENV_ITEMFACTORY->createElementNode( | ||
412 | 83 | lAttrElem, result, lAttrNodeName, lTypeName, | ||
413 | 84 | true, false, lBindings, lBase); | ||
414 | 85 | |||
415 | 86 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | ||
416 | 87 | GENV_ITEMFACTORY->createAttributeNode( | ||
417 | 88 | lValueAttr, lAttrElem.getp(), lValueAttrName, lTypeName, (*lIter)); | ||
418 | 89 | } | ||
419 | 90 | } | ||
420 | 91 | }; /* class IndexUtil */ | ||
421 | 92 | |||
422 | 93 | } // namespace zorba | ||
423 | 94 | /* vim:set et sw=2 ts=2: */ | ||
424 | 95 | #endif | ||
425 | 0 | 96 | ||
426 | === added file 'src/runtime/indexing/pregenerated/index_func.cpp' | |||
427 | --- src/runtime/indexing/pregenerated/index_func.cpp 1970-01-01 00:00:00 +0000 | |||
428 | +++ src/runtime/indexing/pregenerated/index_func.cpp 2012-01-18 01:11:25 +0000 | |||
429 | @@ -0,0 +1,79 @@ | |||
430 | 1 | /* | ||
431 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
432 | 3 | * | ||
433 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
434 | 5 | * you may not use this file except in compliance with the License. | ||
435 | 6 | * You may obtain a copy of the License at | ||
436 | 7 | * | ||
437 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
438 | 9 | * | ||
439 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
440 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
441 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
442 | 13 | * See the License for the specific language governing permissions and | ||
443 | 14 | * limitations under the License. | ||
444 | 15 | */ | ||
445 | 16 | |||
446 | 17 | // ****************************************** | ||
447 | 18 | // * * | ||
448 | 19 | // * THIS IS A GENERATED FILE. DO NOT EDIT! * | ||
449 | 20 | // * SEE .xml FILE WITH SAME NAME * | ||
450 | 21 | // * * | ||
451 | 22 | // ****************************************** | ||
452 | 23 | |||
453 | 24 | #include "stdafx.h" | ||
454 | 25 | #include "zorbatypes/rchandle.h" | ||
455 | 26 | #include "zorbatypes/zstring.h" | ||
456 | 27 | #include "runtime/visitors/planiter_visitor.h" | ||
457 | 28 | #include "runtime/indexing/index_func.h" | ||
458 | 29 | #include "system/globalenv.h" | ||
459 | 30 | |||
460 | 31 | |||
461 | 32 | #include "store/api/iterator.h" | ||
462 | 33 | |||
463 | 34 | namespace zorba { | ||
464 | 35 | |||
465 | 36 | // <IndexKeysIterator> | ||
466 | 37 | const char* IndexKeysIterator::class_name_str = "IndexKeysIterator"; | ||
467 | 38 | IndexKeysIterator::class_factory<IndexKeysIterator> | ||
468 | 39 | IndexKeysIterator::g_class_factory; | ||
469 | 40 | |||
470 | 41 | const serialization::ClassVersion | ||
471 | 42 | IndexKeysIterator::class_versions[] ={{ 1, 0x000905, false}}; | ||
472 | 43 | |||
473 | 44 | const int IndexKeysIterator::class_versions_count = | ||
474 | 45 | sizeof(IndexKeysIterator::class_versions)/sizeof(struct serialization::ClassVersion); | ||
475 | 46 | |||
476 | 47 | void IndexKeysIterator::accept(PlanIterVisitor& v) const { | ||
477 | 48 | v.beginVisit(*this); | ||
478 | 49 | |||
479 | 50 | std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); | ||
480 | 51 | std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); | ||
481 | 52 | for ( ; lIter != lEnd; ++lIter ){ | ||
482 | 53 | (*lIter)->accept(v); | ||
483 | 54 | } | ||
484 | 55 | |||
485 | 56 | v.endVisit(*this); | ||
486 | 57 | } | ||
487 | 58 | |||
488 | 59 | IndexKeysIterator::~IndexKeysIterator() {} | ||
489 | 60 | |||
490 | 61 | IndexKeysIteratorState::IndexKeysIteratorState() {} | ||
491 | 62 | |||
492 | 63 | IndexKeysIteratorState::~IndexKeysIteratorState() {} | ||
493 | 64 | |||
494 | 65 | |||
495 | 66 | void IndexKeysIteratorState::init(PlanState& planState) { | ||
496 | 67 | PlanIteratorState::init(planState); | ||
497 | 68 | } | ||
498 | 69 | |||
499 | 70 | void IndexKeysIteratorState::reset(PlanState& planState) { | ||
500 | 71 | PlanIteratorState::reset(planState); | ||
501 | 72 | } | ||
502 | 73 | // </IndexKeysIterator> | ||
503 | 74 | |||
504 | 75 | |||
505 | 76 | |||
506 | 77 | } | ||
507 | 78 | |||
508 | 79 | |||
509 | 0 | 80 | ||
510 | === added file 'src/runtime/indexing/pregenerated/index_func.h' | |||
511 | --- src/runtime/indexing/pregenerated/index_func.h 1970-01-01 00:00:00 +0000 | |||
512 | +++ src/runtime/indexing/pregenerated/index_func.h 2012-01-18 01:11:25 +0000 | |||
513 | @@ -0,0 +1,97 @@ | |||
514 | 1 | /* | ||
515 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
516 | 3 | * | ||
517 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
518 | 5 | * you may not use this file except in compliance with the License. | ||
519 | 6 | * You may obtain a copy of the License at | ||
520 | 7 | * | ||
521 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
522 | 9 | * | ||
523 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
524 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
525 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
526 | 13 | * See the License for the specific language governing permissions and | ||
527 | 14 | * limitations under the License. | ||
528 | 15 | */ | ||
529 | 16 | |||
530 | 17 | // ****************************************** | ||
531 | 18 | // * * | ||
532 | 19 | // * THIS IS A GENERATED FILE. DO NOT EDIT! * | ||
533 | 20 | // * SEE .xml FILE WITH SAME NAME * | ||
534 | 21 | // * * | ||
535 | 22 | // ****************************************** | ||
536 | 23 | #ifndef ZORBA_RUNTIME_INDEXING_INDEX_FUNC_H | ||
537 | 24 | #define ZORBA_RUNTIME_INDEXING_INDEX_FUNC_H | ||
538 | 25 | |||
539 | 26 | |||
540 | 27 | #include "common/shared_types.h" | ||
541 | 28 | |||
542 | 29 | |||
543 | 30 | |||
544 | 31 | #include "runtime/base/narybase.h" | ||
545 | 32 | #include "store/api/index.h" | ||
546 | 33 | |||
547 | 34 | |||
548 | 35 | namespace zorba { | ||
549 | 36 | |||
550 | 37 | /** | ||
551 | 38 | * | ||
552 | 39 | * keys($iindexName as xs:QName) as () | ||
553 | 40 | * | ||
554 | 41 | * Author: Zorba Team | ||
555 | 42 | */ | ||
556 | 43 | class IndexKeysIteratorState : public PlanIteratorState | ||
557 | 44 | { | ||
558 | 45 | public: | ||
559 | 46 | store::Index::KeyIterator_t theIter; // | ||
560 | 47 | |||
561 | 48 | IndexKeysIteratorState(); | ||
562 | 49 | |||
563 | 50 | ~IndexKeysIteratorState(); | ||
564 | 51 | |||
565 | 52 | void init(PlanState&); | ||
566 | 53 | void reset(PlanState&); | ||
567 | 54 | }; | ||
568 | 55 | |||
569 | 56 | class IndexKeysIterator : public NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState> | ||
570 | 57 | { | ||
571 | 58 | protected: | ||
572 | 59 | store::NsBindings theNSBindings; // | ||
573 | 60 | public: | ||
574 | 61 | SERIALIZABLE_CLASS(IndexKeysIterator); | ||
575 | 62 | |||
576 | 63 | SERIALIZABLE_CLASS_CONSTRUCTOR2T(IndexKeysIterator, | ||
577 | 64 | NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>); | ||
578 | 65 | |||
579 | 66 | void serialize( ::zorba::serialization::Archiver& ar) | ||
580 | 67 | { | ||
581 | 68 | serialize_baseclass(ar, | ||
582 | 69 | (NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>*)this); | ||
583 | 70 | |||
584 | 71 | ar & theNSBindings; | ||
585 | 72 | } | ||
586 | 73 | |||
587 | 74 | IndexKeysIterator( | ||
588 | 75 | static_context* sctx, | ||
589 | 76 | const QueryLoc& loc, | ||
590 | 77 | std::vector<PlanIter_t>& children) | ||
591 | 78 | : | ||
592 | 79 | NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>(sctx, loc, children), | ||
593 | 80 | theNSBindings() | ||
594 | 81 | {} | ||
595 | 82 | |||
596 | 83 | virtual ~IndexKeysIterator(); | ||
597 | 84 | |||
598 | 85 | void accept(PlanIterVisitor& v) const; | ||
599 | 86 | |||
600 | 87 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; | ||
601 | 88 | }; | ||
602 | 89 | |||
603 | 90 | |||
604 | 91 | } | ||
605 | 92 | #endif | ||
606 | 93 | /* | ||
607 | 94 | * Local variables: | ||
608 | 95 | * mode: c++ | ||
609 | 96 | * End: | ||
610 | 97 | */ | ||
611 | 0 | 98 | ||
612 | === added file 'src/runtime/spec/indexing/index_func.xml' | |||
613 | --- src/runtime/spec/indexing/index_func.xml 1970-01-01 00:00:00 +0000 | |||
614 | +++ src/runtime/spec/indexing/index_func.xml 2012-01-18 01:11:25 +0000 | |||
615 | @@ -0,0 +1,55 @@ | |||
616 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
617 | 2 | |||
618 | 3 | <!-- | ||
619 | 4 | //////////////////////////////////////////////////////////////////////////////// | ||
620 | 5 | // // | ||
621 | 6 | // // | ||
622 | 7 | //////////////////////////////////////////////////////////////////////////////// | ||
623 | 8 | --> | ||
624 | 9 | <zorba:iterators | ||
625 | 10 | xmlns:zorba="http://www.zorba-xquery.com" | ||
626 | 11 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
627 | 12 | xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd"> | ||
628 | 13 | |||
629 | 14 | <zorba:source> | ||
630 | 15 | <zorba:include form="Quoted">store/api/iterator.h</zorba:include> | ||
631 | 16 | </zorba:source> | ||
632 | 17 | |||
633 | 18 | <zorba:header> | ||
634 | 19 | <zorba:include form="Quoted">store/api/index.h</zorba:include> | ||
635 | 20 | </zorba:header> | ||
636 | 21 | |||
637 | 22 | <!-- | ||
638 | 23 | /******************************************************************************* | ||
639 | 24 | *******************************************************************************/ | ||
640 | 25 | --> | ||
641 | 26 | <zorba:iterator name="IndexKeysIterator" arity="nary"> | ||
642 | 27 | |||
643 | 28 | <zorba:description author="Zorba Team"> | ||
644 | 29 | keys($iindexName as xs:QName) as () | ||
645 | 30 | </zorba:description> | ||
646 | 31 | |||
647 | 32 | <zorba:function> | ||
648 | 33 | |||
649 | 34 | <zorba:signature localname="keys" | ||
650 | 35 | prefix="zorba-store-indexes-static-dml"> | ||
651 | 36 | <zorba:param>xs:QName</zorba:param> | ||
652 | 37 | <zorba:output>node()*</zorba:output> | ||
653 | 38 | </zorba:signature> | ||
654 | 39 | |||
655 | 40 | <zorba:methods> | ||
656 | 41 | <zorba:accessesDynCtx returnValue="true"/> | ||
657 | 42 | </zorba:methods> | ||
658 | 43 | |||
659 | 44 | </zorba:function> | ||
660 | 45 | |||
661 | 46 | <zorba:state> | ||
662 | 47 | <zorba:member type="store::Index::KeyIterator_t" name="theIter"/> | ||
663 | 48 | </zorba:state> | ||
664 | 49 | |||
665 | 50 | <zorba:member type="store::NsBindings" name="theNSBindings" brief=""/> | ||
666 | 51 | |||
667 | 52 | </zorba:iterator> | ||
668 | 53 | |||
669 | 54 | </zorba:iterators> | ||
670 | 55 | |||
671 | 0 | 56 | ||
672 | === modified file 'src/runtime/store/maps_impl.cpp' | |||
673 | --- src/runtime/store/maps_impl.cpp 2011-10-26 21:13:53 +0000 | |||
674 | +++ src/runtime/store/maps_impl.cpp 2012-01-18 01:11:25 +0000 | |||
675 | @@ -23,6 +23,7 @@ | |||
676 | 23 | #include "system/globalenv.h" | 23 | #include "system/globalenv.h" |
677 | 24 | 24 | ||
678 | 25 | #include "runtime/store/maps.h" | 25 | #include "runtime/store/maps.h" |
679 | 26 | #include "runtime/indexing/index_util.h" | ||
680 | 26 | 27 | ||
681 | 27 | #include "context/static_context.h" | 28 | #include "context/static_context.h" |
682 | 28 | #include "context/namespace_context.h" | 29 | #include "context/namespace_context.h" |
683 | @@ -444,11 +445,6 @@ | |||
684 | 444 | zstring lBaseURI = | 445 | zstring lBaseURI = |
685 | 445 | static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS; | 446 | static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS; |
686 | 446 | 447 | ||
687 | 447 | store::Item_t lKeyNodeName; | ||
688 | 448 | GENV_ITEMFACTORY->createQName(lKeyNodeName, | ||
689 | 449 | static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS, | ||
690 | 450 | "", "key"); | ||
691 | 451 | |||
692 | 452 | MapKeysIteratorState* state; | 448 | MapKeysIteratorState* state; |
693 | 453 | DEFAULT_STACK_INIT(MapKeysIteratorState, state, aPlanState); | 449 | DEFAULT_STACK_INIT(MapKeysIteratorState, state, aPlanState); |
694 | 454 | 450 | ||
695 | @@ -477,36 +473,9 @@ | |||
696 | 477 | // </key> | 473 | // </key> |
697 | 478 | while (state->theIter->next(lKey)) | 474 | while (state->theIter->next(lKey)) |
698 | 479 | { | 475 | { |
729 | 480 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | 476 | IndexUtil::createIndexKeyElement(result, lKey, |
730 | 481 | 477 | static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS | |
731 | 482 | GENV_ITEMFACTORY->createElementNode( | 478 | ); |
702 | 483 | result, NULL, lKeyNodeName, lTypeName, | ||
703 | 484 | true, false, theNSBindings, lBaseURI); | ||
704 | 485 | |||
705 | 486 | for (store::ItemVector::iterator lIter = lKey.begin(); | ||
706 | 487 | lIter != lKey.end(); | ||
707 | 488 | ++lIter) | ||
708 | 489 | { | ||
709 | 490 | store::Item_t lAttrElem, lAttrNodeName; | ||
710 | 491 | store::Item_t lNameAttr, lValueAttr, lValueAttrName; | ||
711 | 492 | |||
712 | 493 | GENV_ITEMFACTORY->createQName(lAttrNodeName, | ||
713 | 494 | static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS, | ||
714 | 495 | "", "attribute"); | ||
715 | 496 | |||
716 | 497 | GENV_ITEMFACTORY->createQName(lValueAttrName, | ||
717 | 498 | "", "", "value"); | ||
718 | 499 | |||
719 | 500 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | ||
720 | 501 | |||
721 | 502 | GENV_ITEMFACTORY->createElementNode( | ||
722 | 503 | lAttrElem, result, lAttrNodeName, lTypeName, | ||
723 | 504 | true, false, theNSBindings, lBaseURI); | ||
724 | 505 | |||
725 | 506 | lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME; | ||
726 | 507 | GENV_ITEMFACTORY->createAttributeNode( | ||
727 | 508 | lValueAttr, lAttrElem.getp(), lValueAttrName, lTypeName, (*lIter)); | ||
728 | 509 | } | ||
732 | 510 | STACK_PUSH(true, state); | 479 | STACK_PUSH(true, state); |
733 | 511 | } | 480 | } |
734 | 512 | 481 | ||
735 | 513 | 482 | ||
736 | === modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h' | |||
737 | --- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-01-11 17:30:25 +0000 | |||
738 | +++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-01-18 01:11:25 +0000 | |||
739 | @@ -201,6 +201,8 @@ | |||
740 | 201 | 201 | ||
741 | 202 | class CheckICIterator; | 202 | class CheckICIterator; |
742 | 203 | 203 | ||
743 | 204 | class IndexKeysIterator; | ||
744 | 205 | |||
745 | 204 | class StaticNamespacesIterator; | 206 | class StaticNamespacesIterator; |
746 | 205 | 207 | ||
747 | 206 | class DefaultFunctionNamespaceIterator; | 208 | class DefaultFunctionNamespaceIterator; |
748 | @@ -854,6 +856,9 @@ | |||
749 | 854 | virtual void beginVisit ( const CheckICIterator& ) = 0; | 856 | virtual void beginVisit ( const CheckICIterator& ) = 0; |
750 | 855 | virtual void endVisit ( const CheckICIterator& ) = 0; | 857 | virtual void endVisit ( const CheckICIterator& ) = 0; |
751 | 856 | 858 | ||
752 | 859 | virtual void beginVisit ( const IndexKeysIterator& ) = 0; | ||
753 | 860 | virtual void endVisit ( const IndexKeysIterator& ) = 0; | ||
754 | 861 | |||
755 | 857 | virtual void beginVisit ( const StaticNamespacesIterator& ) = 0; | 862 | virtual void beginVisit ( const StaticNamespacesIterator& ) = 0; |
756 | 858 | virtual void endVisit ( const StaticNamespacesIterator& ) = 0; | 863 | virtual void endVisit ( const StaticNamespacesIterator& ) = 0; |
757 | 859 | 864 | ||
758 | 860 | 865 | ||
759 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' | |||
760 | --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-01-11 17:30:25 +0000 | |||
761 | +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-01-18 01:11:25 +0000 | |||
762 | @@ -49,6 +49,7 @@ | |||
763 | 49 | #include "runtime/fnput/fnput.h" | 49 | #include "runtime/fnput/fnput.h" |
764 | 50 | #include "runtime/function_item/function_item_iter.h" | 50 | #include "runtime/function_item/function_item_iter.h" |
765 | 51 | #include "runtime/indexing/ic_ddl.h" | 51 | #include "runtime/indexing/ic_ddl.h" |
766 | 52 | #include "runtime/indexing/index_func.h" | ||
767 | 52 | #include "runtime/introspection/sctx.h" | 53 | #include "runtime/introspection/sctx.h" |
768 | 53 | #include "runtime/maths/maths.h" | 54 | #include "runtime/maths/maths.h" |
769 | 54 | #include "runtime/nodes/node_position.h" | 55 | #include "runtime/nodes/node_position.h" |
770 | @@ -1300,6 +1301,20 @@ | |||
771 | 1300 | // </CheckICIterator> | 1301 | // </CheckICIterator> |
772 | 1301 | 1302 | ||
773 | 1302 | 1303 | ||
774 | 1304 | // <IndexKeysIterator> | ||
775 | 1305 | void PrinterVisitor::beginVisit ( const IndexKeysIterator& a) { | ||
776 | 1306 | thePrinter.startBeginVisit("IndexKeysIterator", ++theId); | ||
777 | 1307 | printCommons( &a, theId ); | ||
778 | 1308 | thePrinter.endBeginVisit( theId ); | ||
779 | 1309 | } | ||
780 | 1310 | |||
781 | 1311 | void PrinterVisitor::endVisit ( const IndexKeysIterator& ) { | ||
782 | 1312 | thePrinter.startEndVisit(); | ||
783 | 1313 | thePrinter.endEndVisit(); | ||
784 | 1314 | } | ||
785 | 1315 | // </IndexKeysIterator> | ||
786 | 1316 | |||
787 | 1317 | |||
788 | 1303 | // <StaticNamespacesIterator> | 1318 | // <StaticNamespacesIterator> |
789 | 1304 | void PrinterVisitor::beginVisit ( const StaticNamespacesIterator& a) { | 1319 | void PrinterVisitor::beginVisit ( const StaticNamespacesIterator& a) { |
790 | 1305 | thePrinter.startBeginVisit("StaticNamespacesIterator", ++theId); | 1320 | thePrinter.startBeginVisit("StaticNamespacesIterator", ++theId); |
791 | 1306 | 1321 | ||
792 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.h' | |||
793 | --- src/runtime/visitors/pregenerated/printer_visitor.h 2012-01-11 17:30:25 +0000 | |||
794 | +++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-01-18 01:11:25 +0000 | |||
795 | @@ -304,6 +304,9 @@ | |||
796 | 304 | void beginVisit( const CheckICIterator& ); | 304 | void beginVisit( const CheckICIterator& ); |
797 | 305 | void endVisit ( const CheckICIterator& ); | 305 | void endVisit ( const CheckICIterator& ); |
798 | 306 | 306 | ||
799 | 307 | void beginVisit( const IndexKeysIterator& ); | ||
800 | 308 | void endVisit ( const IndexKeysIterator& ); | ||
801 | 309 | |||
802 | 307 | void beginVisit( const StaticNamespacesIterator& ); | 310 | void beginVisit( const StaticNamespacesIterator& ); |
803 | 308 | void endVisit ( const StaticNamespacesIterator& ); | 311 | void endVisit ( const StaticNamespacesIterator& ); |
804 | 309 | 312 | ||
805 | 310 | 313 | ||
806 | === modified file 'src/store/naive/simple_index_value.cpp' | |||
807 | --- src/store/naive/simple_index_value.cpp 2012-01-11 17:30:25 +0000 | |||
808 | +++ src/store/naive/simple_index_value.cpp 2012-01-18 01:11:25 +0000 | |||
809 | @@ -519,6 +519,13 @@ | |||
810 | 519 | /****************************************************************************** | 519 | /****************************************************************************** |
811 | 520 | 520 | ||
812 | 521 | ********************************************************************************/ | 521 | ********************************************************************************/ |
813 | 522 | ValueTreeIndex::KeyIterator::KeyIterator(const IndexMap& aMap) | ||
814 | 523 | : | ||
815 | 524 | theMap(aMap) | ||
816 | 525 | { | ||
817 | 526 | } | ||
818 | 527 | |||
819 | 528 | |||
820 | 522 | ValueTreeIndex::KeyIterator::~KeyIterator() | 529 | ValueTreeIndex::KeyIterator::~KeyIterator() |
821 | 523 | { | 530 | { |
822 | 524 | }; | 531 | }; |
823 | @@ -526,21 +533,29 @@ | |||
824 | 526 | 533 | ||
825 | 527 | void ValueTreeIndex::KeyIterator::open() | 534 | void ValueTreeIndex::KeyIterator::open() |
826 | 528 | { | 535 | { |
828 | 529 | assert(false); | 536 | theIterator = theMap.begin(); |
829 | 530 | } | 537 | } |
830 | 531 | 538 | ||
831 | 532 | 539 | ||
833 | 533 | bool ValueTreeIndex::KeyIterator::next(store::IndexKey&) | 540 | bool ValueTreeIndex::KeyIterator::next(store::IndexKey& aKey) |
834 | 534 | { | 541 | { |
836 | 535 | assert(false); | 542 | if (theIterator != theMap.end()) |
837 | 543 | { | ||
838 | 544 | const store::IndexKey* lKey = (*theIterator).first; | ||
839 | 545 | aKey = *lKey; | ||
840 | 546 | |||
841 | 547 | ++theIterator; | ||
842 | 548 | return true; | ||
843 | 549 | } | ||
844 | 536 | return false; | 550 | return false; |
845 | 537 | } | 551 | } |
846 | 538 | 552 | ||
847 | 539 | 553 | ||
848 | 540 | void ValueTreeIndex::KeyIterator::close() | 554 | void ValueTreeIndex::KeyIterator::close() |
849 | 541 | { | 555 | { |
852 | 542 | assert(false); | 556 | theIterator = theMap.end(); |
853 | 543 | } | 557 | }; |
854 | 558 | |||
855 | 544 | 559 | ||
856 | 545 | 560 | ||
857 | 546 | /****************************************************************************** | 561 | /****************************************************************************** |
858 | @@ -596,8 +611,7 @@ | |||
859 | 596 | ********************************************************************************/ | 611 | ********************************************************************************/ |
860 | 597 | store::Index::KeyIterator_t ValueTreeIndex::keys() const | 612 | store::Index::KeyIterator_t ValueTreeIndex::keys() const |
861 | 598 | { | 613 | { |
864 | 599 | assert(false); | 614 | return new KeyIterator(theMap); |
863 | 600 | return 0; | ||
865 | 601 | } | 615 | } |
866 | 602 | 616 | ||
867 | 603 | 617 | ||
868 | 604 | 618 | ||
869 | === modified file 'src/store/naive/simple_index_value.h' | |||
870 | --- src/store/naive/simple_index_value.h 2012-01-11 17:30:25 +0000 | |||
871 | +++ src/store/naive/simple_index_value.h 2012-01-18 01:11:25 +0000 | |||
872 | @@ -198,7 +198,12 @@ | |||
873 | 198 | 198 | ||
874 | 199 | class KeyIterator : public Index::KeyIterator | 199 | class KeyIterator : public Index::KeyIterator |
875 | 200 | { | 200 | { |
876 | 201 | protected: | ||
877 | 202 | IndexMap::const_iterator theIterator; | ||
878 | 203 | const IndexMap & theMap; | ||
879 | 204 | |||
880 | 201 | public: | 205 | public: |
881 | 206 | KeyIterator(const IndexMap& aMap); | ||
882 | 202 | ~KeyIterator(); | 207 | ~KeyIterator(); |
883 | 203 | 208 | ||
884 | 204 | void open(); | 209 | void open(); |
885 | 205 | 210 | ||
886 | === added file 'test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res' | |||
887 | --- test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res 1970-01-01 00:00:00 +0000 | |||
888 | +++ test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res 2012-01-18 01:11:25 +0000 | |||
889 | @@ -0,0 +1,1 @@ | |||
890 | 1 | <keys typeIsInteger="true"><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="10"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="5"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="6"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="1"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="7"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="2"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="8"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="3"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="9"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="4"/></key></keys> | ||
891 | 0 | 2 | ||
892 | === added file 'test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res' | |||
893 | --- test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res 1970-01-01 00:00:00 +0000 | |||
894 | +++ test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res 2012-01-18 01:11:25 +0000 | |||
895 | @@ -0,0 +1,1 @@ | |||
896 | 1 | <keys><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="1"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="2"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="3"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="4"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="5"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="6"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="7"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="8"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="9"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"><attribute value="10"/></key></keys> | ||
897 | 0 | 2 | ||
898 | === added file 'test/rbkt/Queries/zorba/index/keys1.xq' | |||
899 | --- test/rbkt/Queries/zorba/index/keys1.xq 1970-01-01 00:00:00 +0000 | |||
900 | +++ test/rbkt/Queries/zorba/index/keys1.xq 2012-01-18 01:11:25 +0000 | |||
901 | @@ -0,0 +1,22 @@ | |||
902 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | ||
903 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
904 | 3 | import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl"; | ||
905 | 4 | import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml"; | ||
906 | 5 | |||
907 | 6 | import module namespace keys-lib = "http://www.example.com/" at "keys_mod.xqlib"; | ||
908 | 7 | |||
909 | 8 | ddl:create(xs:QName("keys-lib:foo")); | ||
910 | 9 | index_ddl:create(xs:QName("keys-lib:FooIdx")); | ||
911 | 10 | |||
912 | 11 | for $i in 1 to 10 | ||
913 | 12 | return | ||
914 | 13 | dml:insert-nodes(xs:QName("keys-lib:foo"), | ||
915 | 14 | <foo id="{$i}"/> | ||
916 | 15 | ); | ||
917 | 16 | |||
918 | 17 | let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx")) | ||
919 | 18 | let $attr := $keys[1]/self::*:key/*:attribute/@*:value | ||
920 | 19 | return | ||
921 | 20 | <keys typeIsInteger="{data($attr) instance of xs:integer}">{ | ||
922 | 21 | $keys | ||
923 | 22 | }</keys> | ||
924 | 0 | 23 | ||
925 | === added file 'test/rbkt/Queries/zorba/index/keys2.xq' | |||
926 | --- test/rbkt/Queries/zorba/index/keys2.xq 1970-01-01 00:00:00 +0000 | |||
927 | +++ test/rbkt/Queries/zorba/index/keys2.xq 2012-01-18 01:11:25 +0000 | |||
928 | @@ -0,0 +1,22 @@ | |||
929 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | ||
930 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
931 | 3 | import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl"; | ||
932 | 4 | import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml"; | ||
933 | 5 | |||
934 | 6 | import module namespace keys-lib = "http://www.example.com/" at "keys_mod.xqlib"; | ||
935 | 7 | |||
936 | 8 | ddl:create(xs:QName("keys-lib:foo")); | ||
937 | 9 | index_ddl:create(xs:QName("keys-lib:FooIdx2")); | ||
938 | 10 | |||
939 | 11 | for $i in 1 to 10 | ||
940 | 12 | return | ||
941 | 13 | dml:insert-nodes(xs:QName("keys-lib:foo"), | ||
942 | 14 | <foo id="{$i}"/> | ||
943 | 15 | ); | ||
944 | 16 | |||
945 | 17 | let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx2")) | ||
946 | 18 | return | ||
947 | 19 | <keys>{ | ||
948 | 20 | $keys | ||
949 | 21 | }</keys> | ||
950 | 22 | |||
951 | 0 | 23 | ||
952 | === added file 'test/rbkt/Queries/zorba/index/keys_mod.xqlib' | |||
953 | --- test/rbkt/Queries/zorba/index/keys_mod.xqlib 1970-01-01 00:00:00 +0000 | |||
954 | +++ test/rbkt/Queries/zorba/index/keys_mod.xqlib 2012-01-18 01:11:25 +0000 | |||
955 | @@ -0,0 +1,15 @@ | |||
956 | 1 | module namespace keys-lib = "http://www.example.com/"; | ||
957 | 2 | |||
958 | 3 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
959 | 4 | |||
960 | 5 | declare namespace ann = "http://www.zorba-xquery.com/annotations"; | ||
961 | 6 | |||
962 | 7 | declare %ann:unordered collection keys-lib:foo as node()*; | ||
963 | 8 | |||
964 | 9 | declare %ann:automatic %ann:value-equality index keys-lib:FooIdx | ||
965 | 10 | on nodes dml:collection(xs:QName("keys-lib:foo")) | ||
966 | 11 | by xs:integer(./@id) as xs:integer; | ||
967 | 12 | |||
968 | 13 | declare %ann:automatic %ann:value-range index keys-lib:FooIdx2 | ||
969 | 14 | on nodes dml:collection(xs:QName("keys-lib:foo")) | ||
970 | 15 | by xs:integer(./@id) as xs:integer; |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ bug900677- 2012-01- 18T01-02- 56.733Z/ log.html
Log at: http://