~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/keycache.h

  • Committer: Monty Taylor
  • Date: 2010-02-04 08:14:46 UTC
  • mfrom: (1277.2.1 build) (1280.2.1 build)
  • mto: This revision was merged to the branch mainline in revision 1283.
  • Revision ID: mordred@inaugust.com-20100204081446-ldh9m486va30uap6
Put everything in drizzled into drizzled namespace.
Put internal stuff into drizzled::internal namespace.
Removed some cruft.
Now every symbol that is shipped in a header is in the drizzled namespace
and everything in the server that's not shipped is labeled internal. woot. 
Removed a lot of the extra extern "C" stuff that was in there. Less ugliness for
internal callbacks now for Sun Studio.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#ifndef PLUGIN_MYISAM_KEYCACHE_H
19
19
#define PLUGIN_MYISAM_KEYCACHE_H
20
20
 
21
 
#ifdef __cplusplus
22
 
extern "C" {
23
 
#endif
24
 
 
25
21
enum flush_type
26
22
{
27
23
  FLUSH_KEEP,           /* flush block and keep it in the cache */
34
30
  FLUSH_FORCE_WRITE
35
31
};
36
32
 
37
 
typedef uint64_t my_off_t;
38
33
 
39
34
/* declare structures that is used by st_key_cache */
40
35
 
45
40
struct st_hash_link;
46
41
typedef struct st_hash_link HASH_LINK;
47
42
 
 
43
namespace drizzled
 
44
{
 
45
namespace internal
 
46
{
 
47
typedef uint64_t my_off_t;
 
48
struct st_my_thread_var;
 
49
}
 
50
 
48
51
/* info about requests in a waiting queue */
49
52
typedef struct st_keycache_wqueue
50
53
{
51
 
  struct st_my_thread_var *last_thread;  /* circular list of waiting threads */
 
54
  drizzled::internal::st_my_thread_var *last_thread;  /* circular list of waiting threads */
52
55
} KEYCACHE_WQUEUE;
53
56
 
54
57
#define CHANGED_BLOCKS_HASH 128             /* must be power of 2 */
120
123
  bool in_init;         /* Set to 1 in MySQL during init/resize     */
121
124
} KEY_CACHE;
122
125
 
 
126
} /* namespace drizzled */
 
127
 
123
128
/* The default key cache */
124
 
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
 
129
extern drizzled::KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
125
130
 
126
 
extern int init_key_cache(KEY_CACHE *keycache, uint32_t key_cache_block_size,
127
 
                          uint32_t use_mem, uint32_t division_limit,
 
131
extern int init_key_cache(drizzled::KEY_CACHE *keycache, uint32_t key_cache_block_size,
 
132
                          size_t use_mem, uint32_t division_limit,
128
133
                          uint32_t age_threshold);
129
 
extern int resize_key_cache(KEY_CACHE *keycache, uint32_t key_cache_block_size,
130
 
                            uint32_t use_mem, uint32_t division_limit,
 
134
extern int resize_key_cache(drizzled::KEY_CACHE *keycache, uint32_t key_cache_block_size,
 
135
                            size_t use_mem, uint32_t division_limit,
131
136
                            uint32_t age_threshold);
132
 
extern unsigned char *key_cache_read(KEY_CACHE *keycache,
133
 
                            int file, my_off_t filepos, int level,
 
137
extern unsigned char *key_cache_read(drizzled::KEY_CACHE *keycache,
 
138
                            int file, drizzled::internal::my_off_t filepos, int level,
134
139
                            unsigned char *buff, uint32_t length,
135
140
                            uint32_t block_length,int return_buffer);
136
 
extern int key_cache_insert(KEY_CACHE *keycache,
137
 
                            int file, my_off_t filepos, int level,
 
141
extern int key_cache_insert(drizzled::KEY_CACHE *keycache,
 
142
                            int file, drizzled::internal::my_off_t filepos, int level,
138
143
                            unsigned char *buff, uint32_t length);
139
 
extern int key_cache_write(KEY_CACHE *keycache,
140
 
                           int file, my_off_t filepos, int level,
 
144
extern int key_cache_write(drizzled::KEY_CACHE *keycache,
 
145
                           int file, drizzled::internal::my_off_t filepos, int level,
141
146
                           unsigned char *buff, uint32_t length,
142
147
                           uint32_t block_length,int force_write);
143
 
extern int flush_key_blocks(KEY_CACHE *keycache,
 
148
extern int flush_key_blocks(drizzled::KEY_CACHE *keycache,
144
149
                            int file, enum flush_type type);
145
 
extern void end_key_cache(KEY_CACHE *keycache, bool cleanup);
 
150
extern void end_key_cache(drizzled::KEY_CACHE *keycache, bool cleanup);
146
151
 
147
152
extern void reset_key_cache_counters();
148
153
 
149
 
#ifdef __cplusplus
 
154
/*
 
155
  Next highest power of two
 
156
 
 
157
  SYNOPSIS
 
158
    my_round_up_to_next_power()
 
159
    v           Value to check
 
160
 
 
161
  RETURN
 
162
    Next or equal power of 2
 
163
    Note: 0 will return 0
 
164
 
 
165
  NOTES
 
166
    Algorithm by Sean Anderson, according to:
 
167
    http://graphics.stanford.edu/~seander/bithacks.html
 
168
    (Orignal code public domain)
 
169
 
 
170
    Comments shows how this works with 01100000000000000000000000001011
 
171
*/
 
172
 
 
173
static inline uint32_t my_round_up_to_next_power(uint32_t v)
 
174
{
 
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 */
150
182
}
151
 
#endif
 
183
 
152
184
 
153
185
#endif /* PLUGIN_MYISAM_KEYCACHE_H */