123
118
bool in_init; /* Set to 1 in MySQL during init/resize */
126
} /* namespace drizzled */
128
121
/* The default key cache */
129
extern drizzled::KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
122
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
131
extern int init_key_cache(drizzled::KEY_CACHE *keycache, uint32_t key_cache_block_size,
124
extern int init_key_cache(KEY_CACHE *keycache, uint32_t key_cache_block_size,
132
125
size_t use_mem, uint32_t division_limit,
133
126
uint32_t age_threshold);
134
extern int resize_key_cache(drizzled::KEY_CACHE *keycache, uint32_t key_cache_block_size,
127
extern int resize_key_cache(KEY_CACHE *keycache, uint32_t key_cache_block_size,
135
128
size_t use_mem, uint32_t division_limit,
136
129
uint32_t age_threshold);
137
extern unsigned char *key_cache_read(drizzled::KEY_CACHE *keycache,
138
int file, drizzled::internal::my_off_t filepos, int level,
130
extern unsigned char *key_cache_read(KEY_CACHE *keycache,
131
File file, my_off_t filepos, int level,
139
132
unsigned char *buff, uint32_t length,
140
133
uint32_t block_length,int return_buffer);
141
extern int key_cache_insert(drizzled::KEY_CACHE *keycache,
142
int file, drizzled::internal::my_off_t filepos, int level,
134
extern int key_cache_insert(KEY_CACHE *keycache,
135
File file, my_off_t filepos, int level,
143
136
unsigned char *buff, uint32_t length);
144
extern int key_cache_write(drizzled::KEY_CACHE *keycache,
145
int file, drizzled::internal::my_off_t filepos, int level,
137
extern int key_cache_write(KEY_CACHE *keycache,
138
File file, my_off_t filepos, int level,
146
139
unsigned char *buff, uint32_t length,
147
140
uint32_t block_length,int force_write);
148
extern int flush_key_blocks(drizzled::KEY_CACHE *keycache,
141
extern int flush_key_blocks(KEY_CACHE *keycache,
149
142
int file, enum flush_type type);
150
extern void end_key_cache(drizzled::KEY_CACHE *keycache, bool cleanup);
143
extern void end_key_cache(KEY_CACHE *keycache, bool cleanup);
152
145
extern void reset_key_cache_counters();
155
Next highest power of two
158
my_round_up_to_next_power()
162
Next or equal power of 2
163
Note: 0 will return 0
166
Algorithm by Sean Anderson, according to:
167
http://graphics.stanford.edu/~seander/bithacks.html
168
(Orignal code public domain)
170
Comments shows how this works with 01100000000000000000000000001011
173
static inline uint32_t my_round_up_to_next_power(uint32_t v)
175
v--; /* 01100000000000000000000000001010 */
176
v|= v >> 1; /* 01110000000000000000000000001111 */
177
v|= v >> 2; /* 01111100000000000000000000001111 */
178
v|= v >> 4; /* 01111111110000000000000000001111 */
179
v|= v >> 8; /* 01111111111111111100000000001111 */
180
v|= v >> 16; /* 01111111111111111111111111111111 */
181
return v+1; /* 10000000000000000000000000000000 */
185
151
#endif /* PLUGIN_MYISAM_KEYCACHE_H */