1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2002, 2004 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 |
/* This file is included in all heap-files */
|
|
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
17 |
#ifndef HEAPDEF_H
|
18 |
#define HEAPDEF_H
|
|
1
by brian
clean slate |
19 |
|
612.2.13
by Monty Taylor
Work on removing global.h from headers that should be installed. |
20 |
#include <drizzled/global.h> |
21 |
#include <drizzled/base.h> |
|
22 |
||
23 |
#include <mysys/my_sys.h> |
|
24 |
#include <mystrings/m_ctype.h> |
|
212.5.13
by Monty Taylor
Moved my_sys/my_pthread/my_nosys and mysys_err to mysys. |
25 |
#include <mysys/my_pthread.h> |
1
by brian
clean slate |
26 |
#include "heap.h" /* Structs & some defines */ |
212.5.15
by Monty Taylor
Moved my_tree. |
27 |
#include <mysys/my_tree.h> |
1
by brian
clean slate |
28 |
|
29 |
/*
|
|
30 |
When allocating keys /rows in the internal block structure, do it
|
|
31 |
within the following boundaries.
|
|
32 |
||
33 |
The challenge is to find the balance between allocate as few blocks
|
|
34 |
as possible and keep memory consumption down.
|
|
35 |
*/
|
|
36 |
||
612.2.13
by Monty Taylor
Work on removing global.h from headers that should be installed. |
37 |
#ifdef __cplusplus
|
38 |
extern "C" { |
|
39 |
#endif
|
|
40 |
||
1
by brian
clean slate |
41 |
#define HP_MIN_RECORDS_IN_BLOCK 16
|
42 |
#define HP_MAX_RECORDS_IN_BLOCK 8192
|
|
43 |
||
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
44 |
#define CHUNK_STATUS_DELETED 0 /* this chunk has been deleted and can be reused */ |
45 |
#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 |
||
1
by brian
clean slate |
48 |
/* Some extern variables */
|
49 |
||
50 |
extern LIST *heap_open_list,*heap_share_list; |
|
51 |
||
52 |
#define test_active(info) \
|
|
53 |
if (!(info->update & HA_STATE_AKTIV))\
|
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
54 |
{ my_errno=HA_ERR_NO_ACTIVE_RECORD; return(-1); }
|
1
by brian
clean slate |
55 |
#define hp_find_hash(A,B) ((HASH_INFO*) hp_find_block((A),(B)))
|
56 |
||
57 |
/* Find pos for record and update it in info->current_ptr */
|
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
58 |
#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->s->recordspace.block,pos)
|
59 |
||
60 |
#define get_chunk_status(info,ptr) (ptr[(info)->offset_status])
|
|
61 |
||
62 |
#define get_chunk_count(info,rec_length) ((rec_length + (info)->chunk_dataspace_length - 1) / (info)->chunk_dataspace_length)
|
|
1
by brian
clean slate |
63 |
|
64 |
typedef struct st_hp_hash_info |
|
65 |
{
|
|
66 |
struct st_hp_hash_info *next_key; |
|
481
by Brian Aker
Remove all of uchar. |
67 |
unsigned char *ptr_to_rec; |
1
by brian
clean slate |
68 |
} HASH_INFO; |
69 |
||
70 |
typedef struct { |
|
71 |
HA_KEYSEG *keyseg; |
|
482
by Brian Aker
Remove uint. |
72 |
uint32_t key_length; |
73 |
uint32_t search_flag; |
|
1
by brian
clean slate |
74 |
} heap_rb_param; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
75 |
|
1
by brian
clean slate |
76 |
/* Prototypes for intern functions */
|
77 |
||
78 |
extern HP_SHARE *hp_find_named_heap(const char *name); |
|
481
by Brian Aker
Remove all of uchar. |
79 |
extern int hp_rectest(HP_INFO *info,const unsigned char *old); |
80 |
extern unsigned char *hp_find_block(HP_BLOCK *info,uint32_t pos); |
|
1
by brian
clean slate |
81 |
extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length); |
82 |
extern void hp_free(HP_SHARE *info); |
|
482
by Brian Aker
Remove uint. |
83 |
extern unsigned char *hp_free_level(HP_BLOCK *block,uint32_t level,HP_PTRS *pos, |
481
by Brian Aker
Remove all of uchar. |
84 |
unsigned char *last_pos); |
1
by brian
clean slate |
85 |
extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, |
481
by Brian Aker
Remove all of uchar. |
86 |
const unsigned char *record, unsigned char *recpos); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
87 |
extern int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, |
481
by Brian Aker
Remove all of uchar. |
88 |
const unsigned char *record, unsigned char *recpos); |
1
by brian
clean slate |
89 |
extern int hp_rb_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo, |
481
by Brian Aker
Remove all of uchar. |
90 |
const unsigned char *record,unsigned char *recpos,int flag); |
1
by brian
clean slate |
91 |
extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo, |
481
by Brian Aker
Remove all of uchar. |
92 |
const unsigned char *record,unsigned char *recpos,int flag); |
291
by Brian Aker
Head ulong conversion. |
93 |
extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,uint32_t pos); |
481
by Brian Aker
Remove all of uchar. |
94 |
extern unsigned char *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const unsigned char *key, |
482
by Brian Aker
Remove uint. |
95 |
uint32_t nextflag); |
481
by Brian Aker
Remove all of uchar. |
96 |
extern unsigned char *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo, |
97 |
const unsigned char *key, HASH_INFO *pos); |
|
98 |
extern uint32_t hp_hashnr(HP_KEYDEF *keyinfo,const unsigned char *key); |
|
99 |
extern uint32_t hp_rec_hashnr(HP_KEYDEF *keyinfo,const unsigned char *rec); |
|
291
by Brian Aker
Head ulong conversion. |
100 |
extern uint32_t hp_mask(uint32_t hashnr,uint32_t buffmax,uint32_t maxlength); |
1
by brian
clean slate |
101 |
extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link, |
102 |
HASH_INFO *newlink); |
|
481
by Brian Aker
Remove all of uchar. |
103 |
extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec1, |
104 |
const unsigned char *rec2, |
|
280
by Brian Aker
Removed my_bool from heap engine. |
105 |
bool diff_if_only_endspace_difference); |
481
by Brian Aker
Remove all of uchar. |
106 |
extern int hp_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec, |
107 |
const unsigned char *key); |
|
108 |
extern void hp_make_key(HP_KEYDEF *keydef,unsigned char *key,const unsigned char *rec); |
|
482
by Brian Aker
Remove uint. |
109 |
extern uint32_t hp_rb_make_key(HP_KEYDEF *keydef, unsigned char *key, |
481
by Brian Aker
Remove all of uchar. |
110 |
const unsigned char *rec, unsigned char *recpos); |
482
by Brian Aker
Remove uint. |
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); |
|
481
by Brian Aker
Remove all of uchar. |
114 |
extern bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const unsigned char *record); |
1
by brian
clean slate |
115 |
extern int hp_close(register HP_INFO *info); |
116 |
extern void hp_clear(HP_SHARE *info); |
|
117 |
extern void hp_clear_keys(HP_SHARE *info); |
|
482
by Brian Aker
Remove uint. |
118 |
extern uint32_t hp_rb_pack_key(HP_KEYDEF *keydef, unsigned char *key, const unsigned char *old, |
1
by brian
clean slate |
119 |
key_part_map keypart_map); |
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
120 |
|
121 |
/* Chunkset management (alloc/free/encode/decode) functions */
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
122 |
|
482
by Brian Aker
Remove uint. |
123 |
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); |
|
481
by Brian Aker
Remove all of uchar. |
125 |
extern void hp_free_chunks(HP_DATASPACE *info, unsigned char *pos); |
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
126 |
extern void hp_clear_dataspace(HP_DATASPACE *info); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
127 |
|
482
by Brian Aker
Remove uint. |
128 |
extern uint32_t hp_get_encoded_data_length(HP_SHARE *info, const unsigned char *record, uint32_t *chunk_count); |
481
by Brian Aker
Remove all of uchar. |
129 |
extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos); |
130 |
extern void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos); |
|
482
by Brian Aker
Remove uint. |
131 |
extern uint32_t hp_process_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos, uint32_t is_compare); |
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
132 |
|
133 |
||
134 |
||
1
by brian
clean slate |
135 |
extern pthread_mutex_t THR_LOCK_heap; |
398.1.9
by Monty Taylor
Cleaned up stuff out of global.h. |
136 |
|
137 |
#ifdef __cplusplus
|
|
138 |
}
|
|
139 |
#endif
|
|
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
140 |
|
141 |
#endif /* HEAPDEF_H */ |