~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/discrete_interval.h

  • Committer: Joe Daly
  • Date: 2010-01-06 02:20:42 UTC
  • mto: This revision was merged to the branch mainline in revision 1267.
  • Revision ID: skinny.moey@gmail.com-20100106022042-8ov23wc4aq8f9k7d
rename hash_algorithm to algorithm

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
#include "drizzled/definitions.h"
27
27
 
28
 
namespace drizzled
29
 
{
30
 
 
31
28
/*
32
29
  Such interval is "discrete": it is the set of
33
30
  { auto_inc_interval_min + k * increment,
34
31
    0 <= k <= (auto_inc_interval_values-1) }
35
32
  Where "increment" is maintained separately by the user of this class (and is
36
33
  currently only session->variables.auto_increment_increment).
37
 
  It mustn't derive from memory::SqlAlloc, because SET INSERT_ID needs to
 
34
  It mustn't derive from drizzled::memory::SqlAlloc, because SET INSERT_ID needs to
38
35
  allocate memory which must stay allocated for use by the next statement.
39
36
*/
40
37
class Discrete_interval {
54
51
    interval_min(start), interval_values(val),
55
52
    interval_max((val == UINT64_MAX) ? val : start + val * incr),
56
53
    next(NULL)
57
 
  {}
 
54
  {};
58
55
  Discrete_interval() :
59
56
    interval_min(0), interval_values(0),
60
57
    interval_max(0), next(NULL)
61
 
  {}
62
 
  uint64_t minimum() const { return interval_min;    }
63
 
  uint64_t values()  const { return interval_values; }
64
 
  uint64_t maximum() const { return interval_max;    }
 
58
  {};
 
59
  uint64_t minimum() const { return interval_min;    };
 
60
  uint64_t values()  const { return interval_values; };
 
61
  uint64_t maximum() const { return interval_max;    };
65
62
  /*
66
63
    If appending [3,5] to [1,2], we merge both in [1,5] (they should have the
67
64
    same increment for that, user of the class has to ensure that). That is
83
80
      return 0;
84
81
    }
85
82
    return 1;
86
 
  }
 
83
  };
87
84
};
88
85
 
89
86
 
114
111
public:
115
112
  Discrete_intervals_list() :
116
113
    head(NULL), tail(NULL),
117
 
    current(NULL), elements(0) {}
 
114
    current(NULL), elements(0) {};
118
115
  Discrete_intervals_list(const Discrete_intervals_list& from) :
119
116
    head(NULL), tail(NULL),
120
117
    current(NULL), elements(0)
150
147
      current= current->next;
151
148
    return tmp;
152
149
  }
153
 
  ~Discrete_intervals_list() { empty(); }
154
 
  uint64_t minimum()     const { return (head ? head->minimum() : 0); }
155
 
  uint64_t maximum()     const { return (head ? tail->maximum() : 0); }
 
150
  ~Discrete_intervals_list() { empty(); };
 
151
  uint64_t minimum()     const { return (head ? head->minimum() : 0); };
 
152
  uint64_t maximum()     const { return (head ? tail->maximum() : 0); };
156
153
  uint32_t      nb_elements() const { return elements; }
157
154
 
158
155
  bool append(uint64_t start, uint64_t val, uint64_t incr)
182
179
 
183
180
};
184
181
 
185
 
} /* namespace drizzled */
186
 
 
187
182
#endif /* DRIZZLED_DISCRETE_INTERVAL_H */