1
by brian
clean slate |
1 |
/* Copyright (C) 2003 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
/* Key cache variable structures */
|
|
17 |
||
1122.2.10
by Monty Taylor
Fixed all of the include guards. |
18 |
#ifndef PLUGIN_MYISAM_KEYCACHE_H
|
19 |
#define PLUGIN_MYISAM_KEYCACHE_H
|
|
53.2.37
by Monty Taylor
Moved keycache code to MyISAM. |
20 |
|
21 |
enum flush_type |
|
22 |
{
|
|
23 |
FLUSH_KEEP, /* flush block and keep it in the cache */ |
|
24 |
FLUSH_RELEASE, /* flush block and remove it from the cache */ |
|
25 |
FLUSH_IGNORE_CHANGED, /* remove block from the cache */ |
|
26 |
/*
|
|
27 |
* As my_disable_flush_pagecache_blocks is always 0, the following option
|
|
28 |
* is strictly equivalent to FLUSH_KEEP
|
|
29 |
* */
|
|
30 |
FLUSH_FORCE_WRITE
|
|
31 |
};
|
|
32 |
||
1241.13.1
by Monty Taylor
Put my_off_t back... but this time localized only to myisam and mysys. |
33 |
|
1
by brian
clean slate |
34 |
/* declare structures that is used by st_key_cache */
|
35 |
||
36 |
struct st_block_link; |
|
37 |
typedef struct st_block_link BLOCK_LINK; |
|
38 |
struct st_keycache_page; |
|
39 |
typedef struct st_keycache_page KEYCACHE_PAGE; |
|
40 |
struct st_hash_link; |
|
41 |
typedef struct st_hash_link HASH_LINK; |
|
42 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
43 |
namespace drizzled |
44 |
{
|
|
45 |
namespace internal |
|
46 |
{
|
|
47 |
typedef uint64_t my_off_t; |
|
48 |
struct st_my_thread_var; |
|
49 |
}
|
|
50 |
||
1
by brian
clean slate |
51 |
/* info about requests in a waiting queue */
|
52 |
typedef struct st_keycache_wqueue |
|
53 |
{
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
54 |
drizzled::internal::st_my_thread_var *last_thread; /* circular list of waiting threads */ |
1
by brian
clean slate |
55 |
} KEYCACHE_WQUEUE; |
56 |
||
57 |
#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ |
|
58 |
||
59 |
/*
|
|
60 |
The key cache structure
|
|
61 |
It also contains read-only statistics parameters.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
62 |
*/
|
1
by brian
clean slate |
63 |
|
64 |
typedef struct st_key_cache |
|
65 |
{
|
|
281
by Brian Aker
Converted myisam away from my_bool |
66 |
bool key_cache_inited; |
67 |
bool can_be_used; /* usage of cache for read/write is allowed */ |
|
1689.2.23
by Brian Aker
Remaining keycache bits. |
68 |
|
482
by Brian Aker
Remove uint. |
69 |
uint32_t key_cache_block_size; /* size of the page buffer of a cache block */ |
1
by brian
clean slate |
70 |
|
1030.1.2
by Brian Aker
More alignment for structures |
71 |
int blocks; /* max number of blocks in the cache */ |
1
by brian
clean slate |
72 |
|
281
by Brian Aker
Converted myisam away from my_bool |
73 |
bool in_init; /* Set to 1 in MySQL during init/resize */ |
1689.2.23
by Brian Aker
Remaining keycache bits. |
74 |
|
75 |
st_key_cache(): |
|
76 |
key_cache_inited(false), |
|
77 |
can_be_used(false), |
|
78 |
key_cache_block_size(0), |
|
79 |
blocks(0), |
|
80 |
in_init(0) |
|
81 |
{ } |
|
82 |
||
1
by brian
clean slate |
83 |
} KEY_CACHE; |
84 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
85 |
} /* namespace drizzled */ |
86 |
||
1
by brian
clean slate |
87 |
/* The default key cache */
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
88 |
extern int init_key_cache(drizzled::KEY_CACHE *keycache, uint32_t key_cache_block_size, |
89 |
size_t use_mem, uint32_t division_limit, |
|
482
by Brian Aker
Remove uint. |
90 |
uint32_t age_threshold); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
91 |
extern unsigned char *key_cache_read(drizzled::KEY_CACHE *keycache, |
92 |
int file, drizzled::internal::my_off_t filepos, int level, |
|
1241.13.1
by Monty Taylor
Put my_off_t back... but this time localized only to myisam and mysys. |
93 |
unsigned char *buff, uint32_t length, |
94 |
uint32_t block_length,int return_buffer); |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
95 |
extern int key_cache_insert(drizzled::KEY_CACHE *keycache, |
96 |
int file, drizzled::internal::my_off_t filepos, int level, |
|
482
by Brian Aker
Remove uint. |
97 |
unsigned char *buff, uint32_t length); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
98 |
extern int key_cache_write(drizzled::KEY_CACHE *keycache, |
99 |
int file, drizzled::internal::my_off_t filepos, int level, |
|
482
by Brian Aker
Remove uint. |
100 |
unsigned char *buff, uint32_t length, |
101 |
uint32_t block_length,int force_write); |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
102 |
extern int flush_key_blocks(drizzled::KEY_CACHE *keycache, |
1
by brian
clean slate |
103 |
int file, enum flush_type type); |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
104 |
extern void end_key_cache(drizzled::KEY_CACHE *keycache, bool cleanup); |
1
by brian
clean slate |
105 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
106 |
/*
|
107 |
Next highest power of two
|
|
108 |
||
109 |
SYNOPSIS
|
|
110 |
my_round_up_to_next_power()
|
|
111 |
v Value to check
|
|
112 |
||
113 |
RETURN
|
|
114 |
Next or equal power of 2
|
|
115 |
Note: 0 will return 0
|
|
116 |
||
117 |
NOTES
|
|
118 |
Algorithm by Sean Anderson, according to:
|
|
119 |
http://graphics.stanford.edu/~seander/bithacks.html
|
|
120 |
(Orignal code public domain)
|
|
121 |
||
122 |
Comments shows how this works with 01100000000000000000000000001011
|
|
123 |
*/
|
|
124 |
||
125 |
static inline uint32_t my_round_up_to_next_power(uint32_t v) |
|
126 |
{
|
|
127 |
v--; /* 01100000000000000000000000001010 */ |
|
128 |
v|= v >> 1; /* 01110000000000000000000000001111 */ |
|
129 |
v|= v >> 2; /* 01111100000000000000000000001111 */ |
|
130 |
v|= v >> 4; /* 01111111110000000000000000001111 */ |
|
131 |
v|= v >> 8; /* 01111111111111111100000000001111 */ |
|
132 |
v|= v >> 16; /* 01111111111111111111111111111111 */ |
|
133 |
return v+1; /* 10000000000000000000000000000000 */ |
|
398.1.9
by Monty Taylor
Cleaned up stuff out of global.h. |
134 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
135 |
|
398.1.9
by Monty Taylor
Cleaned up stuff out of global.h. |
136 |
|
1122.2.10
by Monty Taylor
Fixed all of the include guards. |
137 |
#endif /* PLUGIN_MYISAM_KEYCACHE_H */ |