~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memory/heap_priv.h

Fix merge issues with 1.0 CC fix.

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
/* This file is included in all heap-files */
17
 
#ifndef HEAPDEF_H
18
 
#define HEAPDEF_H
 
17
#pragma once
19
18
 
20
 
#include <drizzled/global.h>
 
19
#include <config.h>
21
20
#include <drizzled/base.h>
22
21
 
23
 
#include <mysys/my_sys.h>
24
 
#include <mystrings/m_ctype.h>
25
 
#include <mysys/my_pthread.h>
26
22
#include "heap.h"                       /* Structs & some defines */
27
 
#include <mysys/my_tree.h>
 
23
 
 
24
#include <list>
 
25
 
 
26
 
 
27
namespace boost {
 
28
  class mutex;
 
29
}
28
30
 
29
31
/*
30
32
  When allocating keys /rows in the internal block structure, do it
34
36
  as possible and keep memory consumption down.
35
37
*/
36
38
 
37
 
#ifdef __cplusplus
38
 
extern "C" {
39
 
#endif
40
 
 
41
 
#define HP_MIN_RECORDS_IN_BLOCK 16
42
 
#define HP_MAX_RECORDS_IN_BLOCK 8192
43
 
 
44
39
#define CHUNK_STATUS_DELETED 0    /* this chunk has been deleted and can be reused */
45
40
#define CHUNK_STATUS_ACTIVE  1    /* this chunk represents the first part of a live record */
46
 
#define CHUNK_STATUS_LINKED  2    /* this chunk is a continuation from another chunk (part of chunkset) */
47
41
 
48
42
        /* Some extern variables */
49
43
 
50
 
extern LIST *heap_open_list,*heap_share_list;
 
44
extern std::list<HP_SHARE *> heap_share_list;
 
45
extern std::list<HP_INFO *> heap_open_list;
51
46
 
52
47
#define test_active(info) \
53
48
if (!(info->update & HA_STATE_AKTIV))\
54
 
{ my_errno=HA_ERR_NO_ACTIVE_RECORD; return(-1); }
 
49
{ errno= drizzled::HA_ERR_NO_ACTIVE_RECORD; return(-1); }
55
50
#define hp_find_hash(A,B) ((HASH_INFO*) hp_find_block((A),(B)))
56
51
 
57
52
        /* Find pos for record and update it in info->current_ptr */
58
 
#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->s->recordspace.block,pos)
 
53
#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->getShare()->recordspace.block,pos)
59
54
 
60
55
#define get_chunk_status(info,ptr) (ptr[(info)->offset_status])
61
56
 
62
 
#define get_chunk_count(info,rec_length) ((rec_length + (info)->chunk_dataspace_length - 1) / (info)->chunk_dataspace_length)
63
 
 
64
57
typedef struct st_hp_hash_info
65
58
{
66
59
  struct st_hp_hash_info *next_key;
67
60
  unsigned char *ptr_to_rec;
68
61
} HASH_INFO;
69
62
 
70
 
typedef struct {
71
 
  HA_KEYSEG *keyseg;
72
 
  uint32_t key_length;
73
 
  uint32_t search_flag;
74
 
} heap_rb_param;
75
 
 
76
63
        /* Prototypes for intern functions */
77
64
 
78
65
extern HP_SHARE *hp_find_named_heap(const char *name);
81
68
extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length);
82
69
extern void hp_free(HP_SHARE *info);
83
70
extern unsigned char *hp_free_level(HP_BLOCK *block,uint32_t level,HP_PTRS *pos,
84
 
                           unsigned char *last_pos);
 
71
                                    unsigned char *last_pos);
85
72
extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
86
73
                        const unsigned char *record, unsigned char *recpos);
87
 
extern int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
88
 
                           const unsigned char *record, unsigned char *recpos);
89
 
extern int hp_rb_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
90
 
                            const unsigned char *record,unsigned char *recpos,int flag);
91
74
extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
92
75
                         const unsigned char *record,unsigned char *recpos,int flag);
93
76
extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,uint32_t pos);
95
78
                       uint32_t nextflag);
96
79
extern unsigned char *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
97
80
                            const unsigned char *key, HASH_INFO *pos);
98
 
extern uint32_t hp_hashnr(HP_KEYDEF *keyinfo,const unsigned char *key);
99
81
extern uint32_t hp_rec_hashnr(HP_KEYDEF *keyinfo,const unsigned char *rec);
100
82
extern uint32_t hp_mask(uint32_t hashnr,uint32_t buffmax,uint32_t maxlength);
101
83
extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
103
85
extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec1,
104
86
                          const unsigned char *rec2,
105
87
                          bool diff_if_only_endspace_difference);
106
 
extern int hp_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec,
107
 
                      const unsigned char *key);
108
88
extern void hp_make_key(HP_KEYDEF *keydef,unsigned char *key,const unsigned char *rec);
109
 
extern uint32_t hp_rb_make_key(HP_KEYDEF *keydef, unsigned char *key,
110
 
                           const unsigned char *rec, unsigned char *recpos);
111
 
extern uint32_t hp_rb_key_length(HP_KEYDEF *keydef, const unsigned char *key);
112
 
extern uint32_t hp_rb_null_key_length(HP_KEYDEF *keydef, const unsigned char *key);
113
 
extern uint32_t hp_rb_var_key_length(HP_KEYDEF *keydef, const unsigned char *key);
114
89
extern bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const unsigned char *record);
115
 
extern int hp_close(register HP_INFO *info);
 
90
extern int hp_close(HP_INFO *info);
116
91
extern void hp_clear(HP_SHARE *info);
117
 
extern void hp_clear_keys(HP_SHARE *info);
118
 
extern uint32_t hp_rb_pack_key(HP_KEYDEF *keydef, unsigned char *key, const unsigned char *old,
119
 
                           key_part_map keypart_map);
120
92
 
121
93
   /* Chunkset management (alloc/free/encode/decode) functions */
122
94
 
123
95
extern unsigned char *hp_allocate_chunkset(HP_DATASPACE *info, uint32_t chunk_count);
124
 
extern int hp_reallocate_chunkset(HP_DATASPACE *info, uint32_t chunk_count, unsigned char* pos);
125
96
extern void hp_free_chunks(HP_DATASPACE *info, unsigned char *pos);
126
97
extern void hp_clear_dataspace(HP_DATASPACE *info);
127
98
 
128
99
extern uint32_t hp_get_encoded_data_length(HP_SHARE *info, const unsigned char *record, uint32_t *chunk_count);
129
100
extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
130
101
extern void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos);
131
 
extern uint32_t hp_process_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos, uint32_t is_compare);
132
 
 
133
 
 
134
 
 
135
 
extern pthread_mutex_t THR_LOCK_heap;
136
 
 
137
 
#ifdef __cplusplus
138
 
}
139
 
#endif
140
 
 
141
 
#endif /* HEAPDEF_H */
 
102
extern bool hp_compare_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
 
103
 
 
104
extern boost::mutex THR_LOCK_heap;
 
105