~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/heapdef.h

Merge/fix in FAQ.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* This file is included in all heap-files */
17
 
#ifndef PLUGIN_MEMORY_HEAP_PRIV_H
18
 
#define PLUGIN_MEMORY_HEAP_PRIV_H
19
 
 
20
 
#include <config.h>
21
 
#include <drizzled/base.h>
22
 
 
23
 
#include <drizzled/internal/my_sys.h>
24
 
#include <drizzled/charset_info.h>
25
 
#include <drizzled/internal/my_pthread.h>
 
17
 
 
18
#include <my_base.h>                    /* This includes global */
 
19
C_MODE_START
 
20
#include <my_pthread.h>
26
21
#include "heap.h"                       /* Structs & some defines */
27
 
#include <drizzled/tree.h>
28
 
#include <list>
29
 
 
30
 
#include <boost/thread/mutex.hpp>
 
22
#include "my_tree.h"
31
23
 
32
24
/*
33
25
  When allocating keys /rows in the internal block structure, do it
37
29
  as possible and keep memory consumption down.
38
30
*/
39
31
 
40
 
#define CHUNK_STATUS_DELETED 0    /* this chunk has been deleted and can be reused */
41
 
#define CHUNK_STATUS_ACTIVE  1    /* this chunk represents the first part of a live record */
 
32
#define HP_MIN_RECORDS_IN_BLOCK 16
 
33
#define HP_MAX_RECORDS_IN_BLOCK 8192
42
34
 
43
35
        /* Some extern variables */
44
36
 
45
 
extern std::list<HP_SHARE *> heap_share_list;
46
 
extern std::list<HP_INFO *> heap_open_list;
 
37
extern LIST *heap_open_list,*heap_share_list;
47
38
 
48
39
#define test_active(info) \
49
40
if (!(info->update & HA_STATE_AKTIV))\
50
 
{ errno= drizzled::HA_ERR_NO_ACTIVE_RECORD; return(-1); }
 
41
{ my_errno=HA_ERR_NO_ACTIVE_RECORD; return(-1); }
51
42
#define hp_find_hash(A,B) ((HASH_INFO*) hp_find_block((A),(B)))
52
43
 
53
44
        /* Find pos for record and update it in info->current_ptr */
54
 
#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->getShare()->recordspace.block,pos)
55
 
 
56
 
#define get_chunk_status(info,ptr) (ptr[(info)->offset_status])
 
45
#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->s->block,pos)
57
46
 
58
47
typedef struct st_hp_hash_info
59
48
{
60
49
  struct st_hp_hash_info *next_key;
61
 
  unsigned char *ptr_to_rec;
 
50
  uchar *ptr_to_rec;
62
51
} HASH_INFO;
63
52
 
 
53
typedef struct {
 
54
  HA_KEYSEG *keyseg;
 
55
  uint key_length;
 
56
  uint search_flag;
 
57
} heap_rb_param;
 
58
      
64
59
        /* Prototypes for intern functions */
65
60
 
66
61
extern HP_SHARE *hp_find_named_heap(const char *name);
67
 
extern int hp_rectest(HP_INFO *info,const unsigned char *old);
68
 
extern unsigned char *hp_find_block(HP_BLOCK *info,uint32_t pos);
 
62
extern int hp_rectest(HP_INFO *info,const uchar *old);
 
63
extern uchar *hp_find_block(HP_BLOCK *info,ulong pos);
69
64
extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length);
70
65
extern void hp_free(HP_SHARE *info);
71
 
extern unsigned char *hp_free_level(HP_BLOCK *block,uint32_t level,HP_PTRS *pos,
72
 
                                    unsigned char *last_pos);
 
66
extern uchar *hp_free_level(HP_BLOCK *block,uint level,HP_PTRS *pos,
 
67
                           uchar *last_pos);
73
68
extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
74
 
                        const unsigned char *record, unsigned char *recpos);
 
69
                        const uchar *record, uchar *recpos);
 
70
extern int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, 
 
71
                           const uchar *record, uchar *recpos);
 
72
extern int hp_rb_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
 
73
                            const uchar *record,uchar *recpos,int flag);
75
74
extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
76
 
                         const unsigned char *record,unsigned char *recpos,int flag);
77
 
extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,uint32_t pos);
78
 
extern unsigned char *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const unsigned char *key,
79
 
                       uint32_t nextflag);
80
 
extern unsigned char *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
81
 
                            const unsigned char *key, HASH_INFO *pos);
82
 
extern uint32_t hp_rec_hashnr(HP_KEYDEF *keyinfo,const unsigned char *rec);
83
 
extern uint32_t hp_mask(uint32_t hashnr,uint32_t buffmax,uint32_t maxlength);
 
75
                         const uchar *record,uchar *recpos,int flag);
 
76
extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,ulong pos);
 
77
extern uchar *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const uchar *key,
 
78
                       uint nextflag);
 
79
extern uchar *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
 
80
                            const uchar *key, HASH_INFO *pos);
 
81
extern ulong hp_hashnr(HP_KEYDEF *keyinfo,const uchar *key);
 
82
extern ulong hp_rec_hashnr(HP_KEYDEF *keyinfo,const uchar *rec);
 
83
extern ulong hp_mask(ulong hashnr,ulong buffmax,ulong maxlength);
84
84
extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
85
85
                         HASH_INFO *newlink);
86
 
extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec1,
87
 
                          const unsigned char *rec2,
88
 
                          bool diff_if_only_endspace_difference);
89
 
extern void hp_make_key(HP_KEYDEF *keydef,unsigned char *key,const unsigned char *rec);
90
 
extern bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const unsigned char *record);
91
 
extern int hp_close(HP_INFO *info);
 
86
extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const uchar *rec1,
 
87
                          const uchar *rec2,
 
88
                          my_bool diff_if_only_endspace_difference);
 
89
extern int hp_key_cmp(HP_KEYDEF *keydef,const uchar *rec,
 
90
                      const uchar *key);
 
91
extern void hp_make_key(HP_KEYDEF *keydef,uchar *key,const uchar *rec);
 
92
extern uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key,
 
93
                           const uchar *rec, uchar *recpos);
 
94
extern uint hp_rb_key_length(HP_KEYDEF *keydef, const uchar *key);
 
95
extern uint hp_rb_null_key_length(HP_KEYDEF *keydef, const uchar *key);
 
96
extern uint hp_rb_var_key_length(HP_KEYDEF *keydef, const uchar *key);
 
97
extern my_bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const uchar *record);
 
98
extern int hp_close(register HP_INFO *info);
92
99
extern void hp_clear(HP_SHARE *info);
93
 
 
94
 
   /* Chunkset management (alloc/free/encode/decode) functions */
95
 
 
96
 
extern unsigned char *hp_allocate_chunkset(HP_DATASPACE *info, uint32_t chunk_count);
97
 
extern void hp_free_chunks(HP_DATASPACE *info, unsigned char *pos);
98
 
extern void hp_clear_dataspace(HP_DATASPACE *info);
99
 
 
100
 
extern uint32_t hp_get_encoded_data_length(HP_SHARE *info, const unsigned char *record, uint32_t *chunk_count);
101
 
extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
102
 
extern void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos);
103
 
extern bool hp_compare_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
104
 
 
105
 
extern boost::mutex THR_LOCK_heap;
106
 
 
107
 
#endif /* PLUGIN_MEMORY_HEAP_PRIV_H */
 
100
extern void hp_clear_keys(HP_SHARE *info);
 
101
extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
 
102
                           key_part_map keypart_map);
 
103
extern pthread_mutex_t THR_LOCK_heap;
 
104
C_MODE_END