Merge lp:~zorba-coders/zorba/abstract-collection-set into lp:zorba
- abstract-collection-set
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Matthias Brantner |
Approved revision: | 10678 |
Merged at revision: | 10682 |
Proposed branch: | lp:~zorba-coders/zorba/abstract-collection-set |
Merge into: | lp:zorba |
Diff against target: |
506 lines (+196/-89) 7 files modified
src/store/naive/CMakeLists.txt (+1/-1) src/store/naive/collection_set.h (+27/-51) src/store/naive/shared_types.h (+4/-5) src/store/naive/simple_collection_set.cpp (+33/-26) src/store/naive/simple_collection_set.h (+117/-0) src/store/naive/simple_store.cpp (+10/-6) src/store/naive/simple_store.h (+4/-0) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/abstract-collection-set |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Till Westmann | Approve | ||
Review via email: mp+94384@code.launchpad.net |
Commit message
Refactored CollectionSet class. zorba::
Description of the change
Refactored CollectionSet class. zorba::
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/abstract-collection-set into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job abstract-
finished. The final status was:
No tests were run - build or configure step must have failed.
Not commiting changes.
Error in read script: /home/ceej/
Matthias Brantner (matthias-brantner) wrote : | # |
- Did you forget to add file simple_
- I would keep the CollectionSet in the simplestore namespace because it's a component defined by the simplestore and not the store api (i.e. a file in store/api)
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/abstract-collection-set into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job abstract-
finished. The final status was:
3 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Till Westmann (tillw) : | # |
Matthias Brantner (matthias-brantner) wrote : | # |
One last and very small change request. The indentation in line 512 of the diff is broken.
Zorba Build Bot (zorba-buildbot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job abstract-
All tests succeeded!
Preview Diff
1 | === modified file 'src/store/naive/CMakeLists.txt' |
2 | --- src/store/naive/CMakeLists.txt 2011-06-22 17:30:15 +0000 |
3 | +++ src/store/naive/CMakeLists.txt 2012-02-28 14:55:38 +0000 |
4 | @@ -31,7 +31,7 @@ |
5 | simple_store.cpp |
6 | simple_iterator_factory.cpp |
7 | simple_collection.cpp |
8 | - collection_set.cpp |
9 | + simple_collection_set.cpp |
10 | simple_index.cpp |
11 | simple_index_value.cpp |
12 | simple_index_general.cpp |
13 | |
14 | === modified file 'src/store/naive/collection_set.h' |
15 | --- src/store/naive/collection_set.h 2012-02-22 16:30:24 +0000 |
16 | +++ src/store/naive/collection_set.h 2012-02-28 14:55:38 +0000 |
17 | @@ -29,82 +29,58 @@ |
18 | |
19 | /******************************************************************************* |
20 | Collections container to ease the implementation of stores which contain |
21 | - a different kind of memory management. For the simplestore, the Collections |
22 | - is only a wrapper class around an ItemPointerHashMap. |
23 | + a different kind of memory management. |
24 | ********************************************************************************/ |
25 | class CollectionSet |
26 | { |
27 | public: |
28 | - typedef ItemPointerHashMap<store::Collection_t> Set; |
29 | - static const ulong DEFAULT_COLLECTION_MAP_SIZE; |
30 | - |
31 | - protected: |
32 | - Set theCollections; |
33 | - |
34 | - public: |
35 | - CollectionSet(); |
36 | - |
37 | - // needs to be virtual to allow implementation of additional stores |
38 | + virtual ~CollectionSet() {} |
39 | + |
40 | virtual void |
41 | - clear(); |
42 | + clear() = 0; |
43 | |
44 | - // needs to be virtual to allow implementation of additional stores |
45 | virtual bool |
46 | insert( |
47 | - const store::Item* aName, |
48 | - store::Collection_t& aCollection); |
49 | + const zorba::store::Item* aName, |
50 | + zorba::store::Collection_t& aCollection) = 0; |
51 | |
52 | - // needs to be virtual to allow implementation of additional stores |
53 | virtual bool |
54 | get( |
55 | - const store::Item* aName, |
56 | - store::Collection_t& aCollection, |
57 | - bool aDynamicCollection = false); |
58 | + const zorba::store::Item* aName, |
59 | + zorba::store::Collection_t& aCollection, |
60 | + bool aDynamicCollection = false) = 0; |
61 | |
62 | - // needs to be virtual to allow implementation of additional stores |
63 | virtual bool |
64 | - remove(const store::Item* aName, bool aDynamicCollection = false); |
65 | - |
66 | - // needs to be virtual to allow implementation of additional stores |
67 | - virtual store::Iterator_t |
68 | - names(bool aDynamicCollection = false); |
69 | - |
70 | - // needs to be virtual to allow implementation of additional stores |
71 | - virtual CollectionIterator_t |
72 | - collections(bool aDynamicCollection = false); |
73 | + remove(const zorba::store::Item* aName, bool aDynamicCollection = false) = 0; |
74 | + |
75 | + virtual zorba::store::Iterator_t |
76 | + names(bool aDynamicCollection = false) = 0; |
77 | + |
78 | + virtual CollectionSetIterator_t |
79 | + collections(bool aDynamicCollection = false) = 0; |
80 | |
81 | }; /* class CollectionSet */ |
82 | |
83 | /******************************************************************************* |
84 | - Collection iterator |
85 | + Collection set iterator |
86 | Returned by the CollectionSet::collections function |
87 | ********************************************************************************/ |
88 | - class CollectionIterator : public SimpleRCObject |
89 | + class CollectionSetIterator : public SimpleRCObject |
90 | { |
91 | - protected: |
92 | - CollectionSet::Set* theCollections; |
93 | - CollectionSet::Set::iterator theIterator; |
94 | - bool theOpened; |
95 | - bool theDynamicCollections; |
96 | - |
97 | public: |
98 | - CollectionIterator( |
99 | - CollectionSet::Set* aCollections, |
100 | - bool aDynamicCollections); |
101 | - |
102 | - virtual ~CollectionIterator(); |
103 | + virtual ~CollectionSetIterator() {} |
104 | |
105 | virtual void |
106 | - open(); |
107 | + open() = 0; |
108 | |
109 | virtual bool |
110 | - next(store::Collection_t&); |
111 | - |
112 | - virtual void |
113 | - reset(); |
114 | - |
115 | - virtual void |
116 | - close(); |
117 | + next(zorba::store::Collection_t&) = 0; |
118 | + |
119 | + virtual void |
120 | + reset() = 0; |
121 | + |
122 | + virtual void |
123 | + close() throw() = 0; |
124 | }; |
125 | |
126 | } /* namespace simplestore */ |
127 | |
128 | === modified file 'src/store/naive/shared_types.h' |
129 | --- src/store/naive/shared_types.h 2011-10-06 20:55:03 +0000 |
130 | +++ src/store/naive/shared_types.h 2012-02-28 14:55:38 +0000 |
131 | @@ -33,10 +33,6 @@ |
132 | class AtomicItem; |
133 | typedef store::ItemHandle<AtomicItem> AtomicItem_t; |
134 | |
135 | -class CollectionSet; |
136 | -class CollectionIterator; |
137 | -typedef rchandle<CollectionIterator> CollectionIterator_t; |
138 | - |
139 | class XmlTree; |
140 | typedef rchandle<XmlTree> XmlTree_t; |
141 | |
142 | @@ -46,9 +42,12 @@ |
143 | class IndexImpl; |
144 | typedef rchandle<IndexImpl> IndexImpl_t; |
145 | |
146 | - |
147 | typedef rchandle<store::IndexEntryCreator> IndexEntryCreator_t; |
148 | |
149 | +class CollectionSet; |
150 | + |
151 | +class CollectionSetIterator; |
152 | +typedef rchandle<CollectionSetIterator> CollectionSetIterator_t; |
153 | |
154 | } |
155 | |
156 | |
157 | === renamed file 'src/store/naive/collection_set.cpp' => 'src/store/naive/simple_collection_set.cpp' |
158 | --- src/store/naive/collection_set.cpp 2012-02-15 10:25:02 +0000 |
159 | +++ src/store/naive/simple_collection_set.cpp 2012-02-28 14:55:38 +0000 |
160 | @@ -15,7 +15,7 @@ |
161 | */ |
162 | #include "stdafx.h" |
163 | |
164 | -#include "collection_set.h" |
165 | +#include "simple_collection_set.h" |
166 | #include "store/api/iterator.h" |
167 | #include "name_iterator.h" |
168 | |
169 | @@ -24,8 +24,8 @@ |
170 | /******************************************************************************* |
171 | |
172 | ********************************************************************************/ |
173 | -CollectionIterator::CollectionIterator( |
174 | - CollectionSet::Set* aCollections, |
175 | +SimpleCollectionSetIterator::SimpleCollectionSetIterator( |
176 | + SimpleCollectionSet::Set* aCollections, |
177 | bool aDynamicCollection) |
178 | : |
179 | theCollections(aCollections), |
180 | @@ -35,14 +35,14 @@ |
181 | } |
182 | |
183 | |
184 | -CollectionIterator::~CollectionIterator() |
185 | +SimpleCollectionSetIterator::~SimpleCollectionSetIterator() |
186 | { |
187 | close(); |
188 | } |
189 | |
190 | |
191 | void |
192 | -CollectionIterator::open() |
193 | +SimpleCollectionSetIterator::open() |
194 | { |
195 | theIterator = theCollections->begin(); |
196 | theOpened = true; |
197 | @@ -50,7 +50,7 @@ |
198 | |
199 | |
200 | bool |
201 | -CollectionIterator::next(store::Collection_t& aResult) |
202 | +SimpleCollectionSetIterator::next(zorba::store::Collection_t& aResult) |
203 | { |
204 | while (theIterator != theCollections->end()) |
205 | { |
206 | @@ -69,14 +69,14 @@ |
207 | |
208 | |
209 | void |
210 | -CollectionIterator::reset() |
211 | +SimpleCollectionSetIterator::reset() |
212 | { |
213 | theIterator = theCollections->begin(); |
214 | } |
215 | |
216 | |
217 | void |
218 | -CollectionIterator::close() |
219 | +SimpleCollectionSetIterator::close() throw() |
220 | { |
221 | if (!theOpened) { |
222 | return; |
223 | @@ -88,23 +88,29 @@ |
224 | /******************************************************************************* |
225 | |
226 | ********************************************************************************/ |
227 | -const ulong CollectionSet::DEFAULT_COLLECTION_MAP_SIZE = 32; |
228 | - |
229 | - |
230 | -CollectionSet::CollectionSet() |
231 | +const ulong SimpleCollectionSet::DEFAULT_COLLECTION_MAP_SIZE = 32; |
232 | + |
233 | + |
234 | +SimpleCollectionSet::SimpleCollectionSet() |
235 | : |
236 | theCollections(0, NULL, DEFAULT_COLLECTION_MAP_SIZE, true) |
237 | { |
238 | } |
239 | |
240 | |
241 | -void CollectionSet::clear() |
242 | +SimpleCollectionSet::~SimpleCollectionSet() |
243 | +{ |
244 | +} |
245 | + |
246 | + |
247 | +void SimpleCollectionSet::clear() |
248 | { |
249 | theCollections.clear(); |
250 | } |
251 | |
252 | |
253 | -bool CollectionSet::insert(const store::Item* aName, store::Collection_t& aCollection) |
254 | +bool SimpleCollectionSet::insert(const zorba::store::Item* aName, |
255 | + zorba::store::Collection_t& aCollection) |
256 | { |
257 | store::Item* qname = const_cast<store::Item*>(aName); |
258 | |
259 | @@ -112,12 +118,12 @@ |
260 | } |
261 | |
262 | |
263 | -bool CollectionSet::get( |
264 | - const store::Item* aName, |
265 | - store::Collection_t& aCollection, |
266 | +bool SimpleCollectionSet::get( |
267 | + const zorba::store::Item* aName, |
268 | + zorba::store::Collection_t& aCollection, |
269 | bool aDynamicCollection) |
270 | { |
271 | - if (theCollections.get(const_cast<store::Item*>(aName), aCollection)) |
272 | + if (theCollections.get(const_cast<zorba::store::Item*>(aName), aCollection)) |
273 | { |
274 | return aCollection->isDynamic() == aDynamicCollection; |
275 | } |
276 | @@ -128,35 +134,36 @@ |
277 | } |
278 | |
279 | |
280 | -bool CollectionSet::remove(const store::Item* aName, bool aDynamicCollection) |
281 | +bool SimpleCollectionSet::remove(const zorba::store::Item* aName, bool aDynamicCollection) |
282 | { |
283 | - store::Collection_t lColl; |
284 | + zorba::store::Collection_t lColl; |
285 | if (!get(aName, lColl, aDynamicCollection)) |
286 | { |
287 | return false; |
288 | } |
289 | else |
290 | { |
291 | - return theCollections.erase(const_cast<store::Item*>(aName)); |
292 | + return theCollections.erase(const_cast<zorba::store::Item*>(aName)); |
293 | } |
294 | } |
295 | |
296 | |
297 | -store::Iterator_t CollectionSet::names(bool aDynamicCollections) |
298 | +zorba::store::Iterator_t SimpleCollectionSet::names(bool aDynamicCollections) |
299 | { |
300 | return new NameIterator<Set>(theCollections, aDynamicCollections); |
301 | } |
302 | |
303 | |
304 | -CollectionIterator_t CollectionSet::collections(bool aDynamicCollections) |
305 | +CollectionSetIterator_t SimpleCollectionSet::collections(bool aDynamicCollections) |
306 | { |
307 | - return new CollectionIterator(&theCollections, aDynamicCollections); |
308 | + return new SimpleCollectionSetIterator(&theCollections, |
309 | + aDynamicCollections); |
310 | } |
311 | |
312 | // specialize the next function of the NameIterator for |
313 | -// the CollectionSet in order to be able to handle dynamic collections |
314 | +// the SimpleCollectionSet in order to be able to handle dynamic collections |
315 | template<> bool |
316 | -NameIterator<CollectionSet::Set>::next(store::Item_t& aResult) |
317 | +NameIterator<SimpleCollectionSet::Set>::next(zorba::store::Item_t& aResult) |
318 | { |
319 | while (theIterator != theItems.end()) |
320 | { |
321 | |
322 | === added file 'src/store/naive/simple_collection_set.h' |
323 | --- src/store/naive/simple_collection_set.h 1970-01-01 00:00:00 +0000 |
324 | +++ src/store/naive/simple_collection_set.h 2012-02-28 14:55:38 +0000 |
325 | @@ -0,0 +1,117 @@ |
326 | +/* |
327 | + * Copyright 2006-2010 The FLWOR Foundation. |
328 | + * |
329 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
330 | + * you may not use this file except in compliance with the License. |
331 | + * You may obtain a copy of the License at |
332 | + * |
333 | + * http://www.apache.org/licenses/LICENSE-2.0 |
334 | + * |
335 | + * Unless required by applicable law or agreed to in writing, software |
336 | + * distributed under the License is distributed on an "AS IS" BASIS, |
337 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
338 | + * See the License for the specific language governing permissions and |
339 | + * limitations under the License. |
340 | + */ |
341 | +#ifndef ZORBA_SIMPLE_STORE_SIMPLE_COLLECTION_SET_H |
342 | +#define ZORBA_SIMPLE_STORE_SIMPLE_COLLECTION_SET_H |
343 | + |
344 | +#include "zorbautils/hashmap_itemp.h" |
345 | +#include "collection_set.h" |
346 | +#include "store/api/shared_types.h" |
347 | + |
348 | +namespace zorba { |
349 | + |
350 | + namespace simplestore { |
351 | + |
352 | + class CollectionIterator; |
353 | + |
354 | + /******************************************************************************* |
355 | + Collections container to ease the implementation of stores which contain |
356 | + a different kind of memory management. For the simplestore, the Collections |
357 | + is only a wrapper class around an ItemPointerHashMap. |
358 | + ********************************************************************************/ |
359 | + class SimpleCollectionSet : public CollectionSet |
360 | + { |
361 | + public: |
362 | + typedef ItemPointerHashMap<zorba::store::Collection_t> Set; |
363 | + static const ulong DEFAULT_COLLECTION_MAP_SIZE; |
364 | + |
365 | + protected: |
366 | + Set theCollections; |
367 | + |
368 | + public: |
369 | + SimpleCollectionSet(); |
370 | + |
371 | + virtual |
372 | + ~SimpleCollectionSet(); |
373 | + |
374 | + virtual void |
375 | + clear(); |
376 | + |
377 | + virtual bool |
378 | + insert( |
379 | + const zorba::store::Item* aName, |
380 | + zorba::store::Collection_t& aCollection); |
381 | + |
382 | + virtual bool |
383 | + get( |
384 | + const zorba::store::Item* aName, |
385 | + zorba::store::Collection_t& aCollection, |
386 | + bool aDynamicCollection = false); |
387 | + |
388 | + virtual bool |
389 | + remove(const zorba::store::Item* aName, bool aDynamicCollection = false); |
390 | + |
391 | + virtual zorba::store::Iterator_t |
392 | + names(bool aDynamicCollection = false); |
393 | + |
394 | + // needs to be virtual to allow implementation of additional stores |
395 | + virtual CollectionSetIterator_t |
396 | + collections(bool aDynamicCollection = false); |
397 | + |
398 | + }; /* class CollectionSet */ |
399 | + |
400 | + /******************************************************************************* |
401 | + Collection iterator |
402 | + Returned by the CollectionSet::collections function |
403 | + ********************************************************************************/ |
404 | + class SimpleCollectionSetIterator : public CollectionSetIterator |
405 | + { |
406 | + protected: |
407 | + SimpleCollectionSet::Set* theCollections; |
408 | + SimpleCollectionSet::Set::iterator theIterator; |
409 | + bool theOpened; |
410 | + bool theDynamicCollections; |
411 | + |
412 | + public: |
413 | + SimpleCollectionSetIterator( |
414 | + SimpleCollectionSet::Set* aCollections, |
415 | + bool aDynamicCollections); |
416 | + |
417 | + virtual ~SimpleCollectionSetIterator(); |
418 | + |
419 | + virtual void |
420 | + open(); |
421 | + |
422 | + virtual bool |
423 | + next(zorba::store::Collection_t&); |
424 | + |
425 | + virtual void |
426 | + reset(); |
427 | + |
428 | + virtual void |
429 | + close() throw(); |
430 | + }; |
431 | + |
432 | + } /* namespace simplestore */ |
433 | +} /* namespace zorba */ |
434 | + |
435 | +#endif |
436 | + |
437 | +/* |
438 | + * Local variables: |
439 | + * mode: c++ |
440 | + * End: |
441 | + */ |
442 | +/* vim:set et sw=2 ts=2: */ |
443 | |
444 | === modified file 'src/store/naive/simple_store.cpp' |
445 | --- src/store/naive/simple_store.cpp 2012-02-15 10:25:02 +0000 |
446 | +++ src/store/naive/simple_store.cpp 2012-02-28 14:55:38 +0000 |
447 | @@ -37,7 +37,7 @@ |
448 | #include "simple_temp_seq.h" |
449 | #include "simple_lazy_temp_seq.h" |
450 | #include "simple_collection.h" |
451 | -#include "collection_set.h" |
452 | +#include "simple_collection_set.h" |
453 | #include "simple_index.h" |
454 | #include "simple_index_value.h" |
455 | #include "simple_index_general.h" |
456 | @@ -79,6 +79,10 @@ |
457 | SimpleStore static data |
458 | ********************************************************************************/ |
459 | const ulong SimpleStore::NAMESPACE_POOL_SIZE = 128; |
460 | +const ulong SimpleStore::DEFAULT_DOCUMENT_SET_SIZE = 32; |
461 | +const ulong SimpleStore::DEFAULT_URI_COLLECTION_SET_SIZE = 32; |
462 | +const ulong SimpleStore::DEFAULT_INDICES_SET_SIZE = 32; |
463 | +const ulong SimpleStore::DEFAULT_INTEGRITY_CONSTRAINT_SET_SIZE = 32; |
464 | |
465 | const char* SimpleStore::XS_URI = "http://www.w3.org/2001/XMLSchema"; |
466 | const char* SimpleStore::XML_URI = "http://www.w3.org/2001/XML/1998/namespace"; |
467 | @@ -102,11 +106,11 @@ |
468 | theIteratorFactory(NULL), |
469 | theNodeFactory(NULL), |
470 | thePULFactory(NULL), |
471 | - theDocuments(CollectionSet::DEFAULT_COLLECTION_MAP_SIZE, true), |
472 | + theDocuments(DEFAULT_DOCUMENT_SET_SIZE, true), |
473 | theCollections(0), |
474 | - theIndices(0, NULL, CollectionSet::DEFAULT_COLLECTION_MAP_SIZE, true), |
475 | - theICs(0, NULL, CollectionSet::DEFAULT_COLLECTION_MAP_SIZE, true), |
476 | - theHashMaps(0, NULL, CollectionSet::DEFAULT_COLLECTION_MAP_SIZE, true), |
477 | + theIndices(0, NULL, DEFAULT_INDICES_SET_SIZE, true), |
478 | + theICs(0, NULL, DEFAULT_INTEGRITY_CONSTRAINT_SET_SIZE, true), |
479 | + theHashMaps(0, NULL, DEFAULT_INDICES_SET_SIZE, true), |
480 | theTraceLevel(0), |
481 | theNodeToReferencesMap(128, true) |
482 | #ifndef ZORBA_NO_FULL_TEXT |
483 | @@ -402,7 +406,7 @@ |
484 | *******************************************************************************/ |
485 | CollectionSet* SimpleStore::createCollectionSet() const |
486 | { |
487 | - return new CollectionSet(); |
488 | + return new SimpleCollectionSet(); |
489 | } |
490 | |
491 | |
492 | |
493 | === modified file 'src/store/naive/simple_store.h' |
494 | --- src/store/naive/simple_store.h 2012-02-22 16:30:24 +0000 |
495 | +++ src/store/naive/simple_store.h 2012-02-28 14:55:38 +0000 |
496 | @@ -143,6 +143,10 @@ |
497 | |
498 | protected: |
499 | static const ulong NAMESPACE_POOL_SIZE; |
500 | + static const ulong DEFAULT_DOCUMENT_SET_SIZE; |
501 | + static const ulong DEFAULT_URI_COLLECTION_SET_SIZE; |
502 | + static const ulong DEFAULT_INDICES_SET_SIZE; |
503 | + static const ulong DEFAULT_INTEGRITY_CONSTRAINT_SET_SIZE; |
504 | |
505 | public: |
506 | zstring theEmptyNs; |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ abstract- collection- set-2012- 02-23T14- 54-58.415Z/ log.html
Log at: http://