~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_bitmap.h

  • Committer: Monty Taylor
  • Date: 2009-05-08 19:27:21 UTC
  • mto: This revision was merged to the branch mainline in revision 1009.
  • Revision ID: mordred@inaugust.com-20090508192721-glbsg850k7wqp1rd
Further reversion of P.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
/// TODO: OMG FIX THIS
30
30
 
31
31
#include <mysys/my_bitmap.h>
32
 
#include <drizzled/definitions.h>
33
32
#include <drizzled/util/test.h>
34
33
 
35
 
#include <bitset>
36
 
 
37
34
template <uint32_t default_width> class Bitmap
38
35
{
39
36
  MY_BITMAP map;
218
215
extern const key_map key_map_empty;
219
216
extern key_map key_map_full;          /* Should be threaded as const */
220
217
 
221
 
/*
222
 
 * Class to be used when a thread safe version of std::bitset
223
 
 * is needed. We just use a lock here to protect any modifications
224
 
 * to the bitset.
225
 
 */
226
 
class ThreadSafeBitset
227
 
{
228
 
public:
229
 
  ThreadSafeBitset()
230
 
  {
231
 
    pthread_mutex_init(&mutex, NULL);
232
 
  }
233
 
  ~ThreadSafeBitset()
234
 
  {
235
 
    pthread_mutex_destroy(&mutex);
236
 
  }
237
 
  /*
238
 
   * Resets a bit at the given bit position.
239
 
   *
240
 
   * @param position of the bit to reset
241
 
   */
242
 
  void resetBit(uint32_t pos);
243
 
  /*
244
 
   * Finds the first bit that is not set and sets
245
 
   * it.
246
 
   */
247
 
  uint32_t setNextBit();
248
 
private:
249
 
  std::bitset<MAX_FIELDS> bitmap;
250
 
  pthread_mutex_t mutex;
251
 
};
252
 
 
253
 
/*
254
 
 * Returns the position of the first bit in the
255
 
 * given bitmap which is not set. If every bit is set
256
 
 * in the bitmap, return MY_BIT_NONE.
257
 
 *
258
 
 * @param the bitmap to work with
259
 
 */
260
 
uint32_t getFirstBitPos(const std::bitset<MAX_FIELDS> &bitmap);
261
 
 
262
 
/*
263
 
 * Returns true if map1 is a subset of map2; otherwise,
264
 
 * it returns false.
265
 
 *
266
 
 * @param the bitmap to check with
267
 
 * @param the bitmap to check against
268
 
 */
269
 
bool isBitmapSubset(const std::bitset<MAX_FIELDS> *map1, const std::bitset<MAX_FIELDS> *map2);
270
 
 
271
 
/*
272
 
 * Returns true if there is any overlapping bits between
273
 
 * the 2 given bitmaps.
274
 
 *
275
 
 * @param the first bitmap to work with
276
 
 * @param the second bitmap to work with
277
 
 */
278
 
bool isBitmapOverlapping(const std::bitset<MAX_FIELDS> *map1, const std::bitset<MAX_FIELDS> *map2);
279
 
 
280
218
#endif /* _SQL_BITMAP_H_ */