~drizzle-trunk/drizzle/development

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