~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/heap.h

  • Committer: Lee Bieber
  • Date: 2008-11-21 21:52:58 UTC
  • mto: (590.2.7 devel)
  • mto: This revision was merged to the branch mainline in revision 603.
  • Revision ID: lb4072@soe-t2000-8-20081121215258-s86ky54w5r676o4q
changes to get build working on Solaris

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
/* This file should be included when using heap_database_functions */
17
17
/* Author: Michael Widenius */
18
18
 
19
 
#ifndef PLUGIN_HEAP_HEAP_H
20
 
#define PLUGIN_HEAP_HEAP_H
 
19
#ifndef _heap_h
 
20
#define _heap_h
 
21
#ifdef  __cplusplus
 
22
extern "C" {
 
23
#endif
21
24
 
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>
26
29
 
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>
29
32
 
30
33
        /* defines used by heap-funktions */
31
34
 
58
61
{
59
62
  /* Number of unused slots in *last_blocks HP_PTRS block (0 for 0th level) */
60
63
  uint32_t free_ptrs_in_block;
61
 
 
 
64
  
62
65
  /*
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.
66
69
  */
67
70
  uint32_t records_under_level;
68
71
 
69
72
  /*
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 
71
74
    level.
72
75
  */
73
 
  HP_PTRS *last_blocks;
 
76
  HP_PTRS *last_blocks;                 
74
77
};
75
78
 
76
79
 
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 
85
88
  lower levels.
86
89
  At the highest level there is one top block. It is stored in HP_BLOCK::root.
87
90
 
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 
89
92
  its index.
90
 
  See hp_get_new_block
 
93
  See hp_get_new_block 
91
94
*/
92
95
 
93
96
typedef struct st_heap_block
94
97
{
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.
116
119
  */
117
 
  drizzled::ha_rows hash_buckets;
118
 
  drizzled::TREE rb_tree;
 
120
  ha_rows hash_buckets; 
 
121
  TREE rb_tree;
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,
132
135
  uint16_t null_pos;                    /* position for null marker */
133
136
  uint8_t  length_bytes;  /* length of the size, 1 o 2 bytes */
134
137
} HP_COLUMNDEF;
135
 
 
 
138
 
136
139
typedef struct st_heap_dataspace   /* control data for data space */
137
140
{
138
141
  HP_BLOCK block;
167
170
  uint32_t currently_disabled_keys;    /* saved value from "keys" when disabled */
168
171
  uint32_t open_count;
169
172
 
170
 
 
 
173
  
171
174
  char * name;                  /* Name of "memory-file" */
172
 
  drizzled::THR_LOCK lock;
 
175
  THR_LOCK lock;
173
176
  pthread_mutex_t intern_lock;          /* Locking for use with _locking */
174
177
  bool delete_on_close;
 
178
  LIST open_list;
175
179
  uint32_t auto_key;
176
180
  uint32_t auto_key_type;                       /* real type of the auto key segment */
177
181
  uint64_t auto_increment;
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;
 
202
  THR_LOCK_DATA lock;
 
203
  LIST open_list;
199
204
} HP_INFO;
200
205
 
201
206
 
204
209
  uint32_t auto_key;                        /* keynr [1 - maxkey] for auto key */
205
210
  uint32_t auto_key_type;
206
211
  uint32_t max_chunk_size;
207
 
  uint32_t is_dynamic;
 
212
  uint32_t is_dynamic;  
208
213
  uint64_t max_table_size;
209
214
  uint64_t auto_increment;
210
215
  bool with_auto_increment;
233
238
 
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,
 
257
                               key_range *max_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*).
263
267
*/
264
268
 
 
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);
 
272
#endif
 
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)
 
277
#else
265
278
typedef unsigned char *HEAP_PTR;
 
279
#endif
266
280
 
267
 
#endif /* PLUGIN_HEAP_HEAP_H */
 
281
#ifdef  __cplusplus
 
282
}
 
283
#endif
 
284
#endif