Merge lp:~zorba-coders/zorba/bug-938934 into lp:zorba

Proposed by Matthias Brantner
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
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

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

- fix bug #938934 "collection dml:truncate function missing"
- fixes documentation bug: raise zerr:ZDDY0003 instead of zerr:ZDDY0009

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-938934-2012-02-28T02-03-09.189Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 2 Pending.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
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.

review: Needs Fixing
Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

Another bug: the UpdTruncateCollection::apply() method does not work if there are multiple truncate primitives in the same PUL.

lp:~zorba-coders/zorba/bug-938934 updated
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

Revision history for this message
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)

lp:~zorba-coders/zorba/bug-938934 updated
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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 %ann:must-copy-input-nodes to be used by the no-copy optimization.
6 * Caching of results for recursive functions with atomic parameter and return types.
7 * Added %ann:cache and %ann:no-cache to enable or disable caching of results of functions with atomic parameter and return types.
8+ * Added truncate function to the collection modules for efficient deletion of all nodes in a collection.
9 * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context)
10 * Fixed bug 867509 (Can not handle largest xs:unsignedLong values)
11 * Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator)
12
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 : @return The result of this function is an empty XDM instance and a pending update
18 : list which, once applied, deletes the last node from the collection.
19 :
20- : @error zerr:ZDDY0009 If available collections does not provide a mapping
21+ : @error zerr:ZDDY0003 If available collections does not provide a mapping
22 : for the expanded QName $name.
23 : @error zerr:ZDDY0011 if the collection doesn't contain any node.
24 :
25@@ -278,7 +278,7 @@
26 : @return The result of this function is an empty XDM instance and a pending update
27 : list which, once applied, deletes the last n nodes.
28 :
29- : @error zerr:ZDDY0009 If available collections does not provide a mapping
30+ : @error zerr:ZDDY0003 If available collections does not provide a mapping
31 : for the expanded QName $name.
32 : @error zerr:ZDDY0011 if the collection doesn't contain the given number of nodes.
33 :
34@@ -288,6 +288,19 @@
35 $number as xs:integer) external;
36
37 (:~
38+ : The truncate function is an updating function that deletes the
39+ : entire contents of collection.
40+ :
41+ : @param $name The name of the collection whose content to delete
42+ :
43+ : @return The result of this function is an empty XDM instance and a pending update
44+ : list which, once applied, deletes the nodes.
45+ :
46+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
47+ :)
48+declare updating function dml:truncate($name as xs:QName) external;
49+
50+(:~
51 : The index-of function return the index of the given node in the collection.
52 :
53 : @param $node The node to retrieve the index from.
54@@ -307,7 +320,7 @@
55 :
56 : @return The sequence contained in the given collection.
57 :
58- : @error zerr:ZDDY0009 If available collections does not provide a mapping
59+ : @error zerr:ZDDY0003 If available collections does not provide a mapping
60 : for the expanded QName $name.
61 :
62 :)
63
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 $number as xs:integer) external;
69
70 (:~
71+ : The truncate function is an updating function that deletes the
72+ : entire contents of collection.
73+ :
74+ : @param $name The name of the collection whose content to delete
75+ :
76+ : @return The result of this function is an empty XDM instance and a pending update
77+ : list which, once applied, deletes the nodes.
78+ :
79+ : @error zerr:ZDDY0001 if the collection identified by $name is not declared.
80+ : @error zerr:ZDDY0003 if the collection identified by $name is not available.
81+ :
82+ :)
83+declare updating function cdml:truncate($name as xs:QName) external;
84+
85+(:~
86 : The index-of function that returns the position of the node in its collection.
87 :
88 : @param $node The node to retrieve the index for.
89
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 /*******************************************************************************
95
96 ********************************************************************************/
97+PlanIter_t zorba_store_collections_static_dml_truncate::codegen(
98+ CompilerCB*,
99+ static_context* sctx,
100+ const QueryLoc& loc,
101+ std::vector<PlanIter_t>& argv,
102+ expr& ann) const
103+{
104+ return new ZorbaTruncateCollectionIterator(sctx, loc, argv,
105+ getName()->getNamespace() == static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS);
106+}
107+
108+
109+/*******************************************************************************
110+
111+********************************************************************************/
112 PlanIter_t zorba_store_collections_static_dml_delete_node_first::codegen(
113 CompilerCB*,
114 static_context* sctx,
115
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
121
122
123+
124 PlanIter_t zorba_store_collections_static_dml_collection_name::codegen(
125 CompilerCB*,
126 static_context* sctx,
127@@ -686,6 +687,30 @@
128 {
129
130
131+ DECL_WITH_KIND(sctx, zorba_store_collections_static_dml_truncate,
132+ (createQName("http://www.zorba-xquery.com/modules/store/static/collections/dml","","truncate"),
133+ GENV_TYPESYSTEM.QNAME_TYPE_ONE,
134+ GENV_TYPESYSTEM.EMPTY_TYPE),
135+ FunctionConsts::ZORBA_STORE_COLLECTIONS_STATIC_DML_TRUNCATE_1);
136+
137+ }
138+
139+
140+ {
141+
142+
143+ DECL_WITH_KIND(sctx, zorba_store_collections_static_dml_truncate,
144+ (createQName("http://www.zorba-xquery.com/modules/store/dynamic/collections/dml","","truncate"),
145+ GENV_TYPESYSTEM.QNAME_TYPE_ONE,
146+ GENV_TYPESYSTEM.EMPTY_TYPE),
147+ FunctionConsts::ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_TRUNCATE_1);
148+
149+ }
150+
151+
152+ {
153+
154+
155 DECL_WITH_KIND(sctx, zorba_store_collections_static_dml_collection_name,
156 (createQName("http://www.zorba-xquery.com/modules/store/static/collections/dml","","collection-name"),
157 GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE,
158
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 };
164
165
166+//zorba-store-collections-static-dml:truncate
167+class zorba_store_collections_static_dml_truncate : public function
168+{
169+public:
170+ zorba_store_collections_static_dml_truncate(const signature& sig, FunctionConsts::FunctionKind kind)
171+ :
172+ function(sig, kind)
173+ {
174+
175+ }
176+
177+ short getScriptingKind() const { return UPDATING_EXPR; }
178+
179+ bool accessesDynCtx() const { return true; }
180+
181+ CODEGEN_DECL();
182+};
183+
184+
185 //zorba-store-collections-static-dml:collection-name
186 class zorba_store_collections_static_dml_collection_name : public function
187 {
188
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 ZORBA_STORE_COLLECTIONS_STATIC_DML_DELETE_NODES_LAST_2,
194 ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_DELETE_NODE_LAST_1,
195 ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_DELETE_NODES_LAST_2,
196+ ZORBA_STORE_COLLECTIONS_STATIC_DML_TRUNCATE_1,
197+ ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_TRUNCATE_1,
198 ZORBA_STORE_COLLECTIONS_STATIC_DML_COLLECTION_NAME_1,
199 ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_COLLECTION_NAME_1,
200 ZORBA_STORE_COLLECTIONS_STATIC_DDL_IS_AVAILABLE_COLLECTION_1,
201
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 /*******************************************************************************
207
208 ********************************************************************************/
209+bool ZorbaTruncateCollectionIterator::nextImpl(
210+ store::Item_t& result,
211+ PlanState& planState) const
212+{
213+ store::Collection_t collection;
214+ store::Item_t collectionName;
215+ std::auto_ptr<store::PUL> pul;
216+
217+ PlanIteratorState* state;
218+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
219+
220+ consumeNext(collectionName, theChildren[0].getp(), planState);
221+
222+ (void)getCollection(
223+ theSctx, collectionName, loc, theDynamicCollection, collection);
224+
225+ // create the pul and add the primitive
226+ pul.reset(GENV_ITEMFACTORY->createPendingUpdateList());
227+
228+ pul->addTruncateCollection(&loc, collectionName, theDynamicCollection);
229+
230+ result = pul.release();
231+ STACK_PUSH( result != NULL, state);
232+
233+ STACK_END (state);
234+}
235+
236+/*******************************************************************************
237+
238+********************************************************************************/
239+const StaticallyKnownCollection*
240+ZorbaTruncateCollectionIterator::getCollection(
241+ const static_context* aSctx,
242+ const store::Item_t& aName,
243+ const QueryLoc& aLoc,
244+ bool aDynamicCollection,
245+ store::Collection_t& coll) const
246+{
247+ const StaticallyKnownCollection* collectionDecl = aSctx->lookup_collection(aName);
248+ if (collectionDecl == 0 && !aDynamicCollection)
249+ {
250+ throw XQUERY_EXCEPTION(
251+ zerr::ZDDY0001_COLLECTION_NOT_DECLARED,
252+ ERROR_PARAMS( aName->getStringValue() ),
253+ ERROR_LOC( aLoc )
254+ );
255+ }
256+
257+ if (!aDynamicCollection)
258+ {
259+ // checking collection update mode
260+ switch(collectionDecl->getUpdateProperty())
261+ {
262+ case StaticContextConsts::decl_const:
263+ throw XQUERY_EXCEPTION(
264+ zerr::ZDDY0004_COLLECTION_CONST_UPDATE,
265+ ERROR_PARAMS( aName->getStringValue() ),
266+ ERROR_LOC( loc )
267+ );
268+
269+ case StaticContextConsts::decl_append_only:
270+ throw XQUERY_EXCEPTION(
271+ zerr::ZDDY0005_COLLECTION_APPEND_BAD_INSERT,
272+ ERROR_PARAMS( aName->getStringValue() ),
273+ ERROR_LOC( loc )
274+ );
275+ default: break;
276+ }
277+ }
278+
279+ coll = GENV_STORE.getCollection(aName, aDynamicCollection);
280+
281+ if (coll == NULL)
282+ {
283+ throw XQUERY_EXCEPTION(
284+ zerr::ZDDY0003_COLLECTION_DOES_NOT_EXIST,
285+ ERROR_PARAMS( aName->getStringValue() ),
286+ ERROR_LOC( aLoc )
287+ );
288+ }
289+
290+ return collectionDecl;
291+}
292+
293+/*******************************************************************************
294+
295+********************************************************************************/
296 bool ZorbaCollectionNameIterator::nextImpl(
297 store::Item_t& result,
298 PlanState& planState) const
299
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 // </ZorbaDeleteNodesLastIterator>
305
306
307+// <ZorbaTruncateCollectionIterator>
308+const char* ZorbaTruncateCollectionIterator::class_name_str = "ZorbaTruncateCollectionIterator";
309+ZorbaTruncateCollectionIterator::class_factory<ZorbaTruncateCollectionIterator>
310+ZorbaTruncateCollectionIterator::g_class_factory;
311+
312+const serialization::ClassVersion
313+ZorbaTruncateCollectionIterator::class_versions[] ={{ 1, 0x000905, false}};
314+
315+const int ZorbaTruncateCollectionIterator::class_versions_count =
316+sizeof(ZorbaTruncateCollectionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
317+
318+void ZorbaTruncateCollectionIterator::accept(PlanIterVisitor& v) const {
319+ v.beginVisit(*this);
320+
321+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
322+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
323+ for ( ; lIter != lEnd; ++lIter ){
324+ (*lIter)->accept(v);
325+ }
326+
327+ v.endVisit(*this);
328+}
329+
330+ZorbaTruncateCollectionIterator::~ZorbaTruncateCollectionIterator() {}
331+
332+// </ZorbaTruncateCollectionIterator>
333+
334+
335 // <ZorbaCollectionNameIterator>
336 const char* ZorbaCollectionNameIterator::class_name_str = "ZorbaCollectionNameIterator";
337 ZorbaCollectionNameIterator::class_factory<ZorbaCollectionNameIterator>
338
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
344 /**
345 *
346+ * zorba:truncate
347+ *
348+ * Author: Zorba Team
349+ */
350+class ZorbaTruncateCollectionIterator : public NaryBaseIterator<ZorbaTruncateCollectionIterator, PlanIteratorState>
351+{
352+protected:
353+ bool theDynamicCollection; //whether it's the function of the dynamic or the static collection module
354+public:
355+ SERIALIZABLE_CLASS(ZorbaTruncateCollectionIterator);
356+
357+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(ZorbaTruncateCollectionIterator,
358+ NaryBaseIterator<ZorbaTruncateCollectionIterator, PlanIteratorState>);
359+
360+ void serialize( ::zorba::serialization::Archiver& ar)
361+ {
362+ serialize_baseclass(ar,
363+ (NaryBaseIterator<ZorbaTruncateCollectionIterator, PlanIteratorState>*)this);
364+
365+ ar & theDynamicCollection;
366+ }
367+
368+ ZorbaTruncateCollectionIterator(
369+ static_context* sctx,
370+ const QueryLoc& loc,
371+ std::vector<PlanIter_t>& children,
372+ bool aDynamicCollection)
373+ :
374+ NaryBaseIterator<ZorbaTruncateCollectionIterator, PlanIteratorState>(sctx, loc, children),
375+ theDynamicCollection(aDynamicCollection)
376+ {}
377+
378+ virtual ~ZorbaTruncateCollectionIterator();
379+
380+public:
381+ const StaticallyKnownCollection* getCollection(const static_context* sctx, const store::Item_t& name, const QueryLoc& loc, bool dyn_coll, store::Collection_t& coll) const;
382+ void accept(PlanIterVisitor& v) const;
383+
384+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
385+};
386+
387+
388+/**
389+ *
390 * zorba:collection-name
391 *
392 * Author: Zorba Team
393
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 SchemaValidatorImpl validator(loc, sctx);
399 ICCheckerImpl icChecker(sctx, gdctx);
400 std::vector<store::Index*> indexes;
401+ std::vector<store::Index*> truncate_indexes;
402 store::ItemHandle<store::PUL> indexPul;
403
404 // Get all the indexes that are associated with any of the collections that
405 // are going to be updated by this pul. Check which of those indices can be
406 // maintained incrementally, and pass this info back to the pul.
407- pul->getIndicesToRefresh(indexes);
408+ pul->getIndicesToRefresh(indexes, truncate_indexes);
409
410 ulong numIndices = (ulong)indexes.size();
411
412@@ -178,6 +179,17 @@
413 zorbaIndexes[i] = indexDecl;
414 }
415
416+ numIndices = (ulong)truncate_indexes.size();
417+ for (ulong i = 0; i < numIndices; ++i)
418+ {
419+ IndexDecl* indexDecl = sctx->lookup_index(indexes[i]->getName());
420+
421+ if (indexDecl->getMaintenanceMode() == IndexDecl::DOC_MAP)
422+ {
423+ pul->addIndexTruncator(indexDecl->getSourceName(0), indexes[i]);
424+ }
425+ }
426+
427 try
428 {
429 // Apply updates
430
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 /*******************************************************************************
436 ********************************************************************************/
437 -->
438+<zorba:iterator name="ZorbaTruncateCollectionIterator" >
439+
440+ <zorba:description author="Zorba Team">
441+ zorba:truncate
442+ </zorba:description>
443+
444+ <zorba:function generateCodegen="false">
445+
446+ <zorba:signature localname="truncate" prefix="zorba-store-collections-static-dml">
447+ <zorba:param>xs:QName</zorba:param>
448+ <zorba:output>empty-sequence()</zorba:output>
449+ </zorba:signature>
450+
451+ <zorba:signature localname="truncate" prefix="zorba-store-dynamic-collections-dml">
452+ <zorba:param>xs:QName</zorba:param>
453+ <zorba:output>empty-sequence()</zorba:output>
454+ </zorba:signature>
455+
456+ <zorba:methods>
457+ <zorba:getScriptingKind returnValue="UPDATING_EXPR"/>
458+ <zorba:accessesDynCtx returnValue="true"/>
459+ </zorba:methods>
460+
461+ </zorba:function>
462+
463+ <zorba:constructor>
464+ <zorba:parameter type="bool" name="aDynamicCollection" />
465+ </zorba:constructor>
466+
467+ <zorba:member type="bool" name="theDynamicCollection"
468+ brief="whether it's the function of the dynamic or the static collection module"/>
469+
470+ <zorba:method const="true" name="getCollection" return="const StaticallyKnownCollection*">
471+ <zorba:param type="const static_context*" name="sctx"/>
472+ <zorba:param type="const store::Item_t&amp;" name="name"/>
473+ <zorba:param type="const QueryLoc&amp;" name="loc"/>
474+ <zorba:param type="bool" name="dyn_coll"/>
475+ <zorba:param type="store::Collection_t&amp;" name="coll"/>
476+ </zorba:method>
477+</zorba:iterator>
478+
479+
480+<!--
481+/*******************************************************************************
482+********************************************************************************/
483+-->
484 <zorba:iterator name="ZorbaCollectionNameIterator" >
485
486 <zorba:description author="Zorba Team">
487
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
493 class ZorbaDeleteNodesLastIterator;
494
495+ class ZorbaTruncateCollectionIterator;
496+
497 class ZorbaCollectionNameIterator;
498
499 class IsAvailableCollectionIterator;
500@@ -697,6 +699,9 @@
501 virtual void beginVisit ( const ZorbaDeleteNodesLastIterator& ) = 0;
502 virtual void endVisit ( const ZorbaDeleteNodesLastIterator& ) = 0;
503
504+ virtual void beginVisit ( const ZorbaTruncateCollectionIterator& ) = 0;
505+ virtual void endVisit ( const ZorbaTruncateCollectionIterator& ) = 0;
506+
507 virtual void beginVisit ( const ZorbaCollectionNameIterator& ) = 0;
508 virtual void endVisit ( const ZorbaCollectionNameIterator& ) = 0;
509
510
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 // </ZorbaDeleteNodesLastIterator>
516
517
518+// <ZorbaTruncateCollectionIterator>
519+void PrinterVisitor::beginVisit ( const ZorbaTruncateCollectionIterator& a) {
520+ thePrinter.startBeginVisit("ZorbaTruncateCollectionIterator", ++theId);
521+ printCommons( &a, theId );
522+ thePrinter.endBeginVisit( theId );
523+}
524+
525+void PrinterVisitor::endVisit ( const ZorbaTruncateCollectionIterator& ) {
526+ thePrinter.startEndVisit();
527+ thePrinter.endEndVisit();
528+}
529+// </ZorbaTruncateCollectionIterator>
530+
531+
532 // <ZorbaCollectionNameIterator>
533 void PrinterVisitor::beginVisit ( const ZorbaCollectionNameIterator& a) {
534 thePrinter.startBeginVisit("ZorbaCollectionNameIterator", ++theId);
535
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 void beginVisit( const ZorbaDeleteNodesLastIterator& );
541 void endVisit ( const ZorbaDeleteNodesLastIterator& );
542
543+ void beginVisit( const ZorbaTruncateCollectionIterator& );
544+ void endVisit ( const ZorbaTruncateCollectionIterator& );
545+
546 void beginVisit( const ZorbaCollectionNameIterator& );
547 void endVisit ( const ZorbaCollectionNameIterator& );
548
549
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 bool isLast,
555 bool dyn_collection = false) = 0;
556
557+ virtual void addTruncateCollection(
558+ const QueryLoc* aQueryLoc,
559+ Item_t& name,
560+ bool dyn_collection = false) = 0;
561+
562 // functions to add primitives for indexes
563
564 virtual void addCreateIndex(
565@@ -281,13 +286,18 @@
566
567 // utils
568 virtual void getIndicesToRefresh(
569- std::vector<Index*>& indices) = 0;
570+ std::vector<Index*>& indices,
571+ std::vector<Index*>& truncate_indices) = 0;
572
573 virtual void addIndexEntryCreator(
574 const Item* collectionName,
575 Index* idx,
576 IndexEntryCreator* creator) = 0;
577
578+ virtual void addIndexTruncator(
579+ const store::Item* collectionName,
580+ Index* idx) = 0;
581+
582 virtual void setValidator(
583 SchemaValidator* validator) = 0;
584
585
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 UP_INSERT_AT_INTO_COLLECTION,
591 UP_REMOVE_FROM_COLLECTION,
592 UP_REMOVE_AT_FROM_COLLECTION,
593+ UP_TRUNCATE_COLLECTION,
594
595 // index primitives
596 UP_CREATE_INDEX,
597@@ -177,6 +178,8 @@
598 return "insertAtIntoCollection";
599 case UP_REMOVE_FROM_COLLECTION:
600 return "removeFromCollection";
601+ case UP_TRUNCATE_COLLECTION:
602+ return "truncateCollection";
603 case UP_REMOVE_AT_FROM_COLLECTION:
604 return "removeAtFromCollection";
605 case UP_CREATE_INDEX:
606
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 return new UpdDeleteNodesFromCollection(pul, aLoc, name, nodes, isLast, dyn_collection);
612 }
613
614+
615+ /***************************************************************************
616+ ***************************************************************************/
617+ UpdTruncateCollection*
618+ PULPrimitiveFactory::createUpdTruncateCollection(
619+ CollectionPul* pul,
620+ const QueryLoc* aLoc,
621+ store::Item_t& name,
622+ bool dyn_collection)
623+ {
624+ return new UpdTruncateCollection(pul, aLoc, name, dyn_collection);
625+ }
626
627 /***************************************************************************
628 ***************************************************************************/
629
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 class UpdInsertBeforeIntoCollection;
635 class UpdInsertAfterIntoCollection;
636 class UpdDeleteNodesFromCollection;
637+ class UpdTruncateCollection;
638 class UpdCreateIndex;
639 class UpdDeleteIndex;
640 class UpdRefreshIndex;
641@@ -311,6 +312,15 @@
642 std::vector<store::Item_t>& nodes,
643 bool isLast,
644 bool dyn_collection = false);
645+
646+ /***************************************************************************
647+ ***************************************************************************/
648+ virtual UpdTruncateCollection*
649+ createUpdTruncateCollection(
650+ CollectionPul* pul,
651+ const QueryLoc*,
652+ store::Item_t& name,
653+ bool dyn_collection = false);
654
655 /***************************************************************************
656 ***************************************************************************/
657
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 }
663
664
665+/*******************************************************************************
666+ UpdTruncateCollection
667+********************************************************************************/
668+void UpdTruncateCollection::apply()
669+{
670+ SimpleCollection* lColl = static_cast<SimpleCollection*>
671+ (GET_STORE().getCollection(theName, theDynamicCollection).getp());
672+ assert(lColl);
673+
674+ lColl->theXmlTrees.swap(theTrees);
675+
676+ theIsApplied = true;
677+
678+}
679+
680+void UpdTruncateCollection::undo()
681+{
682+ if (!theIsApplied) return;
683+
684+ SimpleCollection* lColl = static_cast<SimpleCollection*>
685+ (GET_STORE().getCollection(theName, theDynamicCollection).getp());
686+ assert(lColl);
687+
688+ lColl->theXmlTrees.clear();
689+
690+ theTrees.swap(lColl->theXmlTrees);
691+
692+ theIsApplied = false;
693+}
694+
695
696 /////////////////////////////////////////////////////////////////////////////////
697 // //
698
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 };
704
705
706+/*******************************************************************************
707+
708+********************************************************************************/
709+class UpdTruncateCollection: public UpdCollection
710+{
711+ friend class PULPrimitiveFactory;
712+
713+protected:
714+ std::vector<store::Item_t> theTrees; // needed for undo only
715+
716+ UpdTruncateCollection(
717+ CollectionPul* pul,
718+ const QueryLoc* aLoc,
719+ store::Item_t& name,
720+ bool dyn_collection)
721+ :
722+ UpdCollection(pul, aLoc, name, dyn_collection)
723+ {
724+ }
725+
726+public:
727+ store::UpdateConsts::UpdPrimKind getKind() const
728+ {
729+ return store::UpdateConsts::UP_TRUNCATE_COLLECTION;
730+ }
731+
732+ void apply();
733+ void undo();
734+};
735+
736+
737 /////////////////////////////////////////////////////////////////////////////////
738 // //
739 // Index Primitives //
740
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 class SimpleCollection : public Collection
746 {
747 friend class CollectionIter;
748+ friend class UpdTruncateCollection;
749
750 public:
751 class CollectionIter : public store::Iterator
752
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
758 virtual KeyIterator_t keys() const = 0;
759
760+ virtual void clear() = 0;
761+
762 store::IndexCondition_t createCondition(store::IndexCondition::Kind k);
763
764 //
765
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 }
771
772
773+/******************************************************************************
774+
775+*******************************************************************************/
776+void GeneralHashIndex::clear()
777+{
778+ for (ulong i = 0; i < store::XS_LAST; ++i)
779+ {
780+ if (theMaps[i] == NULL)
781+ continue;
782+
783+ theMaps[i]->clear();
784+ }
785+
786+ if (isTyped())
787+ {
788+ theSingleMap->clear();
789+ }
790+}
791+
792+
793 /////////////////////////////////////////////////////////////////////////////////
794 // //
795 // GeneralHashIndex::KeyIterator //
796@@ -912,6 +932,26 @@
797 /******************************************************************************
798
799 *******************************************************************************/
800+void GeneralTreeIndex::clear()
801+{
802+ for (ulong i = 0; i < store::XS_LAST; ++i)
803+ {
804+ if (theMaps[i] == NULL)
805+ continue;
806+
807+ theMaps[i]->clear();
808+ }
809+
810+ if (isTyped())
811+ {
812+ theSingleMap->clear();
813+ }
814+}
815+
816+
817+/******************************************************************************
818+
819+*******************************************************************************/
820 store::Index::KeyIterator_t GeneralTreeIndex::keys() const
821 {
822 return 0;
823
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 Index::KeyIterator_t keys() const;
829
830 bool remove(const store::Item_t& key, store::Item_t& item, bool);
831+
832+ void clear();
833 };
834
835
836@@ -291,6 +293,8 @@
837 Index::KeyIterator_t keys() const;
838
839 bool remove(const store::Item_t& key, store::Item_t& item, bool all);
840+
841+ void clear();
842 };
843
844
845
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 }
851
852
853+void PULImpl::addTruncateCollection(
854+ const QueryLoc* aQueryLoc,
855+ store::Item_t& name,
856+ bool dyn_collection)
857+{
858+ CollectionPul* pul = getCollectionPulByName(name.getp(),dyn_collection);
859+
860+ pul->theTruncateCollectionList.push_back(
861+ GET_PUL_FACTORY().createUpdTruncateCollection(pul, aQueryLoc, name, dyn_collection));
862+}
863+
864 /*******************************************************************************
865 Index primitives
866 ********************************************************************************/
867@@ -1157,6 +1168,11 @@
868 UP_LIST_NONE);
869
870 mergeUpdateList(thisPul,
871+ thisPul->theTruncateCollectionList,
872+ otherPul->theTruncateCollectionList,
873+ UP_LIST_NONE);
874+
875+ mergeUpdateList(thisPul,
876 thisPul->theDeleteCollectionList,
877 otherPul->theDeleteCollectionList,
878 UP_LIST_NONE);
879@@ -1502,7 +1518,9 @@
880 This method is invoked by the ApplyIterator before any of the pul primitives
881 is applied.
882 ********************************************************************************/
883-void PULImpl::getIndicesToRefresh(std::vector<store::Index*>& indices)
884+void PULImpl::getIndicesToRefresh(
885+ std::vector<store::Index*>& indices,
886+ std::vector<store::Index*>& truncate_indices)
887 {
888 SimpleStore* store = &GET_STORE();
889
890@@ -1513,6 +1531,7 @@
891 // modified/inserted/deleted collection docs, because they will be need later
892 // to maintain indices.
893 std::set<store::Collection*> collections;
894+ std::set<store::Collection*> truncated_collections;
895
896 CollectionPulMap::iterator collIte = theCollectionPuls.begin();
897 CollectionPulMap::iterator collEnd = theCollectionPuls.end();
898@@ -1529,6 +1548,12 @@
899
900 CollectionPul* pul = collIte->second;
901
902+ if (pul->theTruncateCollectionList.size() > 0)
903+ {
904+ truncated_collections.insert(collection);
905+ continue;
906+ }
907+
908 NodeToUpdatesMap::iterator ite = pul->theNodeToUpdatesMap.begin();
909 NodeToUpdatesMap::iterator end = pul->theNodeToUpdatesMap.end();
910 for (; ite != end; ++ite)
911@@ -1595,6 +1620,21 @@
912 if (colIte != colEnd)
913 break;
914 }
915+
916+ for (csize i = 0; i < numIndexSources; ++i)
917+ {
918+ std::set<store::Collection*>::const_iterator colIte = truncated_collections.begin();
919+ std::set<store::Collection*>::const_iterator colEnd = truncated_collections.end();
920+
921+ for (; colIte != colEnd; ++colIte)
922+ {
923+ if (indexSources[i]->equals((*colIte)->getName()))
924+ {
925+ truncate_indices.push_back(index);
926+ break;
927+ }
928+ }
929+ }
930 }
931 }
932
933@@ -1617,6 +1657,18 @@
934 /*******************************************************************************
935
936 ********************************************************************************/
937+void PULImpl::addIndexTruncator(
938+ const store::Item* collectionName,
939+ store::Index* idx)
940+{
941+ CollectionPul* pul = getCollectionPulByName(collectionName,false);
942+ pul->theTruncatedIndices.push_back(static_cast<IndexImpl*>(idx));
943+}
944+
945+
946+/*******************************************************************************
947+
948+********************************************************************************/
949 void PULImpl::setICChecker(store::ICChecker* icChecker)
950 {
951 theICChecker = icChecker;
952@@ -1796,6 +1848,7 @@
953 cleanList(theCreateCollectionList);
954 cleanList(theInsertIntoCollectionList);
955 cleanList(theDeleteFromCollectionList);
956+ cleanList(theTruncateCollectionList);
957 cleanList(theDeleteCollectionList);
958
959 cleanIndexDeltas(theBeforeIndexDeltas);
960@@ -1822,6 +1875,7 @@
961 switchPulInPrimitivesList(theCreateCollectionList);
962 switchPulInPrimitivesList(theInsertIntoCollectionList);
963 switchPulInPrimitivesList(theDeleteFromCollectionList);
964+ switchPulInPrimitivesList(theTruncateCollectionList);
965 switchPulInPrimitivesList(theDeleteCollectionList);
966 }
967
968@@ -1946,7 +2000,14 @@
969 ********************************************************************************/
970 void CollectionPul::refreshIndices()
971 {
972- csize numIncrementalIndices = theIncrementalIndices.size();
973+ csize numIncrementalIndices = theTruncatedIndices.size();
974+ for (csize idx = 0; idx < numIncrementalIndices; ++idx)
975+ {
976+ ValueIndex* index = static_cast<ValueIndex*>(theTruncatedIndices[idx]);
977+ index->clear();
978+ }
979+
980+ numIncrementalIndices = theIncrementalIndices.size();
981
982 for (csize idx = 0; idx < numIncrementalIndices; ++idx)
983 {
984@@ -2134,6 +2195,7 @@
985 applyList(theCreateCollectionList);
986 applyList(theInsertIntoCollectionList);
987 applyList(theDeleteFromCollectionList);
988+ applyList(theTruncateCollectionList);
989
990 // Compute the after-delta for each incrementally maintained index.
991 computeIndexAfterDeltas();
992@@ -2266,6 +2328,7 @@
993
994 try
995 {
996+ undoList(theTruncateCollectionList);
997 undoList(theDeleteFromCollectionList);
998 undoList(theInsertIntoCollectionList);
999 undoList(theCreateCollectionList);
1000
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 std::vector<UpdatePrimitive*> theCreateCollectionList;
1006 std::vector<UpdatePrimitive*> theInsertIntoCollectionList;
1007 std::vector<UpdatePrimitive*> theDeleteFromCollectionList;
1008+ std::vector<UpdatePrimitive*> theTruncateCollectionList;
1009 std::vector<UpdatePrimitive*> theDeleteCollectionList;
1010
1011 // Validate in place primitives
1012@@ -194,6 +195,7 @@
1013 std::vector<XmlNode*> theDeletedDocs;
1014
1015 std::vector<IndexImpl*> theIncrementalIndices;
1016+ std::vector<IndexImpl*> theTruncatedIndices;
1017
1018 std::vector<IndexEntryCreator_t> theIndexEntryCreators;
1019
1020@@ -465,6 +467,11 @@
1021 bool isLast,
1022 bool dyn_collection = false);
1023
1024+ void addTruncateCollection(
1025+ const QueryLoc* aQueryLoc,
1026+ store::Item_t& name,
1027+ bool dyn_collection = false);
1028+
1029 // Index primitives
1030 void addCreateIndex(
1031 const QueryLoc* aQueryLoc,
1032@@ -539,13 +546,19 @@
1033 // utils
1034 void checkTransformUpdates(const std::vector<store::Item*>& rootNodes) const;
1035
1036- void getIndicesToRefresh(std::vector<store::Index*>& indices);
1037+ void getIndicesToRefresh(
1038+ std::vector<store::Index*>& indices,
1039+ std::vector<store::Index*>& truncate_indices);
1040
1041 void addIndexEntryCreator(
1042 const store::Item* collectionName,
1043 store::Index* idx,
1044 store::IndexEntryCreator* creator);
1045
1046+ void addIndexTruncator(
1047+ const store::Item* collectionName,
1048+ store::Index* idx);
1049+
1050 void setValidator(store::SchemaValidator* validator);
1051 store::SchemaValidator* getValidator() const { return theValidator; }
1052
1053
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+<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
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+0
1065
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+<person id="person0"><city>Macon</city></person>
1071
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
1077 declare collection ns:collection as node()*;
1078
1079-declare function ns:test2() { () };
1080\ No newline at end of file
1081+declare collection ns:collection2 as node()*;
1082+
1083+declare function ns:test2() { () };
1084
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+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";
1090+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";
1091+
1092+import module namespace ns = "http://www.example.com/example" at "../collection_002.xqdata";
1093+
1094+variable $contents;
1095+
1096+ddl:create(xs:QName("ns:collection"));
1097+ddl:create(xs:QName("ns:collection2"));
1098+
1099+dml:insert-nodes(
1100+ xs:QName("ns:collection"),
1101+ for $i in 1 to 10 return <a>{$i}</a>
1102+);
1103+
1104+dml:insert-nodes(
1105+ xs:QName("ns:collection2"),
1106+ for $i in 1 to 10 return <b>{$i}</b>
1107+);
1108+
1109+$contents := (dml:collection(xs:QName("ns:collection")), dml:collection(xs:QName("ns:collection2")));
1110+
1111+(dml:truncate(xs:QName("ns:collection")), dml:truncate(xs:QName("ns:collection2")));
1112+
1113+$contents := ($contents, dml:collection(xs:QName("ns:collection")), dml:collection(xs:QName("ns:collection")));
1114+
1115+$contents
1116
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+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";
1122+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";
1123+
1124+ddl:create(xs:QName("ddl:test2"),(<center1/>,<oldlast/>));
1125+
1126+dml:insert-nodes-first(xs:QName("ddl:test2"), (<c1/>,<c2/>));
1127+
1128+dml:truncate(xs:QName("ddl:test2"));
1129+
1130+count(dml:collection(xs:QName("ddl:test2")))
1131
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+import module namespace auctions = "http://www.w3.org/TestModules/auctions" at
1137+ "auctions_module1.xqlib";
1138+
1139+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";
1140+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";
1141+import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";
1142+import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml";
1143+
1144+declare namespace err = "http://www.w3.org/2005/xqt-errors";
1145+
1146+auctions:create-db();
1147+
1148+variable $cities := ();
1149+
1150+$cities := for $x in auctions:probe-point-city(xs:QName("auctions:PersonCity"), "Macon")
1151+ return <person id = "{$x/@id}">{$x//city}</person>;
1152+
1153+dml:truncate(xs:QName("auctions:auctions"));
1154+
1155+$cities := ($cities,
1156+ for $x in auctions:probe-point-city(xs:QName("auctions:PersonCity"), "Macon")
1157+ return <person id = "{$x/@id}">{$x//city}</person>);
1158+
1159+$cities
1160+

Subscribers

People subscribed via source and target branches