Merge lp:~zorba-coders/zorba/fix-boost-typedef into lp:zorba

Proposed by Federico Cavalieri
Status: Merged
Approved by: Paul J. Lucas
Approved revision: 11722
Merged at revision: 11722
Proposed branch: lp:~zorba-coders/zorba/fix-boost-typedef
Merge into: lp:zorba
Diff against target: 336 lines (+57/-65)
5 files modified
src/functions/cacheable_function.cpp (+15/-17)
src/functions/cacheable_function.h (+10/-10)
src/functions/external_function.cpp (+4/-6)
src/functions/udf.cpp (+4/-4)
src/zorbautils/hashmap_itemh_cache.h (+24/-28)
To merge this branch: bzr merge lp:~zorba-coders/zorba/fix-boost-typedef
Reviewer Review Type Date Requested Status
Paul J. Lucas Approve
Matthias Brantner Approve
Federico Cavalieri Approve
Review via email: mp+217976@code.launchpad.net

Commit message

Removed boost dependency
Fixed typedef

Description of the change

Removed boost dependency
Fixed typedef

To post a comment you must log in.
Revision history for this message
Federico Cavalieri (fcavalieri) :
review: Approve
Revision history for this message
Federico Cavalieri (fcavalieri) wrote :

The choice of the data structure to hold the flags is open to discussion.
I considered:
 - std::bitset
 - uint64
 - vector<bool> (storage optimized specialization is mandated by the standard)

The size of std::bitset is determined at compile time, boost:dynamic_bitset brings the boost dependency, so I went with vector<bool> because the structure will be non empty in exceptional cases. I preferred to not put a limit on function arity or deal with potential multiple bitfields.

