16
16
/* This file should be included when using heap_database_functions */
17
17
/* Author: Michael Widenius */
19
#ifndef PLUGIN_HEAP_HEAP_H
20
#define PLUGIN_HEAP_HEAP_H
22
25
#include <drizzled/base.h>
23
26
#include <drizzled/common.h>
24
#include "drizzled/internal/my_pthread.h"
25
#include <drizzled/thr_lock.h>
27
#include <mysys/my_pthread.h>
28
#include <mysys/thr_lock.h>
27
#include <plugin/myisam/my_handler.h>
28
#include "drizzled/tree.h"
30
#include <storage/myisam/my_handler.h>
31
#include <mysys/my_tree.h>
30
33
/* defines used by heap-funktions */
59
62
/* Number of unused slots in *last_blocks HP_PTRS block (0 for 0th level) */
60
63
uint32_t free_ptrs_in_block;
63
66
Maximum number of records that can be 'contained' inside of each element
64
of last_blocks array. For level 0 - 1, for level 1 - HP_PTRS_IN_NOD, for
67
of last_blocks array. For level 0 - 1, for level 1 - HP_PTRS_IN_NOD, for
65
68
level 2 - HP_PTRS_IN_NOD^2 and so forth.
67
70
uint32_t records_under_level;
70
Ptr to last allocated HP_PTRS (or records buffer for level 0) on this
73
Ptr to last allocated HP_PTRS (or records buffer for level 0) on this
80
83
is recbuffer bytes.
81
84
The internal representation is as follows:
82
85
HP_BLOCK is a hierarchical structure of 'blocks'.
83
A block at level 0 is an array records_in_block records.
84
A block at higher level is an HP_PTRS structure with pointers to blocks at
86
A block at level 0 is an array records_in_block records.
87
A block at higher level is an HP_PTRS structure with pointers to blocks at
86
89
At the highest level there is one top block. It is stored in HP_BLOCK::root.
88
See hp_find_block for a description of how record pointer is obtained from
91
See hp_find_block for a description of how record pointer is obtained from
93
96
typedef struct st_heap_block
95
HP_PTRS *root; /* Top-level block */
98
HP_PTRS *root; /* Top-level block */
96
99
struct st_level_info level_info[HP_MAX_LEVELS+1];
97
100
uint32_t levels; /* number of used levels */
98
101
uint32_t records_in_block; /* Records in one heap-block */
114
117
Number of buckets used in hash table. Used only to provide
115
118
#records estimates for heap key scans.
117
drizzled::ha_rows hash_buckets;
118
drizzled::TREE rb_tree;
120
ha_rows hash_buckets;
119
122
int (*write_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
120
123
const unsigned char *record, unsigned char *recpos);
121
124
int (*delete_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
190
194
uint32_t opt_flag,update;
191
195
unsigned char *lastkey; /* Last used key with rkey */
192
196
unsigned char *recbuf; /* Record buffer for rb-tree keys */
193
enum drizzled::ha_rkey_function last_find_flag;
194
drizzled::TREE_ELEMENT *parents[drizzled::MAX_TREE_HEIGHT+1];
195
drizzled::TREE_ELEMENT **last_pos;
197
enum ha_rkey_function last_find_flag;
198
TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1];
199
TREE_ELEMENT **last_pos;
196
200
uint32_t lastkey_len;
197
201
bool implicit_emptied;
198
drizzled::THR_LOCK_DATA lock;
234
239
extern int heap_delete_table(const char *name);
235
240
extern void heap_drop_table(HP_INFO *info);
236
extern int heap_extra(HP_INFO *info,enum drizzled::ha_extra_function function);
241
extern int heap_extra(HP_INFO *info,enum ha_extra_function function);
237
242
extern int heap_reset(HP_INFO *info);
238
243
extern int heap_rename(const char *old_name,const char *new_name);
239
extern int heap_panic(enum drizzled::ha_panic_function flag);
244
extern int heap_panic(enum ha_panic_function flag);
240
245
extern int heap_rsame(HP_INFO *info,unsigned char *record,int inx);
241
246
extern int heap_rnext(HP_INFO *info,unsigned char *record);
242
247
extern int heap_rprev(HP_INFO *info,unsigned char *record);
243
248
extern int heap_rfirst(HP_INFO *info,unsigned char *record,int inx);
244
249
extern int heap_rlast(HP_INFO *info,unsigned char *record,int inx);
245
250
extern void heap_clear(HP_INFO *info);
251
extern void heap_clear_keys(HP_INFO *info);
246
252
extern int heap_disable_indexes(HP_INFO *info);
247
253
extern int heap_enable_indexes(HP_INFO *info);
248
254
extern int heap_indexes_are_disabled(HP_INFO *info);
249
255
extern void heap_update_auto_increment(HP_INFO *info, const unsigned char *record);
250
drizzled::ha_rows hp_rb_records_in_range(HP_INFO *info,
251
int inx, drizzled::key_range *min_key,
252
drizzled::key_range *max_key);
253
int hp_panic(enum drizzled::ha_panic_function flag);
256
ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key,
258
int hp_panic(enum ha_panic_function flag);
254
259
int heap_rkey(HP_INFO *info, unsigned char *record, int inx, const unsigned char *key,
255
drizzled::key_part_map keypart_map,
256
enum drizzled::ha_rkey_function find_flag);
260
key_part_map keypart_map, enum ha_rkey_function find_flag);
257
261
extern unsigned char * heap_find(HP_INFO *info,int inx,const unsigned char *key);
258
262
extern int heap_check_heap(HP_INFO *info, bool print_status);
259
263
extern unsigned char *heap_position(HP_INFO *info);
262
266
pointer to rows where a long instead of a (unsigned char*).
269
#if defined(WANT_OLD_HEAP_VERSION) || defined(OLD_HEAP_VERSION)
270
extern int heap_rrnd_old(HP_INFO *info,unsigned char *buf,uint32_t pos);
271
extern uint32_t heap_position_old(HP_INFO *info);
273
#ifdef OLD_HEAP_VERSION
274
typedef uint32_t HEAP_PTR;
275
#define heap_position(A) heap_position_old(A)
276
#define heap_rrnd(A,B,C) heap_rrnd_old(A,B,C)
265
278
typedef unsigned char *HEAP_PTR;
267
#endif /* PLUGIN_HEAP_HEAP_H */