Merge lp:~zorba-coders/zorba/bug-938934 into lp:zorba
- bug-938934
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~zorba-coders/zorba/bug-938934 | ||||
Merge into: | lp:zorba | ||||
Diff against target: |
1160 lines (+624/-9) 34 files modified
ChangeLog (+1/-0) modules/com/zorba-xquery/www/modules/store/dynamic/collections/dml.xq (+16/-3) modules/com/zorba-xquery/www/modules/store/static/collections/dml.xq (+15/-0) src/functions/func_collections_impl.cpp (+15/-0) src/functions/pregenerated/func_collections.cpp (+25/-0) src/functions/pregenerated/func_collections.h (+19/-0) src/functions/pregenerated/function_enum.h (+2/-0) src/runtime/collections/collections_impl.cpp (+87/-0) src/runtime/collections/pregenerated/collections.cpp (+28/-0) src/runtime/collections/pregenerated/collections.h (+44/-0) src/runtime/core/apply_updates.cpp (+13/-1) src/runtime/spec/collections/collections.xml (+46/-0) src/runtime/visitors/pregenerated/planiter_visitor.h (+5/-0) src/runtime/visitors/pregenerated/printer_visitor.cpp (+14/-0) src/runtime/visitors/pregenerated/printer_visitor.h (+3/-0) src/store/api/pul.h (+11/-1) src/store/api/update_consts.h (+3/-0) src/store/naive/pul_primitive_factory.cpp (+12/-0) src/store/naive/pul_primitive_factory.h (+10/-0) src/store/naive/pul_primitives.cpp (+30/-0) src/store/naive/pul_primitives.h (+31/-0) src/store/naive/simple_collection.h (+1/-0) src/store/naive/simple_index.h (+2/-0) src/store/naive/simple_index_general.cpp (+40/-0) src/store/naive/simple_index_general.h (+4/-0) src/store/naive/simple_pul.cpp (+65/-2) src/store/naive/simple_pul.h (+14/-1) test/rbkt/ExpQueryResults/zorba/collections/delete_nodes/truncate_001.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/collections/dynamic6.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/index/auctions2.xml.res (+1/-0) test/rbkt/Queries/zorba/collections/collection_002.xqdata (+3/-1) test/rbkt/Queries/zorba/collections/delete_nodes/truncate_001.xq (+27/-0) test/rbkt/Queries/zorba/collections/dynamic6.xq (+10/-0) test/rbkt/Queries/zorba/index/auctions2.xq (+25/-0) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug-938934 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Needs Fixing | ||
Matthias Brantner | Approve | ||
Till Westmann | Pending | ||
Review via email: mp+94897@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-03-08.
Commit message
- fix bug #938934 "collection dml:truncate function missing"
- fixes documentation bug: raise zerr:ZDDY0003 instead of zerr:ZDDY0009
Description of the change
Matthias Brantner (matthias-brantner) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug-938934-2012-02-
All tests succeeded!
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 2 Pending.
Matthias Brantner (matthias-brantner) : | # |
Markos Zaharioudakis (markos-za) : | # |
Markos Zaharioudakis (markos-za) wrote : | # |
Index maintenance has not been taken into account.
Also, a possible optimization is to skip the application of insertion and deletion primitives on a collection, if there is a truncate primiive.
Markos Zaharioudakis (markos-za) wrote : | # |
Another bug: the UpdTruncateColl
- 10682. By Matthias Brantner
-
clear functions for indexes
- 10683. By Matthias Brantner
-
index management if a collection is truncated
- 10684. By Matthias Brantner
-
extended test for two truncate primitives in one PUL
Matthias Brantner (matthias-brantner) wrote : | # |
- index maintenance
- optimization to skip apply if a collection is truncated
- couldn't figure out why multiple truncate primitives can't exist in the same pul (added a test)
- 10685. By Matthias Brantner
-
added truncate function decl for dynamic collections
- 10686. By Matthias Brantner
-
merge
- 10687. By Matthias Brantner
-
removed obsolete member of the truncate primitive because undo is not possible anyway
- 10688. By Matthias Brantner
-
improved error message
Unmerged revisions
Preview Diff
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2012-03-07 15:49:25 +0000 | |||
3 | +++ ChangeLog 2012-03-08 01:45:23 +0000 | |||
4 | @@ -10,6 +10,7 @@ | |||
5 | 10 | %ann:must-copy-input-nodes to be used by the no-copy optimization. | 10 | %ann:must-copy-input-nodes to be used by the no-copy optimization. |
6 | 11 | * Caching of results for recursive functions with atomic parameter and return types. | 11 | * Caching of results for recursive functions with atomic parameter and return types. |
7 | 12 | * Added %ann:cache and %ann:no-cache to enable or disable caching of results of functions with atomic parameter and return types. | 12 | * Added %ann:cache and %ann:no-cache to enable or disable caching of results of functions with atomic parameter and return types. |
8 | 13 | * Added truncate function to the collection modules for efficient deletion of all nodes in a collection. | ||
9 | 13 | * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context) | 14 | * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context) |
10 | 14 | * Fixed bug 867509 (Can not handle largest xs:unsignedLong values) | 15 | * Fixed bug 867509 (Can not handle largest xs:unsignedLong values) |
11 | 15 | * Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator) | 16 | * Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator) |
12 | 16 | 17 | ||
13 | === modified file 'modules/com/zorba-xquery/www/modules/store/dynamic/collections/dml.xq' | |||
14 | --- modules/com/zorba-xquery/www/modules/store/dynamic/collections/dml.xq 2011-08-26 23:36:24 +0000 | |||
15 | +++ modules/com/zorba-xquery/www/modules/store/dynamic/collections/dml.xq 2012-03-08 01:45:23 +0000 | |||
16 | @@ -260,7 +260,7 @@ | |||
17 | 260 | : @return The result of this function is an empty XDM instance and a pending update | 260 | : @return The result of this function is an empty XDM instance and a pending update |
18 | 261 | : list which, once applied, deletes the last node from the collection. | 261 | : list which, once applied, deletes the last node from the collection. |
19 | 262 | : | 262 | : |
21 | 263 | : @error zerr:ZDDY0009 If available collections does not provide a mapping | 263 | : @error zerr:ZDDY0003 If available collections does not provide a mapping |
22 | 264 | : for the expanded QName $name. | 264 | : for the expanded QName $name. |
23 | 265 | : @error zerr:ZDDY0011 if the collection doesn't contain any node. | 265 | : @error zerr:ZDDY0011 if the collection doesn't contain any node. |
24 | 266 | : | 266 | : |
25 | @@ -278,7 +278,7 @@ | |||
26 | 278 | : @return The result of this function is an empty XDM instance and a pending update | 278 | : @return The result of this function is an empty XDM instance and a pending update |
27 | 279 | : list which, once applied, deletes the last n nodes. | 279 | : list which, once applied, deletes the last n nodes. |
28 | 280 | : | 280 | : |
30 | 281 | : @error zerr:ZDDY0009 If available collections does not provide a mapping | 281 | : @error zerr:ZDDY0003 If available collections does not provide a mapping |
31 | 282 | : for the expanded QName $name. | 282 | : for the expanded QName $name. |
32 | 283 | : @error zerr:ZDDY0011 if the collection doesn't contain the given number of nodes. | 283 | : @error zerr:ZDDY0011 if the collection doesn't contain the given number of nodes. |
33 | 284 | : | 284 | : |
34 | @@ -288,6 +288,19 @@ | |||
35 | 288 | $number as xs:integer) external; | 288 | $number as xs:integer) external; |
36 | 289 | 289 | ||
37 | 290 | (:~ | 290 | (:~ |
38 | 291 | : The truncate function is an updating function that deletes the | ||
39 | 292 | : entire contents of collection. | ||
40 | 293 | : | ||
41 | 294 | : @param $name The name of the collection whose content to delete | ||
42 | 295 | : | ||
43 | 296 | : @return The result of this function is an empty XDM instance and a pending update | ||
44 | 297 | : list which, once applied, deletes the nodes. | ||
45 | 298 | : | ||
46 | 299 | : @error zerr:ZDDY0003 if the collection identified by $name is not available. | ||
47 | 300 | :) | ||
48 | 301 | declare updating function dml:truncate($name as xs:QName) external; | ||
49 | 302 | |||
50 | 303 | (:~ | ||
51 | 291 | : The index-of function return the index of the given node in the collection. | 304 | : The index-of function return the index of the given node in the collection. |
52 | 292 | : | 305 | : |
53 | 293 | : @param $node The node to retrieve the index from. | 306 | : @param $node The node to retrieve the index from. |
54 | @@ -307,7 +320,7 @@ | |||
55 | 307 | : | 320 | : |
56 | 308 | : @return The sequence contained in the given collection. | 321 | : @return The sequence contained in the given collection. |
57 | 309 | : | 322 | : |
59 | 310 | : @error zerr:ZDDY0009 If available collections does not provide a mapping | 323 | : @error zerr:ZDDY0003 If available collections does not provide a mapping |
60 | 311 | : for the expanded QName $name. | 324 | : for the expanded QName $name. |
61 | 312 | : | 325 | : |
62 | 313 | :) | 326 | :) |
63 | 314 | 327 | ||
64 | === modified file 'modules/com/zorba-xquery/www/modules/store/static/collections/dml.xq' | |||
65 | --- modules/com/zorba-xquery/www/modules/store/static/collections/dml.xq 2011-10-03 09:18:49 +0000 | |||
66 | +++ modules/com/zorba-xquery/www/modules/store/static/collections/dml.xq 2012-03-08 01:45:23 +0000 | |||
67 | @@ -409,6 +409,21 @@ | |||
68 | 409 | $number as xs:integer) external; | 409 | $number as xs:integer) external; |
69 | 410 | 410 | ||
70 | 411 | (:~ | 411 | (:~ |
71 | 412 | : The truncate function is an updating function that deletes the | ||
72 | 413 | : entire contents of collection. | ||
73 | 414 | : | ||
74 | 415 | : @param $name The name of the collection whose content to delete | ||
75 | 416 | : | ||
76 | 417 | : @return The result of this function is an empty XDM instance and a pending update | ||
77 | 418 | : list which, once applied, deletes the nodes. | ||
78 | 419 | : | ||
79 | 420 | : @error zerr:ZDDY0001 if the collection identified by $name is not declared. | ||
80 | 421 | : @error zerr:ZDDY0003 if the collection identified by $name is not available. | ||
81 | 422 | : | ||
82 | 423 | :) | ||
83 | 424 | declare updating function cdml:truncate($name as xs:QName) external; | ||
84 | 425 | |||
85 | 426 | (:~ | ||
86 | 412 | : The index-of function that returns the position of the node in its collection. | 427 | : The index-of function that returns the position of the node in its collection. |
87 | 413 | : | 428 | : |
88 | 414 | : @param $node The node to retrieve the index for. | 429 | : @param $node The node to retrieve the index for. |
89 | 415 | 430 | ||
90 | === modified file 'src/functions/func_collections_impl.cpp' | |||
91 | --- src/functions/func_collections_impl.cpp 2012-02-16 12:48:17 +0000 | |||
92 | +++ src/functions/func_collections_impl.cpp 2012-03-08 01:45:23 +0000 | |||
93 | @@ -293,6 +293,21 @@ | |||
94 | 293 | /******************************************************************************* | 293 | /******************************************************************************* |
95 | 294 | 294 | ||
96 | 295 | ********************************************************************************/ | 295 | ********************************************************************************/ |
97 | 296 | PlanIter_t zorba_store_collections_static_dml_truncate::codegen( | ||
98 | 297 | CompilerCB*, | ||
99 | 298 | static_context* sctx, | ||
100 | 299 | const QueryLoc& loc, | ||
101 | 300 | std::vector<PlanIter_t>& argv, | ||
102 | 301 | expr& ann) const | ||
103 | 302 | { | ||
104 | 303 | return new ZorbaTruncateCollectionIterator(sctx, loc, argv, | ||
105 | 304 | getName()->getNamespace() == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS); | ||
106 | 305 | } | ||
107 | 306 | |||
108 | 307 | |||
109 | 308 | /******************************************************************************* | ||
110 | 309 | |||
111 | 310 | ********************************************************************************/ | ||
112 | 296 | PlanIter_t zorba_store_collections_static_dml_delete_node_first::codegen( | 311 | PlanIter_t zorba_store_collections_static_dml_delete_node_first::codegen( |
113 | 297 | CompilerCB*, | 312 | CompilerCB*, |
114 | 298 | static_context* sctx, | 313 | static_context* sctx, |
115 | 299 | 314 | ||
116 | === modified file 'src/functions/pregenerated/func_collections.cpp' | |||
117 | --- src/functions/pregenerated/func_collections.cpp 2012-02-16 12:48:17 +0000 | |||
118 | +++ src/functions/pregenerated/func_collections.cpp 2012-03-08 01:45:23 +0000 | |||
119 | @@ -58,6 +58,7 @@ | |||
120 | 58 | 58 | ||
121 | 59 | 59 | ||
122 | 60 | 60 | ||
123 | 61 | |||
124 | 61 | PlanIter_t zorba_store_collections_static_dml_collection_name::codegen( | 62 | PlanIter_t zorba_store_collections_static_dml_collection_name::codegen( |
125 | 62 | CompilerCB*, | 63 | CompilerCB*, |
126 | 63 | static_context* sctx, | 64 | static_context* sctx, |
127 | @@ -686,6 +687,30 @@ | |||
128 | 686 | { | 687 | { |
129 | 687 | 688 | ||
130 | 688 | 689 | ||
131 | 690 | DECL_WITH_KIND(sctx, zorba_store_collections_static_dml_truncate, | ||
132 | 691 | (createQName("http://www.zorba-xquery.com/modules/store/static/collections/dml","","truncate"), | ||
133 | 692 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, | ||
134 | 693 | GENV_TYPESYSTEM.EMPTY_TYPE), | ||
135 | 694 | FunctionConsts::ZORBA_STORE_COLLECTIONS_STATIC_DML_TRUNCATE_1); | ||
136 | 695 | |||
137 | 696 | } | ||
138 | 697 | |||
139 | 698 | |||
140 | 699 | { | ||
141 | 700 | |||
142 | 701 | |||
143 | 702 | DECL_WITH_KIND(sctx, zorba_store_collections_static_dml_truncate, | ||
144 | 703 | (createQName("http://www.zorba-xquery.com/modules/store/dynamic/collections/dml","","truncate"), | ||
145 | 704 | GENV_TYPESYSTEM.QNAME_TYPE_ONE, | ||
146 | 705 | GENV_TYPESYSTEM.EMPTY_TYPE), | ||
147 | 706 | FunctionConsts::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_TRUNCATE_1); | ||
148 | 707 | |||
149 | 708 | } | ||
150 | 709 | |||
151 | 710 | |||
152 | 711 | { | ||
153 | 712 | |||
154 | 713 | |||
155 | 689 | DECL_WITH_KIND(sctx, zorba_store_collections_static_dml_collection_name, | 714 | DECL_WITH_KIND(sctx, zorba_store_collections_static_dml_collection_name, |
156 | 690 | (createQName("http://www.zorba-xquery.com/modules/store/static/collections/dml","","collection-name"), | 715 | (createQName("http://www.zorba-xquery.com/modules/store/static/collections/dml","","collection-name"), |
157 | 691 | GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE, | 716 | GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE, |
158 | 692 | 717 | ||
159 | === modified file 'src/functions/pregenerated/func_collections.h' | |||
160 | --- src/functions/pregenerated/func_collections.h 2012-01-11 17:30:25 +0000 | |||
161 | +++ src/functions/pregenerated/func_collections.h 2012-03-08 01:45:23 +0000 | |||
162 | @@ -434,6 +434,25 @@ | |||
163 | 434 | }; | 434 | }; |
164 | 435 | 435 | ||
165 | 436 | 436 | ||
166 | 437 | //zorba-store-collections-static-dml:truncate | ||
167 | 438 | class zorba_store_collections_static_dml_truncate : public function | ||
168 | 439 | { | ||
169 | 440 | public: | ||
170 | 441 | zorba_store_collections_static_dml_truncate(const signature& sig, FunctionConsts::FunctionKind kind) | ||
171 | 442 | : | ||
172 | 443 | function(sig, kind) | ||
173 | 444 | { | ||
174 | 445 | |||
175 | 446 | } | ||
176 | 447 | |||
177 | 448 | short getScriptingKind() const { return UPDATING_EXPR; } | ||
178 | 449 | |||
179 | 450 | bool accessesDynCtx() const { return true; } | ||
180 | 451 | |||
181 | 452 | CODEGEN_DECL(); | ||
182 | 453 | }; | ||
183 | 454 | |||
184 | 455 | |||
185 | 437 | //zorba-store-collections-static-dml:collection-name | 456 | //zorba-store-collections-static-dml:collection-name |
186 | 438 | class zorba_store_collections_static_dml_collection_name : public function | 457 | class zorba_store_collections_static_dml_collection_name : public function |
187 | 439 | { | 458 | { |
188 | 440 | 459 | ||
189 | === modified file 'src/functions/pregenerated/function_enum.h' | |||
190 | --- src/functions/pregenerated/function_enum.h 2012-03-07 15:49:25 +0000 | |||
191 | +++ src/functions/pregenerated/function_enum.h 2012-03-08 01:45:23 +0000 | |||
192 | @@ -79,6 +79,8 @@ | |||
193 | 79 | ZORBA_STORE_COLLECTIONS_STATIC_DML_DELETE_NODES_LAST_2, | 79 | ZORBA_STORE_COLLECTIONS_STATIC_DML_DELETE_NODES_LAST_2, |
194 | 80 | ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_DELETE_NODE_LAST_1, | 80 | ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_DELETE_NODE_LAST_1, |
195 | 81 | ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_DELETE_NODES_LAST_2, | 81 | ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_DELETE_NODES_LAST_2, |
196 | 82 | ZORBA_STORE_COLLECTIONS_STATIC_DML_TRUNCATE_1, | ||
197 | 83 | ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_TRUNCATE_1, | ||
198 | 82 | ZORBA_STORE_COLLECTIONS_STATIC_DML_COLLECTION_NAME_1, | 84 | ZORBA_STORE_COLLECTIONS_STATIC_DML_COLLECTION_NAME_1, |
199 | 83 | ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_COLLECTION_NAME_1, | 85 | ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_COLLECTION_NAME_1, |
200 | 84 | ZORBA_STORE_COLLECTIONS_STATIC_DDL_IS_AVAILABLE_COLLECTION_1, | 86 | ZORBA_STORE_COLLECTIONS_STATIC_DDL_IS_AVAILABLE_COLLECTION_1, |
201 | 85 | 87 | ||
202 | === modified file 'src/runtime/collections/collections_impl.cpp' | |||
203 | --- src/runtime/collections/collections_impl.cpp 2012-02-16 12:48:17 +0000 | |||
204 | +++ src/runtime/collections/collections_impl.cpp 2012-03-08 01:45:23 +0000 | |||
205 | @@ -1796,6 +1796,93 @@ | |||
206 | 1796 | /******************************************************************************* | 1796 | /******************************************************************************* |
207 | 1797 | 1797 | ||
208 | 1798 | ********************************************************************************/ | 1798 | ********************************************************************************/ |
209 | 1799 | bool ZorbaTruncateCollectionIterator::nextImpl( | ||
210 | 1800 | store::Item_t& result, | ||
211 | 1801 | PlanState& planState) const | ||
212 | 1802 | { | ||
213 | 1803 | store::Collection_t collection; | ||
214 | 1804 | store::Item_t collectionName; | ||
215 | 1805 | std::auto_ptr<store::PUL> pul; | ||
216 | 1806 | |||
217 | 1807 | PlanIteratorState* state; | ||
218 | 1808 | DEFAULT_STACK_INIT(PlanIteratorState, state, planState); | ||
219 | 1809 | |||
220 | 1810 | consumeNext(collectionName, theChildren[0].getp(), planState); | ||
221 | 1811 | |||
222 | 1812 | (void)getCollection( | ||
223 | 1813 | theSctx, collectionName, loc, theDynamicCollection, collection); | ||
224 | 1814 | |||
225 | 1815 | // create the pul and add the primitive | ||
226 | 1816 | pul.reset(GENV_ITEMFACTORY->createPendingUpdateList()); | ||
227 | 1817 | |||
228 | 1818 | pul->addTruncateCollection(&loc, collectionName, theDynamicCollection); | ||
229 | 1819 | |||
230 | 1820 | result = pul.release(); | ||
231 | 1821 | STACK_PUSH( result != NULL, state); | ||
232 | 1822 | |||
233 | 1823 | STACK_END (state); | ||
234 | 1824 | } | ||
235 | 1825 | |||
236 | 1826 | /******************************************************************************* | ||
237 | 1827 | |||
238 | 1828 | ********************************************************************************/ | ||
239 | 1829 | const StaticallyKnownCollection* | ||
240 | 1830 | ZorbaTruncateCollectionIterator::getCollection( | ||
241 | 1831 | const static_context* aSctx, | ||
242 | 1832 | const store::Item_t& aName, | ||
243 | 1833 | const QueryLoc& aLoc, | ||
244 | 1834 | bool aDynamicCollection, | ||
245 | 1835 | store::Collection_t& coll) const | ||
246 | 1836 | { | ||
247 | 1837 | const StaticallyKnownCollection* collectionDecl = aSctx->lookup_collection(aName); | ||
248 | 1838 | if (collectionDecl == 0 && !aDynamicCollection) | ||
249 | 1839 | { | ||
250 | 1840 | throw XQUERY_EXCEPTION( | ||
251 | 1841 | zerr::ZDDY0001_COLLECTION_NOT_DECLARED, | ||
252 | 1842 | ERROR_PARAMS( aName->getStringValue() ), | ||
253 | 1843 | ERROR_LOC( aLoc ) | ||
254 | 1844 | ); | ||
255 | 1845 | } | ||
256 | 1846 | |||
257 | 1847 | if (!aDynamicCollection) | ||
258 | 1848 | { | ||
259 | 1849 | // checking collection update mode | ||
260 | 1850 | switch(collectionDecl->getUpdateProperty()) | ||
261 | 1851 | { | ||
262 | 1852 | case StaticContextConsts::decl_const: | ||
263 | 1853 | throw XQUERY_EXCEPTION( | ||
264 | 1854 | zerr::ZDDY0004_COLLECTION_CONST_UPDATE, | ||
265 | 1855 | ERROR_PARAMS( aName->getStringValue() ), | ||
266 | 1856 | ERROR_LOC( loc ) | ||
267 | 1857 | ); | ||
268 | 1858 | |||
269 | 1859 | case StaticContextConsts::decl_append_only: | ||
270 | 1860 | throw XQUERY_EXCEPTION( | ||
271 | 1861 | zerr::ZDDY0005_COLLECTION_APPEND_BAD_INSERT, | ||
272 | 1862 | ERROR_PARAMS( aName->getStringValue() ), | ||
273 | 1863 | ERROR_LOC( loc ) | ||
274 | 1864 | ); | ||
275 | 1865 | default: break; | ||
276 | 1866 | } | ||
277 | 1867 | } | ||
278 | 1868 | |||
279 | 1869 | coll = GENV_STORE.getCollection(aName, aDynamicCollection); | ||
280 | 1870 | |||
281 | 1871 | if (coll == NULL) | ||
282 | 1872 | { | ||
283 | 1873 | throw XQUERY_EXCEPTION( | ||
284 | 1874 | zerr::ZDDY0003_COLLECTION_DOES_NOT_EXIST, | ||
285 | 1875 | ERROR_PARAMS( aName->getStringValue() ), | ||
286 | 1876 | ERROR_LOC( aLoc ) | ||
287 | 1877 | ); | ||
288 | 1878 | } | ||
289 | 1879 | |||
290 | 1880 | return collectionDecl; | ||
291 | 1881 | } | ||
292 | 1882 | |||
293 | 1883 | /******************************************************************************* | ||
294 | 1884 | |||
295 | 1885 | ********************************************************************************/ | ||
296 | 1799 | bool ZorbaCollectionNameIterator::nextImpl( | 1886 | bool ZorbaCollectionNameIterator::nextImpl( |
297 | 1800 | store::Item_t& result, | 1887 | store::Item_t& result, |
298 | 1801 | PlanState& planState) const | 1888 | PlanState& planState) const |
299 | 1802 | 1889 | ||
300 | === modified file 'src/runtime/collections/pregenerated/collections.cpp' | |||
301 | --- src/runtime/collections/pregenerated/collections.cpp 2011-11-01 14:26:48 +0000 | |||
302 | +++ src/runtime/collections/pregenerated/collections.cpp 2012-03-08 01:45:23 +0000 | |||
303 | @@ -551,6 +551,34 @@ | |||
304 | 551 | // </ZorbaDeleteNodesLastIterator> | 551 | // </ZorbaDeleteNodesLastIterator> |
305 | 552 | 552 | ||
306 | 553 | 553 | ||
307 | 554 | // <ZorbaTruncateCollectionIterator> | ||
308 | 555 | const char* ZorbaTruncateCollectionIterator::class_name_str = "ZorbaTruncateCollectionIterator"; | ||
309 | 556 | ZorbaTruncateCollectionIterator::class_factory<ZorbaTruncateCollectionIterator> | ||
310 | 557 | ZorbaTruncateCollectionIterator::g_class_factory; | ||
311 | 558 | |||
312 | 559 | const serialization::ClassVersion | ||
313 | 560 | ZorbaTruncateCollectionIterator::class_versions[] ={{ 1, 0x000905, false}}; | ||
314 | 561 | |||
315 | 562 | const int ZorbaTruncateCollectionIterator::class_versions_count = | ||
316 | 563 | sizeof(ZorbaTruncateCollectionIterator::class_versions)/sizeof(struct serialization::ClassVersion); | ||
317 | 564 | |||
318 | 565 | void ZorbaTruncateCollectionIterator::accept(PlanIterVisitor& v) const { | ||
319 | 566 | v.beginVisit(*this); | ||
320 | 567 | |||
321 | 568 | std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); | ||
322 | 569 | std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); | ||
323 | 570 | for ( ; lIter != lEnd; ++lIter ){ | ||
324 | 571 | (*lIter)->accept(v); | ||
325 | 572 | } | ||
326 | 573 | |||
327 | 574 | v.endVisit(*this); | ||
328 | 575 | } | ||
329 | 576 | |||
330 | 577 | ZorbaTruncateCollectionIterator::~ZorbaTruncateCollectionIterator() {} | ||
331 | 578 | |||
332 | 579 | // </ZorbaTruncateCollectionIterator> | ||
333 | 580 | |||
334 | 581 | |||
335 | 554 | // <ZorbaCollectionNameIterator> | 582 | // <ZorbaCollectionNameIterator> |
336 | 555 | const char* ZorbaCollectionNameIterator::class_name_str = "ZorbaCollectionNameIterator"; | 583 | const char* ZorbaCollectionNameIterator::class_name_str = "ZorbaCollectionNameIterator"; |
337 | 556 | ZorbaCollectionNameIterator::class_factory<ZorbaCollectionNameIterator> | 584 | ZorbaCollectionNameIterator::class_factory<ZorbaCollectionNameIterator> |
338 | 557 | 585 | ||
339 | === modified file 'src/runtime/collections/pregenerated/collections.h' | |||
340 | --- src/runtime/collections/pregenerated/collections.h 2011-11-01 14:26:48 +0000 | |||
341 | +++ src/runtime/collections/pregenerated/collections.h 2012-03-08 01:45:23 +0000 | |||
342 | @@ -865,6 +865,50 @@ | |||
343 | 865 | 865 | ||
344 | 866 | /** | 866 | /** |
345 | 867 | * | 867 | * |
346 | 868 | * zorba:truncate | ||
347 | 869 | * | ||
348 | 870 | * Author: Zorba Team | ||
349 | 871 | */ | ||
350 | 872 | class ZorbaTruncateCollectionIterator : public NaryBaseIterator<ZorbaTruncateCollectionIterator, PlanIteratorState> | ||
351 | 873 | { | ||
352 | 874 | protected: | ||
353 | 875 | bool theDynamicCollection; //whether it's the function of the dynamic or the static collection module | ||
354 | 876 | public: | ||
355 | 877 | SERIALIZABLE_CLASS(ZorbaTruncateCollectionIterator); | ||
356 | 878 | |||
357 | 879 | SERIALIZABLE_CLASS_CONSTRUCTOR2T(ZorbaTruncateCollectionIterator, | ||
358 | 880 | NaryBaseIterator<ZorbaTruncateCollectionIterator, PlanIteratorState>); | ||
359 | 881 | |||
360 | 882 | void serialize( ::zorba::serialization::Archiver& ar) | ||
361 | 883 | { | ||
362 | 884 | serialize_baseclass(ar, | ||
363 | 885 | (NaryBaseIterator<ZorbaTruncateCollectionIterator, PlanIteratorState>*)this); | ||
364 | 886 | |||
365 | 887 | ar & theDynamicCollection; | ||
366 | 888 | } | ||
367 | 889 | |||
368 | 890 | ZorbaTruncateCollectionIterator( | ||
369 | 891 | static_context* sctx, | ||
370 | 892 | const QueryLoc& loc, | ||
371 | 893 | std::vector<PlanIter_t>& children, | ||
372 | 894 | bool aDynamicCollection) | ||
373 | 895 | : | ||
374 | 896 | NaryBaseIterator<ZorbaTruncateCollectionIterator, PlanIteratorState>(sctx, loc, children), | ||
375 | 897 | theDynamicCollection(aDynamicCollection) | ||
376 | 898 | {} | ||
377 | 899 | |||
378 | 900 | virtual ~ZorbaTruncateCollectionIterator(); | ||
379 | 901 | |||
380 | 902 | public: | ||
381 | 903 | const StaticallyKnownCollection* getCollection(const static_context* sctx, const store::Item_t& name, const QueryLoc& loc, bool dyn_coll, store::Collection_t& coll) const; | ||
382 | 904 | void accept(PlanIterVisitor& v) const; | ||
383 | 905 | |||
384 | 906 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; | ||
385 | 907 | }; | ||
386 | 908 | |||
387 | 909 | |||
388 | 910 | /** | ||
389 | 911 | * | ||
390 | 868 | * zorba:collection-name | 912 | * zorba:collection-name |
391 | 869 | * | 913 | * |
392 | 870 | * Author: Zorba Team | 914 | * Author: Zorba Team |
393 | 871 | 915 | ||
394 | === modified file 'src/runtime/core/apply_updates.cpp' | |||
395 | --- src/runtime/core/apply_updates.cpp 2011-08-17 18:55:07 +0000 | |||
396 | +++ src/runtime/core/apply_updates.cpp 2012-03-08 01:45:23 +0000 | |||
397 | @@ -141,12 +141,13 @@ | |||
398 | 141 | SchemaValidatorImpl validator(loc, sctx); | 141 | SchemaValidatorImpl validator(loc, sctx); |
399 | 142 | ICCheckerImpl icChecker(sctx, gdctx); | 142 | ICCheckerImpl icChecker(sctx, gdctx); |
400 | 143 | std::vector<store::Index*> indexes; | 143 | std::vector<store::Index*> indexes; |
401 | 144 | std::vector<store::Index*> truncate_indexes; | ||
402 | 144 | store::ItemHandle<store::PUL> indexPul; | 145 | store::ItemHandle<store::PUL> indexPul; |
403 | 145 | 146 | ||
404 | 146 | // Get all the indexes that are associated with any of the collections that | 147 | // Get all the indexes that are associated with any of the collections that |
405 | 147 | // are going to be updated by this pul. Check which of those indices can be | 148 | // are going to be updated by this pul. Check which of those indices can be |
406 | 148 | // maintained incrementally, and pass this info back to the pul. | 149 | // maintained incrementally, and pass this info back to the pul. |
408 | 149 | pul->getIndicesToRefresh(indexes); | 150 | pul->getIndicesToRefresh(indexes, truncate_indexes); |
409 | 150 | 151 | ||
410 | 151 | ulong numIndices = (ulong)indexes.size(); | 152 | ulong numIndices = (ulong)indexes.size(); |
411 | 152 | 153 | ||
412 | @@ -178,6 +179,17 @@ | |||
413 | 178 | zorbaIndexes[i] = indexDecl; | 179 | zorbaIndexes[i] = indexDecl; |
414 | 179 | } | 180 | } |
415 | 180 | 181 | ||
416 | 182 | numIndices = (ulong)truncate_indexes.size(); | ||
417 | 183 | for (ulong i = 0; i < numIndices; ++i) | ||
418 | 184 | { | ||
419 | 185 | IndexDecl* indexDecl = sctx->lookup_index(indexes[i]->getName()); | ||
420 | 186 | |||
421 | 187 | if (indexDecl->getMaintenanceMode() == IndexDecl::DOC_MAP) | ||
422 | 188 | { | ||
423 | 189 | pul->addIndexTruncator(indexDecl->getSourceName(0), indexes[i]); | ||
424 | 190 | } | ||
425 | 191 | } | ||
426 | 192 | |||
427 | 181 | try | 193 | try |
428 | 182 | { | 194 | { |
429 | 183 | // Apply updates | 195 | // Apply updates |
430 | 184 | 196 | ||
431 | === modified file 'src/runtime/spec/collections/collections.xml' | |||
432 | --- src/runtime/spec/collections/collections.xml 2012-01-11 17:30:25 +0000 | |||
433 | +++ src/runtime/spec/collections/collections.xml 2012-03-08 01:45:23 +0000 | |||
434 | @@ -924,6 +924,52 @@ | |||
435 | 924 | /******************************************************************************* | 924 | /******************************************************************************* |
436 | 925 | ********************************************************************************/ | 925 | ********************************************************************************/ |
437 | 926 | --> | 926 | --> |
438 | 927 | <zorba:iterator name="ZorbaTruncateCollectionIterator" > | ||
439 | 928 | |||
440 | 929 | <zorba:description author="Zorba Team"> | ||
441 | 930 | zorba:truncate | ||
442 | 931 | </zorba:description> | ||
443 | 932 | |||
444 | 933 | <zorba:function generateCodegen="false"> | ||
445 | 934 | |||
446 | 935 | <zorba:signature localname="truncate" prefix="zorba-store-collections-static-dml"> | ||
447 | 936 | <zorba:param>xs:QName</zorba:param> | ||
448 | 937 | <zorba:output>empty-sequence()</zorba:output> | ||
449 | 938 | </zorba:signature> | ||
450 | 939 | |||
451 | 940 | <zorba:signature localname="truncate" prefix="zorba-store-dynamic-collections-dml"> | ||
452 | 941 | <zorba:param>xs:QName</zorba:param> | ||
453 | 942 | <zorba:output>empty-sequence()</zorba:output> | ||
454 | 943 | </zorba:signature> | ||
455 | 944 | |||
456 | 945 | <zorba:methods> | ||
457 | 946 | <zorba:getScriptingKind returnValue="UPDATING_EXPR"/> | ||
458 | 947 | <zorba:accessesDynCtx returnValue="true"/> | ||
459 | 948 | </zorba:methods> | ||
460 | 949 | |||
461 | 950 | </zorba:function> | ||
462 | 951 | |||
463 | 952 | <zorba:constructor> | ||
464 | 953 | <zorba:parameter type="bool" name="aDynamicCollection" /> | ||
465 | 954 | </zorba:constructor> | ||
466 | 955 | |||
467 | 956 | <zorba:member type="bool" name="theDynamicCollection" | ||
468 | 957 | brief="whether it's the function of the dynamic or the static collection module"/> | ||
469 | 958 | |||
470 | 959 | <zorba:method const="true" name="getCollection" return="const StaticallyKnownCollection*"> | ||
471 | 960 | <zorba:param type="const static_context*" name="sctx"/> | ||
472 | 961 | <zorba:param type="const store::Item_t&" name="name"/> | ||
473 | 962 | <zorba:param type="const QueryLoc&" name="loc"/> | ||
474 | 963 | <zorba:param type="bool" name="dyn_coll"/> | ||
475 | 964 | <zorba:param type="store::Collection_t&" name="coll"/> | ||
476 | 965 | </zorba:method> | ||
477 | 966 | </zorba:iterator> | ||
478 | 967 | |||
479 | 968 | |||
480 | 969 | <!-- | ||
481 | 970 | /******************************************************************************* | ||
482 | 971 | ********************************************************************************/ | ||
483 | 972 | --> | ||
484 | 927 | <zorba:iterator name="ZorbaCollectionNameIterator" > | 973 | <zorba:iterator name="ZorbaCollectionNameIterator" > |
485 | 928 | 974 | ||
486 | 929 | <zorba:description author="Zorba Team"> | 975 | <zorba:description author="Zorba Team"> |
487 | 930 | 976 | ||
488 | === modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h' | |||
489 | --- src/runtime/visitors/pregenerated/planiter_visitor.h 2012-03-07 15:49:25 +0000 | |||
490 | +++ src/runtime/visitors/pregenerated/planiter_visitor.h 2012-03-08 01:45:23 +0000 | |||
491 | @@ -92,6 +92,8 @@ | |||
492 | 92 | 92 | ||
493 | 93 | class ZorbaDeleteNodesLastIterator; | 93 | class ZorbaDeleteNodesLastIterator; |
494 | 94 | 94 | ||
495 | 95 | class ZorbaTruncateCollectionIterator; | ||
496 | 96 | |||
497 | 95 | class ZorbaCollectionNameIterator; | 97 | class ZorbaCollectionNameIterator; |
498 | 96 | 98 | ||
499 | 97 | class IsAvailableCollectionIterator; | 99 | class IsAvailableCollectionIterator; |
500 | @@ -697,6 +699,9 @@ | |||
501 | 697 | virtual void beginVisit ( const ZorbaDeleteNodesLastIterator& ) = 0; | 699 | virtual void beginVisit ( const ZorbaDeleteNodesLastIterator& ) = 0; |
502 | 698 | virtual void endVisit ( const ZorbaDeleteNodesLastIterator& ) = 0; | 700 | virtual void endVisit ( const ZorbaDeleteNodesLastIterator& ) = 0; |
503 | 699 | 701 | ||
504 | 702 | virtual void beginVisit ( const ZorbaTruncateCollectionIterator& ) = 0; | ||
505 | 703 | virtual void endVisit ( const ZorbaTruncateCollectionIterator& ) = 0; | ||
506 | 704 | |||
507 | 700 | virtual void beginVisit ( const ZorbaCollectionNameIterator& ) = 0; | 705 | virtual void beginVisit ( const ZorbaCollectionNameIterator& ) = 0; |
508 | 701 | virtual void endVisit ( const ZorbaCollectionNameIterator& ) = 0; | 706 | virtual void endVisit ( const ZorbaCollectionNameIterator& ) = 0; |
509 | 702 | 707 | ||
510 | 703 | 708 | ||
511 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' | |||
512 | --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-03-07 15:49:25 +0000 | |||
513 | +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2012-03-08 01:45:23 +0000 | |||
514 | @@ -545,6 +545,20 @@ | |||
515 | 545 | // </ZorbaDeleteNodesLastIterator> | 545 | // </ZorbaDeleteNodesLastIterator> |
516 | 546 | 546 | ||
517 | 547 | 547 | ||
518 | 548 | // <ZorbaTruncateCollectionIterator> | ||
519 | 549 | void PrinterVisitor::beginVisit ( const ZorbaTruncateCollectionIterator& a) { | ||
520 | 550 | thePrinter.startBeginVisit("ZorbaTruncateCollectionIterator", ++theId); | ||
521 | 551 | printCommons( &a, theId ); | ||
522 | 552 | thePrinter.endBeginVisit( theId ); | ||
523 | 553 | } | ||
524 | 554 | |||
525 | 555 | void PrinterVisitor::endVisit ( const ZorbaTruncateCollectionIterator& ) { | ||
526 | 556 | thePrinter.startEndVisit(); | ||
527 | 557 | thePrinter.endEndVisit(); | ||
528 | 558 | } | ||
529 | 559 | // </ZorbaTruncateCollectionIterator> | ||
530 | 560 | |||
531 | 561 | |||
532 | 548 | // <ZorbaCollectionNameIterator> | 562 | // <ZorbaCollectionNameIterator> |
533 | 549 | void PrinterVisitor::beginVisit ( const ZorbaCollectionNameIterator& a) { | 563 | void PrinterVisitor::beginVisit ( const ZorbaCollectionNameIterator& a) { |
534 | 550 | thePrinter.startBeginVisit("ZorbaCollectionNameIterator", ++theId); | 564 | thePrinter.startBeginVisit("ZorbaCollectionNameIterator", ++theId); |
535 | 551 | 565 | ||
536 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.h' | |||
537 | --- src/runtime/visitors/pregenerated/printer_visitor.h 2012-03-07 15:49:25 +0000 | |||
538 | +++ src/runtime/visitors/pregenerated/printer_visitor.h 2012-03-08 01:45:23 +0000 | |||
539 | @@ -140,6 +140,9 @@ | |||
540 | 140 | void beginVisit( const ZorbaDeleteNodesLastIterator& ); | 140 | void beginVisit( const ZorbaDeleteNodesLastIterator& ); |
541 | 141 | void endVisit ( const ZorbaDeleteNodesLastIterator& ); | 141 | void endVisit ( const ZorbaDeleteNodesLastIterator& ); |
542 | 142 | 142 | ||
543 | 143 | void beginVisit( const ZorbaTruncateCollectionIterator& ); | ||
544 | 144 | void endVisit ( const ZorbaTruncateCollectionIterator& ); | ||
545 | 145 | |||
546 | 143 | void beginVisit( const ZorbaCollectionNameIterator& ); | 146 | void beginVisit( const ZorbaCollectionNameIterator& ); |
547 | 144 | void endVisit ( const ZorbaCollectionNameIterator& ); | 147 | void endVisit ( const ZorbaCollectionNameIterator& ); |
548 | 145 | 148 | ||
549 | 146 | 149 | ||
550 | === modified file 'src/store/api/pul.h' | |||
551 | --- src/store/api/pul.h 2011-10-12 20:59:49 +0000 | |||
552 | +++ src/store/api/pul.h 2012-03-08 01:45:23 +0000 | |||
553 | @@ -203,6 +203,11 @@ | |||
554 | 203 | bool isLast, | 203 | bool isLast, |
555 | 204 | bool dyn_collection = false) = 0; | 204 | bool dyn_collection = false) = 0; |
556 | 205 | 205 | ||
557 | 206 | virtual void addTruncateCollection( | ||
558 | 207 | const QueryLoc* aQueryLoc, | ||
559 | 208 | Item_t& name, | ||
560 | 209 | bool dyn_collection = false) = 0; | ||
561 | 210 | |||
562 | 206 | // functions to add primitives for indexes | 211 | // functions to add primitives for indexes |
563 | 207 | 212 | ||
564 | 208 | virtual void addCreateIndex( | 213 | virtual void addCreateIndex( |
565 | @@ -281,13 +286,18 @@ | |||
566 | 281 | 286 | ||
567 | 282 | // utils | 287 | // utils |
568 | 283 | virtual void getIndicesToRefresh( | 288 | virtual void getIndicesToRefresh( |
570 | 284 | std::vector<Index*>& indices) = 0; | 289 | std::vector<Index*>& indices, |
571 | 290 | std::vector<Index*>& truncate_indices) = 0; | ||
572 | 285 | 291 | ||
573 | 286 | virtual void addIndexEntryCreator( | 292 | virtual void addIndexEntryCreator( |
574 | 287 | const Item* collectionName, | 293 | const Item* collectionName, |
575 | 288 | Index* idx, | 294 | Index* idx, |
576 | 289 | IndexEntryCreator* creator) = 0; | 295 | IndexEntryCreator* creator) = 0; |
577 | 290 | 296 | ||
578 | 297 | virtual void addIndexTruncator( | ||
579 | 298 | const store::Item* collectionName, | ||
580 | 299 | Index* idx) = 0; | ||
581 | 300 | |||
582 | 291 | virtual void setValidator( | 301 | virtual void setValidator( |
583 | 292 | SchemaValidator* validator) = 0; | 302 | SchemaValidator* validator) = 0; |
584 | 293 | 303 | ||
585 | 294 | 304 | ||
586 | === modified file 'src/store/api/update_consts.h' | |||
587 | --- src/store/api/update_consts.h 2012-01-11 17:30:25 +0000 | |||
588 | +++ src/store/api/update_consts.h 2012-03-08 01:45:23 +0000 | |||
589 | @@ -81,6 +81,7 @@ | |||
590 | 81 | UP_INSERT_AT_INTO_COLLECTION, | 81 | UP_INSERT_AT_INTO_COLLECTION, |
591 | 82 | UP_REMOVE_FROM_COLLECTION, | 82 | UP_REMOVE_FROM_COLLECTION, |
592 | 83 | UP_REMOVE_AT_FROM_COLLECTION, | 83 | UP_REMOVE_AT_FROM_COLLECTION, |
593 | 84 | UP_TRUNCATE_COLLECTION, | ||
594 | 84 | 85 | ||
595 | 85 | // index primitives | 86 | // index primitives |
596 | 86 | UP_CREATE_INDEX, | 87 | UP_CREATE_INDEX, |
597 | @@ -177,6 +178,8 @@ | |||
598 | 177 | return "insertAtIntoCollection"; | 178 | return "insertAtIntoCollection"; |
599 | 178 | case UP_REMOVE_FROM_COLLECTION: | 179 | case UP_REMOVE_FROM_COLLECTION: |
600 | 179 | return "removeFromCollection"; | 180 | return "removeFromCollection"; |
601 | 181 | case UP_TRUNCATE_COLLECTION: | ||
602 | 182 | return "truncateCollection"; | ||
603 | 180 | case UP_REMOVE_AT_FROM_COLLECTION: | 183 | case UP_REMOVE_AT_FROM_COLLECTION: |
604 | 181 | return "removeAtFromCollection"; | 184 | return "removeAtFromCollection"; |
605 | 182 | case UP_CREATE_INDEX: | 185 | case UP_CREATE_INDEX: |
606 | 183 | 186 | ||
607 | === modified file 'src/store/naive/pul_primitive_factory.cpp' | |||
608 | --- src/store/naive/pul_primitive_factory.cpp 2012-03-07 14:22:29 +0000 | |||
609 | +++ src/store/naive/pul_primitive_factory.cpp 2012-03-08 01:45:23 +0000 | |||
610 | @@ -376,6 +376,18 @@ | |||
611 | 376 | return new UpdDeleteNodesFromCollection(pul, aLoc, name, nodes, isLast, dyn_collection); | 376 | return new UpdDeleteNodesFromCollection(pul, aLoc, name, nodes, isLast, dyn_collection); |
612 | 377 | } | 377 | } |
613 | 378 | 378 | ||
614 | 379 | |||
615 | 380 | /*************************************************************************** | ||
616 | 381 | ***************************************************************************/ | ||
617 | 382 | UpdTruncateCollection* | ||
618 | 383 | PULPrimitiveFactory::createUpdTruncateCollection( | ||
619 | 384 | CollectionPul* pul, | ||
620 | 385 | const QueryLoc* aLoc, | ||
621 | 386 | store::Item_t& name, | ||
622 | 387 | bool dyn_collection) | ||
623 | 388 | { | ||
624 | 389 | return new UpdTruncateCollection(pul, aLoc, name, dyn_collection); | ||
625 | 390 | } | ||
626 | 379 | 391 | ||
627 | 380 | /*************************************************************************** | 392 | /*************************************************************************** |
628 | 381 | ***************************************************************************/ | 393 | ***************************************************************************/ |
629 | 382 | 394 | ||
630 | === modified file 'src/store/naive/pul_primitive_factory.h' | |||
631 | --- src/store/naive/pul_primitive_factory.h 2012-02-28 20:45:43 +0000 | |||
632 | +++ src/store/naive/pul_primitive_factory.h 2012-03-08 01:45:23 +0000 | |||
633 | @@ -50,6 +50,7 @@ | |||
634 | 50 | class UpdInsertBeforeIntoCollection; | 50 | class UpdInsertBeforeIntoCollection; |
635 | 51 | class UpdInsertAfterIntoCollection; | 51 | class UpdInsertAfterIntoCollection; |
636 | 52 | class UpdDeleteNodesFromCollection; | 52 | class UpdDeleteNodesFromCollection; |
637 | 53 | class UpdTruncateCollection; | ||
638 | 53 | class UpdCreateIndex; | 54 | class UpdCreateIndex; |
639 | 54 | class UpdDeleteIndex; | 55 | class UpdDeleteIndex; |
640 | 55 | class UpdRefreshIndex; | 56 | class UpdRefreshIndex; |
641 | @@ -311,6 +312,15 @@ | |||
642 | 311 | std::vector<store::Item_t>& nodes, | 312 | std::vector<store::Item_t>& nodes, |
643 | 312 | bool isLast, | 313 | bool isLast, |
644 | 313 | bool dyn_collection = false); | 314 | bool dyn_collection = false); |
645 | 315 | |||
646 | 316 | /*************************************************************************** | ||
647 | 317 | ***************************************************************************/ | ||
648 | 318 | virtual UpdTruncateCollection* | ||
649 | 319 | createUpdTruncateCollection( | ||
650 | 320 | CollectionPul* pul, | ||
651 | 321 | const QueryLoc*, | ||
652 | 322 | store::Item_t& name, | ||
653 | 323 | bool dyn_collection = false); | ||
654 | 314 | 324 | ||
655 | 315 | /*************************************************************************** | 325 | /*************************************************************************** |
656 | 316 | ***************************************************************************/ | 326 | ***************************************************************************/ |
657 | 317 | 327 | ||
658 | === modified file 'src/store/naive/pul_primitives.cpp' | |||
659 | --- src/store/naive/pul_primitives.cpp 2012-03-07 14:22:29 +0000 | |||
660 | +++ src/store/naive/pul_primitives.cpp 2012-03-08 01:45:23 +0000 | |||
661 | @@ -1276,6 +1276,36 @@ | |||
662 | 1276 | } | 1276 | } |
663 | 1277 | 1277 | ||
664 | 1278 | 1278 | ||
665 | 1279 | /******************************************************************************* | ||
666 | 1280 | UpdTruncateCollection | ||
667 | 1281 | ********************************************************************************/ | ||
668 | 1282 | void UpdTruncateCollection::apply() | ||
669 | 1283 | { | ||
670 | 1284 | SimpleCollection* lColl = static_cast<SimpleCollection*> | ||
671 | 1285 | (GET_STORE().getCollection(theName, theDynamicCollection).getp()); | ||
672 | 1286 | assert(lColl); | ||
673 | 1287 | |||
674 | 1288 | lColl->theXmlTrees.swap(theTrees); | ||
675 | 1289 | |||
676 | 1290 | theIsApplied = true; | ||
677 | 1291 | |||
678 | 1292 | } | ||
679 | 1293 | |||
680 | 1294 | void UpdTruncateCollection::undo() | ||
681 | 1295 | { | ||
682 | 1296 | if (!theIsApplied) return; | ||
683 | 1297 | |||
684 | 1298 | SimpleCollection* lColl = static_cast<SimpleCollection*> | ||
685 | 1299 | (GET_STORE().getCollection(theName, theDynamicCollection).getp()); | ||
686 | 1300 | assert(lColl); | ||
687 | 1301 | |||
688 | 1302 | lColl->theXmlTrees.clear(); | ||
689 | 1303 | |||
690 | 1304 | theTrees.swap(lColl->theXmlTrees); | ||
691 | 1305 | |||
692 | 1306 | theIsApplied = false; | ||
693 | 1307 | } | ||
694 | 1308 | |||
695 | 1279 | 1309 | ||
696 | 1280 | ///////////////////////////////////////////////////////////////////////////////// | 1310 | ///////////////////////////////////////////////////////////////////////////////// |
697 | 1281 | // // | 1311 | // // |
698 | 1282 | 1312 | ||
699 | === modified file 'src/store/naive/pul_primitives.h' | |||
700 | --- src/store/naive/pul_primitives.h 2012-02-28 20:45:43 +0000 | |||
701 | +++ src/store/naive/pul_primitives.h 2012-03-08 01:45:23 +0000 | |||
702 | @@ -1210,6 +1210,37 @@ | |||
703 | 1210 | }; | 1210 | }; |
704 | 1211 | 1211 | ||
705 | 1212 | 1212 | ||
706 | 1213 | /******************************************************************************* | ||
707 | 1214 | |||
708 | 1215 | ********************************************************************************/ | ||
709 | 1216 | class UpdTruncateCollection: public UpdCollection | ||
710 | 1217 | { | ||
711 | 1218 | friend class PULPrimitiveFactory; | ||
712 | 1219 | |||
713 | 1220 | protected: | ||
714 | 1221 | std::vector<store::Item_t> theTrees; // needed for undo only | ||
715 | 1222 | |||
716 | 1223 | UpdTruncateCollection( | ||
717 | 1224 | CollectionPul* pul, | ||
718 | 1225 | const QueryLoc* aLoc, | ||
719 | 1226 | store::Item_t& name, | ||
720 | 1227 | bool dyn_collection) | ||
721 | 1228 | : | ||
722 | 1229 | UpdCollection(pul, aLoc, name, dyn_collection) | ||
723 | 1230 | { | ||
724 | 1231 | } | ||
725 | 1232 | |||
726 | 1233 | public: | ||
727 | 1234 | store::UpdateConsts::UpdPrimKind getKind() const | ||
728 | 1235 | { | ||
729 | 1236 | return store::UpdateConsts::UP_TRUNCATE_COLLECTION; | ||
730 | 1237 | } | ||
731 | 1238 | |||
732 | 1239 | void apply(); | ||
733 | 1240 | void undo(); | ||
734 | 1241 | }; | ||
735 | 1242 | |||
736 | 1243 | |||
737 | 1213 | ///////////////////////////////////////////////////////////////////////////////// | 1244 | ///////////////////////////////////////////////////////////////////////////////// |
738 | 1214 | // // | 1245 | // // |
739 | 1215 | // Index Primitives // | 1246 | // Index Primitives // |
740 | 1216 | 1247 | ||
741 | === modified file 'src/store/naive/simple_collection.h' | |||
742 | --- src/store/naive/simple_collection.h 2012-03-07 14:22:29 +0000 | |||
743 | +++ src/store/naive/simple_collection.h 2012-03-08 01:45:23 +0000 | |||
744 | @@ -41,6 +41,7 @@ | |||
745 | 41 | class SimpleCollection : public Collection | 41 | class SimpleCollection : public Collection |
746 | 42 | { | 42 | { |
747 | 43 | friend class CollectionIter; | 43 | friend class CollectionIter; |
748 | 44 | friend class UpdTruncateCollection; | ||
749 | 44 | 45 | ||
750 | 45 | public: | 46 | public: |
751 | 46 | class CollectionIter : public store::Iterator | 47 | class CollectionIter : public store::Iterator |
752 | 47 | 48 | ||
753 | === modified file 'src/store/naive/simple_index.h' | |||
754 | --- src/store/naive/simple_index.h 2012-01-11 17:30:25 +0000 | |||
755 | +++ src/store/naive/simple_index.h 2012-03-08 01:45:23 +0000 | |||
756 | @@ -69,6 +69,8 @@ | |||
757 | 69 | 69 | ||
758 | 70 | virtual KeyIterator_t keys() const = 0; | 70 | virtual KeyIterator_t keys() const = 0; |
759 | 71 | 71 | ||
760 | 72 | virtual void clear() = 0; | ||
761 | 73 | |||
762 | 72 | store::IndexCondition_t createCondition(store::IndexCondition::Kind k); | 74 | store::IndexCondition_t createCondition(store::IndexCondition::Kind k); |
763 | 73 | 75 | ||
764 | 74 | // | 76 | // |
765 | 75 | 77 | ||
766 | === modified file 'src/store/naive/simple_index_general.cpp' | |||
767 | --- src/store/naive/simple_index_general.cpp 2012-02-15 10:25:02 +0000 | |||
768 | +++ src/store/naive/simple_index_general.cpp 2012-03-08 01:45:23 +0000 | |||
769 | @@ -755,6 +755,26 @@ | |||
770 | 755 | } | 755 | } |
771 | 756 | 756 | ||
772 | 757 | 757 | ||
773 | 758 | /****************************************************************************** | ||
774 | 759 | |||
775 | 760 | *******************************************************************************/ | ||
776 | 761 | void GeneralHashIndex::clear() | ||
777 | 762 | { | ||
778 | 763 | for (ulong i = 0; i < store::XS_LAST; ++i) | ||
779 | 764 | { | ||
780 | 765 | if (theMaps[i] == NULL) | ||
781 | 766 | continue; | ||
782 | 767 | |||
783 | 768 | theMaps[i]->clear(); | ||
784 | 769 | } | ||
785 | 770 | |||
786 | 771 | if (isTyped()) | ||
787 | 772 | { | ||
788 | 773 | theSingleMap->clear(); | ||
789 | 774 | } | ||
790 | 775 | } | ||
791 | 776 | |||
792 | 777 | |||
793 | 758 | ///////////////////////////////////////////////////////////////////////////////// | 778 | ///////////////////////////////////////////////////////////////////////////////// |
794 | 759 | // // | 779 | // // |
795 | 760 | // GeneralHashIndex::KeyIterator // | 780 | // GeneralHashIndex::KeyIterator // |
796 | @@ -912,6 +932,26 @@ | |||
797 | 912 | /****************************************************************************** | 932 | /****************************************************************************** |
798 | 913 | 933 | ||
799 | 914 | *******************************************************************************/ | 934 | *******************************************************************************/ |
800 | 935 | void GeneralTreeIndex::clear() | ||
801 | 936 | { | ||
802 | 937 | for (ulong i = 0; i < store::XS_LAST; ++i) | ||
803 | 938 | { | ||
804 | 939 | if (theMaps[i] == NULL) | ||
805 | 940 | continue; | ||
806 | 941 | |||
807 | 942 | theMaps[i]->clear(); | ||
808 | 943 | } | ||
809 | 944 | |||
810 | 945 | if (isTyped()) | ||
811 | 946 | { | ||
812 | 947 | theSingleMap->clear(); | ||
813 | 948 | } | ||
814 | 949 | } | ||
815 | 950 | |||
816 | 951 | |||
817 | 952 | /****************************************************************************** | ||
818 | 953 | |||
819 | 954 | *******************************************************************************/ | ||
820 | 915 | store::Index::KeyIterator_t GeneralTreeIndex::keys() const | 955 | store::Index::KeyIterator_t GeneralTreeIndex::keys() const |
821 | 916 | { | 956 | { |
822 | 917 | return 0; | 957 | return 0; |
823 | 918 | 958 | ||
824 | === modified file 'src/store/naive/simple_index_general.h' | |||
825 | --- src/store/naive/simple_index_general.h 2012-02-28 20:45:43 +0000 | |||
826 | +++ src/store/naive/simple_index_general.h 2012-03-08 01:45:23 +0000 | |||
827 | @@ -238,6 +238,8 @@ | |||
828 | 238 | Index::KeyIterator_t keys() const; | 238 | Index::KeyIterator_t keys() const; |
829 | 239 | 239 | ||
830 | 240 | bool remove(const store::Item_t& key, store::Item_t& item, bool); | 240 | bool remove(const store::Item_t& key, store::Item_t& item, bool); |
831 | 241 | |||
832 | 242 | void clear(); | ||
833 | 241 | }; | 243 | }; |
834 | 242 | 244 | ||
835 | 243 | 245 | ||
836 | @@ -291,6 +293,8 @@ | |||
837 | 291 | Index::KeyIterator_t keys() const; | 293 | Index::KeyIterator_t keys() const; |
838 | 292 | 294 | ||
839 | 293 | bool remove(const store::Item_t& key, store::Item_t& item, bool all); | 295 | bool remove(const store::Item_t& key, store::Item_t& item, bool all); |
840 | 296 | |||
841 | 297 | void clear(); | ||
842 | 294 | }; | 298 | }; |
843 | 295 | 299 | ||
844 | 296 | 300 | ||
845 | 297 | 301 | ||
846 | === modified file 'src/store/naive/simple_pul.cpp' | |||
847 | --- src/store/naive/simple_pul.cpp 2012-03-07 14:22:29 +0000 | |||
848 | +++ src/store/naive/simple_pul.cpp 2012-03-08 01:45:23 +0000 | |||
849 | @@ -944,6 +944,17 @@ | |||
850 | 944 | } | 944 | } |
851 | 945 | 945 | ||
852 | 946 | 946 | ||
853 | 947 | void PULImpl::addTruncateCollection( | ||
854 | 948 | const QueryLoc* aQueryLoc, | ||
855 | 949 | store::Item_t& name, | ||
856 | 950 | bool dyn_collection) | ||
857 | 951 | { | ||
858 | 952 | CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection); | ||
859 | 953 | |||
860 | 954 | pul->theTruncateCollectionList.push_back( | ||
861 | 955 | GET_PUL_FACTORY().createUpdTruncateCollection(pul, aQueryLoc, name, dyn_collection)); | ||
862 | 956 | } | ||
863 | 957 | |||
864 | 947 | /******************************************************************************* | 958 | /******************************************************************************* |
865 | 948 | Index primitives | 959 | Index primitives |
866 | 949 | ********************************************************************************/ | 960 | ********************************************************************************/ |
867 | @@ -1157,6 +1168,11 @@ | |||
868 | 1157 | UP_LIST_NONE); | 1168 | UP_LIST_NONE); |
869 | 1158 | 1169 | ||
870 | 1159 | mergeUpdateList(thisPul, | 1170 | mergeUpdateList(thisPul, |
871 | 1171 | thisPul->theTruncateCollectionList, | ||
872 | 1172 | otherPul->theTruncateCollectionList, | ||
873 | 1173 | UP_LIST_NONE); | ||
874 | 1174 | |||
875 | 1175 | mergeUpdateList(thisPul, | ||
876 | 1160 | thisPul->theDeleteCollectionList, | 1176 | thisPul->theDeleteCollectionList, |
877 | 1161 | otherPul->theDeleteCollectionList, | 1177 | otherPul->theDeleteCollectionList, |
878 | 1162 | UP_LIST_NONE); | 1178 | UP_LIST_NONE); |
879 | @@ -1502,7 +1518,9 @@ | |||
880 | 1502 | This method is invoked by the ApplyIterator before any of the pul primitives | 1518 | This method is invoked by the ApplyIterator before any of the pul primitives |
881 | 1503 | is applied. | 1519 | is applied. |
882 | 1504 | ********************************************************************************/ | 1520 | ********************************************************************************/ |
884 | 1505 | void PULImpl::getIndicesToRefresh(std::vector<store::Index*>& indices) | 1521 | void PULImpl::getIndicesToRefresh( |
885 | 1522 | std::vector<store::Index*>& indices, | ||
886 | 1523 | std::vector<store::Index*>& truncate_indices) | ||
887 | 1506 | { | 1524 | { |
888 | 1507 | SimpleStore* store = &GET_STORE(); | 1525 | SimpleStore* store = &GET_STORE(); |
889 | 1508 | 1526 | ||
890 | @@ -1513,6 +1531,7 @@ | |||
891 | 1513 | // modified/inserted/deleted collection docs, because they will be need later | 1531 | // modified/inserted/deleted collection docs, because they will be need later |
892 | 1514 | // to maintain indices. | 1532 | // to maintain indices. |
893 | 1515 | std::set<store::Collection*> collections; | 1533 | std::set<store::Collection*> collections; |
894 | 1534 | std::set<store::Collection*> truncated_collections; | ||
895 | 1516 | 1535 | ||
896 | 1517 | CollectionPulMap::iterator collIte = theCollectionPuls.begin(); | 1536 | CollectionPulMap::iterator collIte = theCollectionPuls.begin(); |
897 | 1518 | CollectionPulMap::iterator collEnd = theCollectionPuls.end(); | 1537 | CollectionPulMap::iterator collEnd = theCollectionPuls.end(); |
898 | @@ -1529,6 +1548,12 @@ | |||
899 | 1529 | 1548 | ||
900 | 1530 | CollectionPul* pul = collIte->second; | 1549 | CollectionPul* pul = collIte->second; |
901 | 1531 | 1550 | ||
902 | 1551 | if (pul->theTruncateCollectionList.size() > 0) | ||
903 | 1552 | { | ||
904 | 1553 | truncated_collections.insert(collection); | ||
905 | 1554 | continue; | ||
906 | 1555 | } | ||
907 | 1556 | |||
908 | 1532 | NodeToUpdatesMap::iterator ite = pul->theNodeToUpdatesMap.begin(); | 1557 | NodeToUpdatesMap::iterator ite = pul->theNodeToUpdatesMap.begin(); |
909 | 1533 | NodeToUpdatesMap::iterator end = pul->theNodeToUpdatesMap.end(); | 1558 | NodeToUpdatesMap::iterator end = pul->theNodeToUpdatesMap.end(); |
910 | 1534 | for (; ite != end; ++ite) | 1559 | for (; ite != end; ++ite) |
911 | @@ -1595,6 +1620,21 @@ | |||
912 | 1595 | if (colIte != colEnd) | 1620 | if (colIte != colEnd) |
913 | 1596 | break; | 1621 | break; |
914 | 1597 | } | 1622 | } |
915 | 1623 | |||
916 | 1624 | for (csize i = 0; i < numIndexSources; ++i) | ||
917 | 1625 | { | ||
918 | 1626 | std::set<store::Collection*>::const_iterator colIte = truncated_collections.begin(); | ||
919 | 1627 | std::set<store::Collection*>::const_iterator colEnd = truncated_collections.end(); | ||
920 | 1628 | |||
921 | 1629 | for (; colIte != colEnd; ++colIte) | ||
922 | 1630 | { | ||
923 | 1631 | if (indexSources[i]->equals((*colIte)->getName())) | ||
924 | 1632 | { | ||
925 | 1633 | truncate_indices.push_back(index); | ||
926 | 1634 | break; | ||
927 | 1635 | } | ||
928 | 1636 | } | ||
929 | 1637 | } | ||
930 | 1598 | } | 1638 | } |
931 | 1599 | } | 1639 | } |
932 | 1600 | 1640 | ||
933 | @@ -1617,6 +1657,18 @@ | |||
934 | 1617 | /******************************************************************************* | 1657 | /******************************************************************************* |
935 | 1618 | 1658 | ||
936 | 1619 | ********************************************************************************/ | 1659 | ********************************************************************************/ |
937 | 1660 | void PULImpl::addIndexTruncator( | ||
938 | 1661 | const store::Item* collectionName, | ||
939 | 1662 | store::Index* idx) | ||
940 | 1663 | { | ||
941 | 1664 | CollectionPul* pul = getCollectionPulByName(collectionName,false); | ||
942 | 1665 | pul->theTruncatedIndices.push_back(static_cast<IndexImpl*>(idx)); | ||
943 | 1666 | } | ||
944 | 1667 | |||
945 | 1668 | |||
946 | 1669 | /******************************************************************************* | ||
947 | 1670 | |||
948 | 1671 | ********************************************************************************/ | ||
949 | 1620 | void PULImpl::setICChecker(store::ICChecker* icChecker) | 1672 | void PULImpl::setICChecker(store::ICChecker* icChecker) |
950 | 1621 | { | 1673 | { |
951 | 1622 | theICChecker = icChecker; | 1674 | theICChecker = icChecker; |
952 | @@ -1796,6 +1848,7 @@ | |||
953 | 1796 | cleanList(theCreateCollectionList); | 1848 | cleanList(theCreateCollectionList); |
954 | 1797 | cleanList(theInsertIntoCollectionList); | 1849 | cleanList(theInsertIntoCollectionList); |
955 | 1798 | cleanList(theDeleteFromCollectionList); | 1850 | cleanList(theDeleteFromCollectionList); |
956 | 1851 | cleanList(theTruncateCollectionList); | ||
957 | 1799 | cleanList(theDeleteCollectionList); | 1852 | cleanList(theDeleteCollectionList); |
958 | 1800 | 1853 | ||
959 | 1801 | cleanIndexDeltas(theBeforeIndexDeltas); | 1854 | cleanIndexDeltas(theBeforeIndexDeltas); |
960 | @@ -1822,6 +1875,7 @@ | |||
961 | 1822 | switchPulInPrimitivesList(theCreateCollectionList); | 1875 | switchPulInPrimitivesList(theCreateCollectionList); |
962 | 1823 | switchPulInPrimitivesList(theInsertIntoCollectionList); | 1876 | switchPulInPrimitivesList(theInsertIntoCollectionList); |
963 | 1824 | switchPulInPrimitivesList(theDeleteFromCollectionList); | 1877 | switchPulInPrimitivesList(theDeleteFromCollectionList); |
964 | 1878 | switchPulInPrimitivesList(theTruncateCollectionList); | ||
965 | 1825 | switchPulInPrimitivesList(theDeleteCollectionList); | 1879 | switchPulInPrimitivesList(theDeleteCollectionList); |
966 | 1826 | } | 1880 | } |
967 | 1827 | 1881 | ||
968 | @@ -1946,7 +2000,14 @@ | |||
969 | 1946 | ********************************************************************************/ | 2000 | ********************************************************************************/ |
970 | 1947 | void CollectionPul::refreshIndices() | 2001 | void CollectionPul::refreshIndices() |
971 | 1948 | { | 2002 | { |
973 | 1949 | csize numIncrementalIndices = theIncrementalIndices.size(); | 2003 | csize numIncrementalIndices = theTruncatedIndices.size(); |
974 | 2004 | for (csize idx = 0; idx < numIncrementalIndices; ++idx) | ||
975 | 2005 | { | ||
976 | 2006 | ValueIndex* index = static_cast<ValueIndex*>(theTruncatedIndices[idx]); | ||
977 | 2007 | index->clear(); | ||
978 | 2008 | } | ||
979 | 2009 | |||
980 | 2010 | numIncrementalIndices = theIncrementalIndices.size(); | ||
981 | 1950 | 2011 | ||
982 | 1951 | for (csize idx = 0; idx < numIncrementalIndices; ++idx) | 2012 | for (csize idx = 0; idx < numIncrementalIndices; ++idx) |
983 | 1952 | { | 2013 | { |
984 | @@ -2134,6 +2195,7 @@ | |||
985 | 2134 | applyList(theCreateCollectionList); | 2195 | applyList(theCreateCollectionList); |
986 | 2135 | applyList(theInsertIntoCollectionList); | 2196 | applyList(theInsertIntoCollectionList); |
987 | 2136 | applyList(theDeleteFromCollectionList); | 2197 | applyList(theDeleteFromCollectionList); |
988 | 2198 | applyList(theTruncateCollectionList); | ||
989 | 2137 | 2199 | ||
990 | 2138 | // Compute the after-delta for each incrementally maintained index. | 2200 | // Compute the after-delta for each incrementally maintained index. |
991 | 2139 | computeIndexAfterDeltas(); | 2201 | computeIndexAfterDeltas(); |
992 | @@ -2266,6 +2328,7 @@ | |||
993 | 2266 | 2328 | ||
994 | 2267 | try | 2329 | try |
995 | 2268 | { | 2330 | { |
996 | 2331 | undoList(theTruncateCollectionList); | ||
997 | 2269 | undoList(theDeleteFromCollectionList); | 2332 | undoList(theDeleteFromCollectionList); |
998 | 2270 | undoList(theInsertIntoCollectionList); | 2333 | undoList(theInsertIntoCollectionList); |
999 | 2271 | undoList(theCreateCollectionList); | 2334 | undoList(theCreateCollectionList); |
1000 | 2272 | 2335 | ||
1001 | === modified file 'src/store/naive/simple_pul.h' | |||
1002 | --- src/store/naive/simple_pul.h 2012-03-07 14:22:29 +0000 | |||
1003 | +++ src/store/naive/simple_pul.h 2012-03-08 01:45:23 +0000 | |||
1004 | @@ -183,6 +183,7 @@ | |||
1005 | 183 | std::vector<UpdatePrimitive*> theCreateCollectionList; | 183 | std::vector<UpdatePrimitive*> theCreateCollectionList; |
1006 | 184 | std::vector<UpdatePrimitive*> theInsertIntoCollectionList; | 184 | std::vector<UpdatePrimitive*> theInsertIntoCollectionList; |
1007 | 185 | std::vector<UpdatePrimitive*> theDeleteFromCollectionList; | 185 | std::vector<UpdatePrimitive*> theDeleteFromCollectionList; |
1008 | 186 | std::vector<UpdatePrimitive*> theTruncateCollectionList; | ||
1009 | 186 | std::vector<UpdatePrimitive*> theDeleteCollectionList; | 187 | std::vector<UpdatePrimitive*> theDeleteCollectionList; |
1010 | 187 | 188 | ||
1011 | 188 | // Validate in place primitives | 189 | // Validate in place primitives |
1012 | @@ -194,6 +195,7 @@ | |||
1013 | 194 | std::vector<XmlNode*> theDeletedDocs; | 195 | std::vector<XmlNode*> theDeletedDocs; |
1014 | 195 | 196 | ||
1015 | 196 | std::vector<IndexImpl*> theIncrementalIndices; | 197 | std::vector<IndexImpl*> theIncrementalIndices; |
1016 | 198 | std::vector<IndexImpl*> theTruncatedIndices; | ||
1017 | 197 | 199 | ||
1018 | 198 | std::vector<IndexEntryCreator_t> theIndexEntryCreators; | 200 | std::vector<IndexEntryCreator_t> theIndexEntryCreators; |
1019 | 199 | 201 | ||
1020 | @@ -465,6 +467,11 @@ | |||
1021 | 465 | bool isLast, | 467 | bool isLast, |
1022 | 466 | bool dyn_collection = false); | 468 | bool dyn_collection = false); |
1023 | 467 | 469 | ||
1024 | 470 | void addTruncateCollection( | ||
1025 | 471 | const QueryLoc* aQueryLoc, | ||
1026 | 472 | store::Item_t& name, | ||
1027 | 473 | bool dyn_collection = false); | ||
1028 | 474 | |||
1029 | 468 | // Index primitives | 475 | // Index primitives |
1030 | 469 | void addCreateIndex( | 476 | void addCreateIndex( |
1031 | 470 | const QueryLoc* aQueryLoc, | 477 | const QueryLoc* aQueryLoc, |
1032 | @@ -539,13 +546,19 @@ | |||
1033 | 539 | // utils | 546 | // utils |
1034 | 540 | void checkTransformUpdates(const std::vector<store::Item*>& rootNodes) const; | 547 | void checkTransformUpdates(const std::vector<store::Item*>& rootNodes) const; |
1035 | 541 | 548 | ||
1037 | 542 | void getIndicesToRefresh(std::vector<store::Index*>& indices); | 549 | void getIndicesToRefresh( |
1038 | 550 | std::vector<store::Index*>& indices, | ||
1039 | 551 | std::vector<store::Index*>& truncate_indices); | ||
1040 | 543 | 552 | ||
1041 | 544 | void addIndexEntryCreator( | 553 | void addIndexEntryCreator( |
1042 | 545 | const store::Item* collectionName, | 554 | const store::Item* collectionName, |
1043 | 546 | store::Index* idx, | 555 | store::Index* idx, |
1044 | 547 | store::IndexEntryCreator* creator); | 556 | store::IndexEntryCreator* creator); |
1045 | 548 | 557 | ||
1046 | 558 | void addIndexTruncator( | ||
1047 | 559 | const store::Item* collectionName, | ||
1048 | 560 | store::Index* idx); | ||
1049 | 561 | |||
1050 | 549 | void setValidator(store::SchemaValidator* validator); | 562 | void setValidator(store::SchemaValidator* validator); |
1051 | 550 | store::SchemaValidator* getValidator() const { return theValidator; } | 563 | store::SchemaValidator* getValidator() const { return theValidator; } |
1052 | 551 | 564 | ||
1053 | 552 | 565 | ||
1054 | === added file 'test/rbkt/ExpQueryResults/zorba/collections/delete_nodes/truncate_001.xml.res' | |||
1055 | --- test/rbkt/ExpQueryResults/zorba/collections/delete_nodes/truncate_001.xml.res 1970-01-01 00:00:00 +0000 | |||
1056 | +++ test/rbkt/ExpQueryResults/zorba/collections/delete_nodes/truncate_001.xml.res 2012-03-08 01:45:23 +0000 | |||
1057 | @@ -0,0 +1,1 @@ | |||
1058 | 1 | <a>1</a><a>2</a><a>3</a><a>4</a><a>5</a><a>6</a><a>7</a><a>8</a><a>9</a><a>10</a><b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b><b>10</b> | ||
1059 | 0 | 2 | ||
1060 | === added file 'test/rbkt/ExpQueryResults/zorba/collections/dynamic6.xml.res' | |||
1061 | --- test/rbkt/ExpQueryResults/zorba/collections/dynamic6.xml.res 1970-01-01 00:00:00 +0000 | |||
1062 | +++ test/rbkt/ExpQueryResults/zorba/collections/dynamic6.xml.res 2012-03-08 01:45:23 +0000 | |||
1063 | @@ -0,0 +1,1 @@ | |||
1064 | 1 | 0 | ||
1065 | 0 | 2 | ||
1066 | === added file 'test/rbkt/ExpQueryResults/zorba/index/auctions2.xml.res' | |||
1067 | --- test/rbkt/ExpQueryResults/zorba/index/auctions2.xml.res 1970-01-01 00:00:00 +0000 | |||
1068 | +++ test/rbkt/ExpQueryResults/zorba/index/auctions2.xml.res 2012-03-08 01:45:23 +0000 | |||
1069 | @@ -0,0 +1,1 @@ | |||
1070 | 1 | <person id="person0"><city>Macon</city></person> | ||
1071 | 0 | 2 | ||
1072 | === modified file 'test/rbkt/Queries/zorba/collections/collection_002.xqdata' | |||
1073 | --- test/rbkt/Queries/zorba/collections/collection_002.xqdata 2011-06-24 19:58:33 +0000 | |||
1074 | +++ test/rbkt/Queries/zorba/collections/collection_002.xqdata 2012-03-08 01:45:23 +0000 | |||
1075 | @@ -2,4 +2,6 @@ | |||
1076 | 2 | 2 | ||
1077 | 3 | declare collection ns:collection as node()*; | 3 | declare collection ns:collection as node()*; |
1078 | 4 | 4 | ||
1079 | 5 | declare function ns:test2() { () }; | ||
1080 | 6 | \ No newline at end of file | 5 | \ No newline at end of file |
1081 | 6 | declare collection ns:collection2 as node()*; | ||
1082 | 7 | |||
1083 | 8 | declare function ns:test2() { () }; | ||
1084 | 7 | 9 | ||
1085 | === added file 'test/rbkt/Queries/zorba/collections/delete_nodes/truncate_001.xq' | |||
1086 | --- test/rbkt/Queries/zorba/collections/delete_nodes/truncate_001.xq 1970-01-01 00:00:00 +0000 | |||
1087 | +++ test/rbkt/Queries/zorba/collections/delete_nodes/truncate_001.xq 2012-03-08 01:45:23 +0000 | |||
1088 | @@ -0,0 +1,27 @@ | |||
1089 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | ||
1090 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
1091 | 3 | |||
1092 | 4 | import module namespace ns = "http://www.example.com/example" at "../collection_002.xqdata"; | ||
1093 | 5 | |||
1094 | 6 | variable $contents; | ||
1095 | 7 | |||
1096 | 8 | ddl:create(xs:QName("ns:collection")); | ||
1097 | 9 | ddl:create(xs:QName("ns:collection2")); | ||
1098 | 10 | |||
1099 | 11 | dml:insert-nodes( | ||
1100 | 12 | xs:QName("ns:collection"), | ||
1101 | 13 | for $i in 1 to 10 return <a>{$i}</a> | ||
1102 | 14 | ); | ||
1103 | 15 | |||
1104 | 16 | dml:insert-nodes( | ||
1105 | 17 | xs:QName("ns:collection2"), | ||
1106 | 18 | for $i in 1 to 10 return <b>{$i}</b> | ||
1107 | 19 | ); | ||
1108 | 20 | |||
1109 | 21 | $contents := (dml:collection(xs:QName("ns:collection")), dml:collection(xs:QName("ns:collection2"))); | ||
1110 | 22 | |||
1111 | 23 | (dml:truncate(xs:QName("ns:collection")), dml:truncate(xs:QName("ns:collection2"))); | ||
1112 | 24 | |||
1113 | 25 | $contents := ($contents, dml:collection(xs:QName("ns:collection")), dml:collection(xs:QName("ns:collection"))); | ||
1114 | 26 | |||
1115 | 27 | $contents | ||
1116 | 0 | 28 | ||
1117 | === added file 'test/rbkt/Queries/zorba/collections/dynamic6.xq' | |||
1118 | --- test/rbkt/Queries/zorba/collections/dynamic6.xq 1970-01-01 00:00:00 +0000 | |||
1119 | +++ test/rbkt/Queries/zorba/collections/dynamic6.xq 2012-03-08 01:45:23 +0000 | |||
1120 | @@ -0,0 +1,10 @@ | |||
1121 | 1 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl"; | ||
1122 | 2 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml"; | ||
1123 | 3 | |||
1124 | 4 | ddl:create(xs:QName("ddl:test2"),(<center1/>,<oldlast/>)); | ||
1125 | 5 | |||
1126 | 6 | dml:insert-nodes-first(xs:QName("ddl:test2"), (<c1/>,<c2/>)); | ||
1127 | 7 | |||
1128 | 8 | dml:truncate(xs:QName("ddl:test2")); | ||
1129 | 9 | |||
1130 | 10 | count(dml:collection(xs:QName("ddl:test2"))) | ||
1131 | 0 | 11 | ||
1132 | === added file 'test/rbkt/Queries/zorba/index/auctions2.xq' | |||
1133 | --- test/rbkt/Queries/zorba/index/auctions2.xq 1970-01-01 00:00:00 +0000 | |||
1134 | +++ test/rbkt/Queries/zorba/index/auctions2.xq 2012-03-08 01:45:23 +0000 | |||
1135 | @@ -0,0 +1,25 @@ | |||
1136 | 1 | import module namespace auctions = "http://www.w3.org/TestModules/auctions" at | ||
1137 | 2 | "auctions_module1.xqlib"; | ||
1138 | 3 | |||
1139 | 4 | import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl"; | ||
1140 | 5 | import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml"; | ||
1141 | 6 | import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl"; | ||
1142 | 7 | import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml"; | ||
1143 | 8 | |||
1144 | 9 | declare namespace err = "http://www.w3.org/2005/xqt-errors"; | ||
1145 | 10 | |||
1146 | 11 | auctions:create-db(); | ||
1147 | 12 | |||
1148 | 13 | variable $cities := (); | ||
1149 | 14 | |||
1150 | 15 | $cities := for $x in auctions:probe-point-city(xs:QName("auctions:PersonCity"), "Macon") | ||
1151 | 16 | return <person id = "{$x/@id}">{$x//city}</person>; | ||
1152 | 17 | |||
1153 | 18 | dml:truncate(xs:QName("auctions:auctions")); | ||
1154 | 19 | |||
1155 | 20 | $cities := ($cities, | ||
1156 | 21 | for $x in auctions:probe-point-city(xs:QName("auctions:PersonCity"), "Macon") | ||
1157 | 22 | return <person id = "{$x/@id}">{$x//city}</person>); | ||
1158 | 23 | |||
1159 | 24 | $cities | ||
1160 | 25 |
- fix bug #938934 "collection dml:truncate function missing"
- fixes documentation bug: raise zerr:ZDDY0003 instead of zerr:ZDDY0009