~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/discrete_interval.h

  • Committer: devananda
  • Date: 2009-07-01 17:38:47 UTC
  • mto: (1093.1.7 captain)
  • mto: This revision was merged to the branch mainline in revision 1095.
  • Revision ID: devananda.vdv@gmail.com-20090701173847-3n3mbtessg5ff35e
refactored function/benchmark into plugin/benchmark

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
 
21
 
#ifndef DRIZZLED_DISCRETE_INTERVAL_H
22
 
#define DRIZZLED_DISCRETE_INTERVAL_H
23
 
 
24
 
#include <cstdlib>
25
 
 
26
 
#include "drizzled/definitions.h"
27
 
 
28
 
namespace drizzled
29
 
{
 
21
#ifndef DRIZZLED_DISCRETE_INTERVALS_H
 
22
#define DRIZZLED_DISCRETE_INTERVALS_H
30
23
 
31
24
/*
32
25
  Such interval is "discrete": it is the set of
34
27
    0 <= k <= (auto_inc_interval_values-1) }
35
28
  Where "increment" is maintained separately by the user of this class (and is
36
29
  currently only session->variables.auto_increment_increment).
37
 
  It mustn't derive from memory::SqlAlloc, because SET INSERT_ID needs to
 
30
  It mustn't derive from Sql_alloc, because SET INSERT_ID needs to
38
31
  allocate memory which must stay allocated for use by the next statement.
39
32
*/
40
33
class Discrete_interval {
54
47
    interval_min(start), interval_values(val),
55
48
    interval_max((val == UINT64_MAX) ? val : start + val * incr),
56
49
    next(NULL)
57
 
  {}
 
50
  {};
58
51
  Discrete_interval() :
59
52
    interval_min(0), interval_values(0),
60
53
    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;    }
 
54
  {};
 
55
  uint64_t minimum() const { return interval_min;    };
 
56
  uint64_t values()  const { return interval_values; };
 
57
  uint64_t maximum() const { return interval_max;    };
65
58
  /*
66
59
    If appending [3,5] to [1,2], we merge both in [1,5] (they should have the
67
60
    same increment for that, user of the class has to ensure that). That is
83
76
      return 0;
84
77
    }
85
78
    return 1;
86
 
  }
 
79
  };
87
80
};
88
81
 
89
82
 
114
107
public:
115
108
  Discrete_intervals_list() :
116
109
    head(NULL), tail(NULL),
117
 
    current(NULL), elements(0) {}
 
110
    current(NULL), elements(0) {};
118
111
  Discrete_intervals_list(const Discrete_intervals_list& from) :
119
112
    head(NULL), tail(NULL),
120
113
    current(NULL), elements(0)
150
143
      current= current->next;
151
144
    return tmp;
152
145
  }
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); }
 
146
  ~Discrete_intervals_list() { empty(); };
 
147
  uint64_t minimum()     const { return (head ? head->minimum() : 0); };
 
148
  uint64_t maximum()     const { return (head ? tail->maximum() : 0); };
156
149
  uint32_t      nb_elements() const { return elements; }
157
150
 
158
151
  bool append(uint64_t start, uint64_t val, uint64_t incr)
182
175
 
183
176
};
184
177
 
185
 
} /* namespace drizzled */
186
 
 
187
 
#endif /* DRIZZLED_DISCRETE_INTERVAL_H */
 
178
#endif /* DRIZZLED_DISCRETE_INTERVALS_H */