16 #ifndef NDB_INDEX_STAT_IMPL_HPP
17 #define NDB_INDEX_STAT_IMPL_HPP
19 #include <ndb_global.h>
20 #include <ndb_limits.h>
21 #include <NdbDictionary.hpp>
22 #include <NdbIndexStat.hpp>
23 #include <util/NdbPack.hpp>
24 #include <NdbError.hpp>
34 extern const uint g_ndb_index_stat_head_frm_len;
35 extern const uint8 g_ndb_index_stat_head_frm_data[];
36 extern const uint g_ndb_index_stat_sample_frm_len;
37 extern const uint8 g_ndb_index_stat_sample_frm_data[];
45 enum { MaxKeyCount = MAX_INDEX_STAT_KEY_COUNT };
46 enum { MaxKeyBytes = MAX_INDEX_STAT_KEY_SIZE * 4 };
47 enum { MaxValueBytes = MAX_INDEX_STAT_VALUE_SIZE * 4 };
48 enum { MaxValueCBytes = MAX_INDEX_STAT_VALUE_CSIZE * 4 };
58 Uint32 m_indexVersion;
69 Uint8* m_valueDataBuf;
74 NdbMutex* m_query_mutex;
92 void sys_release(
Sys& sys);
100 int get_systables(
Sys& sys);
101 int create_systables(
Ndb* ndb);
102 int drop_systables(
Ndb* ndb);
103 int check_systables(
Sys& sys);
104 int check_systables(
Ndb* ndb);
120 uint m_cacheKeyOffset;
121 uint m_cacheValueOffset;
125 int startTransaction();
126 int execute(
bool commit);
127 int getNdbOperation();
128 int getNdbIndexScanOperation();
130 NDB_TICKS get_time();
139 void init_head(
Head& head);
142 int sys_init(
Con& con);
143 void sys_release(
Con& con);
144 int sys_read_head(
Con& con,
bool commit);
145 int sys_head_setkey(
Con& con);
146 int sys_head_getvalue(
Con& con);
147 int sys_sample_setkey(
Con& con);
148 int sys_sample_getvalue(
Con& con);
149 int sys_sample_setbound(
Con& con,
int sv_bound);
152 int update_stat(
Ndb* ndb,
Head& head);
153 int delete_stat(
Ndb* ndb,
Head& head);
156 int read_head(
Ndb* ndb,
Head& head);
157 int read_stat(
Ndb* ndb,
Head& head);
158 int read_start(
Con& con);
159 int read_next(
Con& con);
160 int read_commit(
Con& con);
161 int save_start(
Con& con);
162 int save_next(
Con& con);
163 int save_commit(
Con& con);
164 int cache_init(
Con& con);
165 int cache_insert(
Con& con);
166 int cache_commit(
Con& con);
174 uint m_sampleVersion;
186 mutable Uint64 m_save_time;
187 mutable Uint64 m_sort_time;
190 uint get_keyaddr(uint pos)
const;
191 void set_keyaddr(uint pos, uint addr);
193 const Uint8* get_keyptr(uint addr)
const;
194 Uint8* get_keyptr(uint addr);
195 const Uint8* get_valueptr(uint pos)
const;
196 Uint8* get_valueptr(uint pos);
198 void swap_entry(uint pos1, uint pos2);
200 double get_rir(uint pos)
const;
201 double get_rir(uint pos1, uint pos2)
const;
202 double get_unq(uint pos, uint k)
const;
203 double get_unq(uint pos1, uint pos2, uint k)
const;
204 double get_rpk(uint pos, uint k)
const;
205 double get_rpk(uint pos1, uint pos2, uint k)
const;
207 int cache_cmpaddr(
const Cache& c, uint addr1, uint addr2)
const;
208 int cache_cmppos(
const Cache& c, uint pos1, uint pos2)
const;
209 int cache_sort(
Cache& c);
210 void cache_isort(
Cache& c);
211 void cache_hsort(
Cache& c);
212 void cache_hsort_sift(
Cache& c,
int i,
int count);
213 void cache_hsort_verify(
Cache& c,
int count);
214 int cache_verify(
const Cache& c);
217 void free_cache(
Cache* c);
223 Uint32 m_sampleCount;
224 Uint32 m_sampleIndex;
240 int finalize_bound(
Bound&);
248 int finalize_range(
Range& range);
249 int convert_range(
Range& range,
257 double m_unq[MaxKeyCount];
274 const char* m_rule[3];
283 int query_keycmp(
const Cache&,
const Bound&, uint pos, Uint32& numEq);
286 int create_sysevents(
Ndb* ndb);
287 int drop_sysevents(
Ndb* ndb);
288 int check_sysevents(
Ndb* ndb);
290 int create_listener(
Ndb* ndb);
291 int execute_listener(
Ndb* ndb);
292 int poll_listener(
Ndb* ndb,
int max_wait_ms);
293 int next_listener(
Ndb* ndb);
294 int drop_listener(
Ndb* ndb);
298 virtual void* mem_alloc(UintPtr bytes);
299 virtual void mem_free(
void* ptr);
307 void setError(
int code,
int line,
int extra = 0);
308 void setError(
const Con& con,
int line);
309 void mapError(
const int* map,
int code);
317 STATIC_CONST( BoundBufWords = (2 * NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY)
318 + NDB_MAX_KEYSIZE_IN_WORDS );
323 m_data(spec, true, 0),
331 NdbIndexStatImpl::Range::Range(Bound& bound1, Bound& bound2) :
340 NdbIndexStatImpl::finalize_range(Range& range)
342 if (finalize_bound(range.m_bound1) == -1)
344 if (finalize_bound(range.m_bound2) == -1)
350 NdbIndexStatImpl::StatValue::StatValue()
356 NdbIndexStatImpl::StatBound::StatBound()
364 NdbIndexStatImpl::Stat::Stat()