No strong opinion though, comments are welcome.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue succeeded - proposal merged!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/functions/cacheable_function.cpp'
2--- src/functions/cacheable_function.cpp 2014-04-16 18:23:55 +0000
3+++ src/functions/cacheable_function.cpp 2014-05-01 19:54:22 +0000
4@@ -41,8 +41,8 @@
5 ********************************************************************************/
6 FunctionCache::FunctionCache(
7 static_context* aSctx,
8- boost::dynamic_bitset<>& aExcludeFromCacheKey,
9- boost::dynamic_bitset<>& aCompareWithDeepEqual,
10+ std::vector<bool>& aExcludeFromCacheKey,
11+ std::vector<bool>& aCompareWithDeepEqual,
12 bool aAcrossSnapshots):
13 FunctionCacheBaseMap(aSctx, aExcludeFromCacheKey, aCompareWithDeepEqual),
14 theAcrossSnapshots(aAcrossSnapshots),
15@@ -173,9 +173,6 @@
16 if (theAreCacheSettingsComputed)
17 return;
18
19- theExcludeFromCacheKey = boost::dynamic_bitset<>(theSignature.paramCount());
20- theCompareWithDeepEqual = boost::dynamic_bitset<>(theSignature.paramCount());
21-
22 if (!theTypeManager)
23 theTypeManager = getTypeManager();
24
25@@ -368,13 +365,14 @@
26 /*******************************************************************************
27 ********************************************************************************/
28 void cacheable_function::parseCachingAnnotation(AnnotationInternal* aAnnotation,
29- boost::dynamic_bitset<>& aBitset,
30+ std::vector<bool>& aFlags,
31 XQueryDiagnostics* aDiag)
32 {
33 if (!aAnnotation)
34 return;
35
36- aBitset = boost::dynamic_bitset<>(theSignature.paramCount());
37+ aFlags.resize(theSignature.paramCount(), false);
38+
39 csize lNum = aAnnotation->getNumLiterals();
40 if (lNum)
41 {
42@@ -418,7 +416,7 @@
43 }
44 else
45 {
46- aBitset[lIndex-1] = 1;
47+ aFlags[lIndex-1] = true;
48 }
49 }
50 }
51@@ -432,30 +430,30 @@
52
53 /*******************************************************************************
54 ********************************************************************************/
55-void cacheable_function::saveDynamicBitset(const boost::dynamic_bitset<>& aBitset, ::zorba::serialization::Archiver& ar)
56+void cacheable_function::saveFlags(const std::vector<bool>& aFlags, ::zorba::serialization::Archiver& ar)
57 {
58- size_t lSize = aBitset.size();
59+ std::vector<bool>::size_type lSize = aFlags.size();
60 ar & lSize;
61 bool lValue;
62- for (boost::dynamic_bitset<>::size_type i = 0; i<lSize; ++i)
63+ for (std::vector<bool>::size_type i = 0; i<lSize; ++i)
64 {
65- lValue = (bool)aBitset[i];
66+ lValue = aFlags[i];
67 ar & lValue;
68 }
69 }
70
71 /*******************************************************************************
72 ********************************************************************************/
73-void cacheable_function::loadDynamicBitset(boost::dynamic_bitset<>& aBitset, ::zorba::serialization::Archiver& ar)
74+void cacheable_function::loadFlags(std::vector<bool>& aFlags, ::zorba::serialization::Archiver& ar)
75 {
76- size_t lSize = 0;
77+ std::vector<bool>::size_type lSize = 0;
78 ar & lSize;
79- aBitset.resize(lSize);
80+ aFlags.resize(lSize, false);
81 bool lValue;
82- for (boost::dynamic_bitset<>::size_type i = 0; i<lSize; ++i)
83+ for (std::vector<bool>::size_type i = 0; i<lSize; ++i)
84 {
85 ar & lValue;
86- aBitset[i] = lValue;
87+ aFlags[i] = lValue;
88 }
89 }
90
91
92=== modified file 'src/functions/cacheable_function.h'
93--- src/functions/cacheable_function.h 2014-04-16 18:23:55 +0000
94+++ src/functions/cacheable_function.h 2014-05-01 19:54:22 +0000
95@@ -20,22 +20,22 @@
96 #include "functions/function.h"
97 #include "zorbautils/hashmap_itemh_cache.h"
98 #include "store/api/item_handle.h"
99-#include <boost/dynamic_bitset.hpp>
100+#include <vector>
101
102 namespace zorba
103 {
104 class expr;
105
106-typedef typename zorba::ItemHandleCacheHashMap< std::vector<store::Item_t> > FunctionCacheBaseMap;
107+typedef zorba::ItemHandleCacheHashMap< std::vector<store::Item_t> > FunctionCacheBaseMap;
108
109 class FunctionCache : public FunctionCacheBaseMap
110 {
111 public:
112- typedef typename FunctionCacheBaseMap::iterator iterator;
113+ typedef FunctionCacheBaseMap::iterator iterator;
114
115 FunctionCache(static_context* aSctx,
116- boost::dynamic_bitset<>& aExcludeFromCacheKey,
117- boost::dynamic_bitset<>& aCompareWithDeepEqual,
118+ std::vector<bool>& aExcludeFromCacheKey,
119+ std::vector<bool>& aCompareWithDeepEqual,
120 bool aAcrossSnapshots);
121
122 FunctionCache::iterator find(const store::Item_t& aKey, PlanState& aPlanState);
123@@ -87,8 +87,8 @@
124 bool theCacheAcrossSnapshots;
125 bool theIsCacheAutomatic;
126 bool theAreCacheSettingsComputed;
127- boost::dynamic_bitset<> theExcludeFromCacheKey;
128- boost::dynamic_bitset<> theCompareWithDeepEqual;
129+ std::vector<bool> theExcludeFromCacheKey;
130+ std::vector<bool> theCompareWithDeepEqual;
131
132 public:
133 SERIALIZABLE_CLASS(cacheable_function)
134@@ -114,8 +114,8 @@
135 virtual void useDefaultCachingSettings();
136 virtual void useLegacyCache(XQueryDiagnostics* aDiag);
137 virtual void useStrictlyDeterministicCache(XQueryDiagnostics* aDiag);
138- void saveDynamicBitset(const boost::dynamic_bitset<>& aBitset, ::zorba::serialization::Archiver& ar);
139- void loadDynamicBitset(boost::dynamic_bitset<>& aBitset, ::zorba::serialization::Archiver& ar);
140+ void saveFlags(const std::vector<bool>& aFlags, ::zorba::serialization::Archiver& ar);
141+ void loadFlags(std::vector<bool>& aFlags, ::zorba::serialization::Archiver& ar);
142
143 private:
144 virtual bool haveAtomicArgumentsAndReturnType() const;
145@@ -123,7 +123,7 @@
146 virtual bool haveAllArgumentOneCardinality() const;
147 virtual void parseCachingAnnotations(XQueryDiagnostics* aDiag);
148 virtual void parseCachingAnnotation(AnnotationInternal* aAnnotation,
149- boost::dynamic_bitset<>& aBitSet,
150+ std::vector<bool>& aFlags,
151 XQueryDiagnostics* aDiag);
152
153 virtual TypeManager* getTypeManager();
154
155=== modified file 'src/functions/external_function.cpp'
156--- src/functions/external_function.cpp 2014-04-16 18:23:55 +0000
157+++ src/functions/external_function.cpp 2014-05-01 19:54:22 +0000
158@@ -100,18 +100,16 @@
159 ar & theLoc;
160 ar & theHasCache;
161 ar & theCacheAcrossSnapshots;
162-
163 if (ar.is_serializing_out())
164 {
165- saveDynamicBitset(theExcludeFromCacheKey, ar);
166- saveDynamicBitset(theCompareWithDeepEqual, ar);
167+ saveFlags(theExcludeFromCacheKey, ar);
168+ saveFlags(theCompareWithDeepEqual, ar);
169 }
170 else
171 {
172- loadDynamicBitset(theExcludeFromCacheKey, ar);
173- loadDynamicBitset(theCompareWithDeepEqual, ar);
174+ loadFlags(theExcludeFromCacheKey, ar);
175+ loadFlags(theCompareWithDeepEqual, ar);
176 }
177-
178 ar & theAreCacheSettingsComputed;
179 ar & theIsCacheAutomatic;
180
181
182=== modified file 'src/functions/udf.cpp'
183--- src/functions/udf.cpp 2014-04-16 18:23:55 +0000
184+++ src/functions/udf.cpp 2014-05-01 19:54:22 +0000
185@@ -181,13 +181,13 @@
186 ar & theCacheAcrossSnapshots;
187 if (ar.is_serializing_out())
188 {
189- saveDynamicBitset(theExcludeFromCacheKey, ar);
190- saveDynamicBitset(theCompareWithDeepEqual, ar);
191+ saveFlags(theExcludeFromCacheKey, ar);
192+ saveFlags(theCompareWithDeepEqual, ar);
193 }
194 else
195 {
196- loadDynamicBitset(theExcludeFromCacheKey, ar);
197- loadDynamicBitset(theCompareWithDeepEqual, ar);
198+ loadFlags(theExcludeFromCacheKey, ar);
199+ loadFlags(theCompareWithDeepEqual, ar);
200 }
201 ar & theAreCacheSettingsComputed;
202 ar & theIsCacheAutomatic;
203
204=== modified file 'src/zorbautils/hashmap_itemh_cache.h'
205--- src/zorbautils/hashmap_itemh_cache.h 2014-04-16 18:23:55 +0000
206+++ src/zorbautils/hashmap_itemh_cache.h 2014-05-01 19:54:22 +0000
207@@ -27,7 +27,7 @@
208
209 #include "system/globalenv.h"
210
211-#include <boost/dynamic_bitset.hpp>
212+#include <vector>
213
214 namespace zorba
215 {
216@@ -39,14 +39,14 @@
217 long theTimeZone;
218 XQPCollator* theCollator;
219 static_context* theSctx;
220- boost::dynamic_bitset<> theExcludeFromCacheKey;
221- boost::dynamic_bitset<> theCompareWithDeepEqual;
222+ std::vector<bool> theExcludeFromCacheKey;
223+ std::vector<bool> theCompareWithDeepEqual;
224
225 public:
226 ItemHandleCacheHashMapCmp(
227 static_context* aSctx,
228- boost::dynamic_bitset<>& aExcludeFromCacheKey,
229- boost::dynamic_bitset<>& aCompareWithDeepEqual)
230+ std::vector<bool>& aExcludeFromCacheKey,
231+ std::vector<bool>& aCompareWithDeepEqual)
232 :
233 theTimeZone(0),
234 theCollator(NULL),
235@@ -54,14 +54,12 @@
236 theExcludeFromCacheKey(aExcludeFromCacheKey),
237 theCompareWithDeepEqual(aCompareWithDeepEqual)
238 {
239- /*if (theSctx->get_local_typemanager() == NULL)
240- theSctx->set_typemanager(new TypeManagerImpl(&GENV_TYPESYSTEM));*/
241 }
242
243 ItemHandleCacheHashMapCmp(
244 static_context* aSctx,
245- boost::dynamic_bitset<>& aExcludeFromCacheKey,
246- boost::dynamic_bitset<>& aCompareWithDeepEqual,
247+ std::vector<bool>& aExcludeFromCacheKey,
248+ std::vector<bool>& aCompareWithDeepEqual,
249 long aTimezone,
250 XQPCollator* aCollator)
251 :
252@@ -71,8 +69,6 @@
253 theExcludeFromCacheKey(aExcludeFromCacheKey),
254 theCompareWithDeepEqual(aCompareWithDeepEqual)
255 {
256- /*if (theSctx->get_local_typemanager() == NULL)
257- theSctx->set_typemanager(new TypeManagerImpl(&GENV_TYPESYSTEM));*/
258 }
259
260 bool id_equal(const store::Item* t1, const store::Item* t2) const
261@@ -200,18 +196,18 @@
262
263 for (unsigned int i=0; i<lVector1->size(); ++i)
264 {
265- if (!theExcludeFromCacheKey[i])
266+ if (!theExcludeFromCacheKey.size() || !theExcludeFromCacheKey[i])
267 {
268- if (theCompareWithDeepEqual[i])
269+ if (!theCompareWithDeepEqual.size() || !theCompareWithDeepEqual[i])
270+ {
271+ if (!id_equal(lVector1->getItem(i), lVector2->getItem(i)))
272+ return false;
273+ }
274+ else
275 {
276 if (!deep_equal(lVector1->getItem(i), lVector2->getItem(i)))
277 return false;
278 }
279- else
280- {
281- if (!id_equal(lVector1->getItem(i), lVector2->getItem(i)))
282- return false;
283- }
284 }
285 }
286 return true;
287@@ -327,12 +323,12 @@
288
289 for (unsigned int i=0; i<lVector->size(); ++i)
290 {
291- if (!theExcludeFromCacheKey[i])
292+ if (!theExcludeFromCacheKey.size() || !theExcludeFromCacheKey[i])
293 {
294- if (theCompareWithDeepEqual[i])
295+ if (!theCompareWithDeepEqual.size() || !theCompareWithDeepEqual[i])
296+ lInnerHash = id_hash(lVector->getItem(i));
297+ else
298 lInnerHash = deep_hash(lVector->getItem(i));
299- else
300- lInnerHash = id_hash(lVector->getItem(i));
301 }
302 lHash = hashfun::h32(&lInnerHash, sizeof(lInnerHash), lHash);
303 }
304@@ -368,8 +364,8 @@
305 public:
306 ItemHandleCacheHashMap(
307 static_context* aSctx,
308- boost::dynamic_bitset<>& aExcludeFromCacheKey,
309- boost::dynamic_bitset<>& aCompareWithDeepEqual)
310+ std::vector<bool>& aExcludeFromCacheKey,
311+ std::vector<bool>& aCompareWithDeepEqual)
312 :
313 theMap(
314 ItemHandleCacheHashMapCmp(aSctx, aExcludeFromCacheKey, aCompareWithDeepEqual),
315@@ -380,8 +376,8 @@
316
317 ItemHandleCacheHashMap(
318 static_context* aSctx,
319- boost::dynamic_bitset<>& aExcludeFromCacheKey,
320- boost::dynamic_bitset<>& aCompareWithDeepEqual,
321+ std::vector<bool>& aExcludeFromCacheKey,
322+ std::vector<bool>& aCompareWithDeepEqual,
323 ulong aSize,
324 bool aSync)
325 :
326@@ -394,8 +390,8 @@
327
328 ItemHandleCacheHashMap(
329 static_context* aSctx,
330- boost::dynamic_bitset<>& aExcludeFromCacheKey,
331- boost::dynamic_bitset<>& aCompareWithDeepEqual,
332+ std::vector<bool>& aExcludeFromCacheKey,
333+ std::vector<bool>& aCompareWithDeepEqual,
334 long aTimezone,
335 XQPCollator* aCollation,
336 ulong aSize,

Subscribers

People subscribed via source and target branches