~zorba-coders/zorba/trunk

« back to all changes in this revision

Viewing changes to src/zorbautils/hashmap_itemh_cache.h

  • Committer: Zorba Jenkins
  • Author(s): Federico Cavalieri
  • Date: 2014-05-02 10:33:24 UTC
  • mfrom: (11721.1.1 trunk)
  • Revision ID: jenkins@lambda.nu-20140502103324-7pt8ik0rwbiwah2c
Removed boost dependency
Fixed typedef
Approved: Paul J. Lucas, Matthias Brantner, Federico Cavalieri

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include "system/globalenv.h"
29
29
 
30
 
#include <boost/dynamic_bitset.hpp>
 
30
#include <vector>
31
31
 
32
32
namespace zorba 
33
33
39
39
  long theTimeZone;
40
40
  XQPCollator* theCollator;
41
41
  static_context* theSctx;
42
 
  boost::dynamic_bitset<> theExcludeFromCacheKey;
43
 
  boost::dynamic_bitset<> theCompareWithDeepEqual;
 
42
  std::vector<bool> theExcludeFromCacheKey;
 
43
  std::vector<bool> theCompareWithDeepEqual;
44
44
 
45
45
public:
46
46
  ItemHandleCacheHashMapCmp(
47
47
      static_context* aSctx,
48
 
      boost::dynamic_bitset<>& aExcludeFromCacheKey,
49
 
      boost::dynamic_bitset<>& aCompareWithDeepEqual)
 
48
      std::vector<bool>& aExcludeFromCacheKey,
 
49
      std::vector<bool>& aCompareWithDeepEqual)
50
50
    :
51
51
    theTimeZone(0),
52
52
    theCollator(NULL),
54
54
    theExcludeFromCacheKey(aExcludeFromCacheKey),
55
55
    theCompareWithDeepEqual(aCompareWithDeepEqual)
56
56
  {
57
 
    /*if (theSctx->get_local_typemanager() == NULL)
58
 
      theSctx->set_typemanager(new TypeManagerImpl(&GENV_TYPESYSTEM));*/
59
57
  }
60
58
 
61
59
  ItemHandleCacheHashMapCmp(
62
60
      static_context* aSctx,
63
 
      boost::dynamic_bitset<>& aExcludeFromCacheKey,
64
 
      boost::dynamic_bitset<>& aCompareWithDeepEqual,
 
61
      std::vector<bool>& aExcludeFromCacheKey,
 
62
      std::vector<bool>& aCompareWithDeepEqual,
65
63
      long aTimezone,
66
64
      XQPCollator* aCollator)
67
65
    :
71
69
    theExcludeFromCacheKey(aExcludeFromCacheKey),
72
70
    theCompareWithDeepEqual(aCompareWithDeepEqual)
73
71
  {
74
 
    /*if (theSctx->get_local_typemanager() == NULL)
75
 
      theSctx->set_typemanager(new TypeManagerImpl(&GENV_TYPESYSTEM));*/
76
72
  }
77
73
 
78
74
  bool id_equal(const store::Item* t1, const store::Item* t2) const
200
196
 
201
197
    for (unsigned int i=0; i<lVector1->size(); ++i)
202
198
    {
203
 
      if (!theExcludeFromCacheKey[i])
 
199
      if (!theExcludeFromCacheKey.size() || !theExcludeFromCacheKey[i])
204
200
      {
205
 
        if (theCompareWithDeepEqual[i])
 
201
        if (!theCompareWithDeepEqual.size() || !theCompareWithDeepEqual[i])
 
202
        {
 
203
          if (!id_equal(lVector1->getItem(i), lVector2->getItem(i)))
 
204
            return false;
 
205
        }
 
206
        else
206
207
        {
207
208
          if (!deep_equal(lVector1->getItem(i), lVector2->getItem(i)))
208
209
            return false;
209
210
        }
210
 
        else
211
 
        {
212
 
          if (!id_equal(lVector1->getItem(i), lVector2->getItem(i)))
213
 
            return false;
214
 
        }
215
211
      }
216
212
    }
217
213
    return true;
327
323
 
328
324
    for (unsigned int i=0; i<lVector->size(); ++i)
329
325
    {
330
 
      if (!theExcludeFromCacheKey[i])
 
326
      if (!theExcludeFromCacheKey.size() || !theExcludeFromCacheKey[i])
331
327
      {
332
 
        if (theCompareWithDeepEqual[i])
 
328
        if (!theCompareWithDeepEqual.size() || !theCompareWithDeepEqual[i])
 
329
          lInnerHash = id_hash(lVector->getItem(i));
 
330
        else
333
331
          lInnerHash = deep_hash(lVector->getItem(i));
334
 
        else
335
 
          lInnerHash = id_hash(lVector->getItem(i));
336
332
      }
337
333
      lHash = hashfun::h32(&lInnerHash, sizeof(lInnerHash), lHash);
338
334
    }
368
364
public:
369
365
  ItemHandleCacheHashMap(
370
366
      static_context* aSctx,
371
 
      boost::dynamic_bitset<>& aExcludeFromCacheKey,
372
 
      boost::dynamic_bitset<>& aCompareWithDeepEqual)
 
367
      std::vector<bool>& aExcludeFromCacheKey,
 
368
      std::vector<bool>& aCompareWithDeepEqual)
373
369
:
374
370
  theMap(
375
371
    ItemHandleCacheHashMapCmp(aSctx, aExcludeFromCacheKey, aCompareWithDeepEqual),
380
376
 
381
377
  ItemHandleCacheHashMap(
382
378
      static_context* aSctx,
383
 
      boost::dynamic_bitset<>& aExcludeFromCacheKey,
384
 
      boost::dynamic_bitset<>& aCompareWithDeepEqual,
 
379
      std::vector<bool>& aExcludeFromCacheKey,
 
380
      std::vector<bool>& aCompareWithDeepEqual,
385
381
      ulong aSize,
386
382
      bool aSync)
387
383
  :
394
390
 
395
391
  ItemHandleCacheHashMap(
396
392
      static_context* aSctx,
397
 
      boost::dynamic_bitset<>& aExcludeFromCacheKey,
398
 
      boost::dynamic_bitset<>& aCompareWithDeepEqual,
 
393
      std::vector<bool>& aExcludeFromCacheKey,
 
394
      std::vector<bool>& aCompareWithDeepEqual,
399
395
      long aTimezone,
400
396
      XQPCollator* aCollation,
401
397
      ulong aSize,