~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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
1 by brian
clean slate
15
16
/* This file is included in all heap-files */
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
17
#pragma once
1 by brian
clean slate
18
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
19
#include <config.h>
612.2.13 by Monty Taylor
Work on removing global.h from headers that should be installed.
20
#include <drizzled/base.h>
21
1 by brian
clean slate
22
#include "heap.h"			/* Structs & some defines */
2241.4.3 by Stewart Smith
heap_priv doesn't need drizzled/tree.h
23
916.1.26 by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine.
24
#include <list>
1 by brian
clean slate
25
2241.4.2 by Stewart Smith
forward decl of boost mutex works fine for heap_priv mutex
26
27
namespace boost {
28
  class mutex;
29
}
1689.3.6 by Brian Aker
Update for HEAP to convert its lock to boost.
30
1 by brian
clean slate
31
/*
32
  When allocating keys /rows in the internal block structure, do it
33
  within the following boundaries.
34
35
  The challenge is to find the balance between allocate as few blocks
36
  as possible and keep memory consumption down.
37
*/
38
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
39
#define CHUNK_STATUS_DELETED 0    /* this chunk has been deleted and can be reused */
40
#define CHUNK_STATUS_ACTIVE  1    /* this chunk represents the first part of a live record */
41
1 by brian
clean slate
42
	/* Some extern variables */
43
916.1.26 by Padraig O'Sullivan
Initial work on removing LIST from the heap storage engine.
44
extern std::list<HP_SHARE *> heap_share_list;
45
extern std::list<HP_INFO *> heap_open_list;
1 by brian
clean slate
46
47
#define test_active(info) \
48
if (!(info->update & HA_STATE_AKTIV))\
2068.7.3 by Brian Aker
Merge in work for error messages being standardized by error_t
49
{ errno= drizzled::HA_ERR_NO_ACTIVE_RECORD; return(-1); }
1 by brian
clean slate
50
#define hp_find_hash(A,B) ((HASH_INFO*) hp_find_block((A),(B)))
51
52
	/* Find pos for record and update it in info->current_ptr */
1697.2.1 by Brian Aker
Encapsulate the internal share for HEAP.
53
#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->getShare()->recordspace.block,pos)
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
54
55
#define get_chunk_status(info,ptr) (ptr[(info)->offset_status])
56
1 by brian
clean slate
57
typedef struct st_hp_hash_info
58
{
59
  struct st_hp_hash_info *next_key;
481 by Brian Aker
Remove all of uchar.
60
  unsigned char *ptr_to_rec;
1 by brian
clean slate
61
} HASH_INFO;
62
63
	/* Prototypes for intern functions */
64
65
extern HP_SHARE *hp_find_named_heap(const char *name);
481 by Brian Aker
Remove all of uchar.
66
extern int hp_rectest(HP_INFO *info,const unsigned char *old);
67
extern unsigned char *hp_find_block(HP_BLOCK *info,uint32_t pos);
1 by brian
clean slate
68
extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length);
69
extern void hp_free(HP_SHARE *info);
482 by Brian Aker
Remove uint.
70
extern unsigned char *hp_free_level(HP_BLOCK *block,uint32_t level,HP_PTRS *pos,
1749.3.2 by Brian Aker
Remove dead rb calls.
71
                                    unsigned char *last_pos);
1 by brian
clean slate
72
extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
481 by Brian Aker
Remove all of uchar.
73
			const unsigned char *record, unsigned char *recpos);
1 by brian
clean slate
74
extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
481 by Brian Aker
Remove all of uchar.
75
			 const unsigned char *record,unsigned char *recpos,int flag);
291 by Brian Aker
Head ulong conversion.
76
extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,uint32_t pos);
481 by Brian Aker
Remove all of uchar.
77
extern unsigned char *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const unsigned char *key,
482 by Brian Aker
Remove uint.
78
		       uint32_t nextflag);
481 by Brian Aker
Remove all of uchar.
79
extern unsigned char *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
80
			    const unsigned char *key, HASH_INFO *pos);
81
extern uint32_t hp_rec_hashnr(HP_KEYDEF *keyinfo,const unsigned char *rec);
291 by Brian Aker
Head ulong conversion.
82
extern uint32_t hp_mask(uint32_t hashnr,uint32_t buffmax,uint32_t maxlength);
1 by brian
clean slate
83
extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
84
			 HASH_INFO *newlink);
481 by Brian Aker
Remove all of uchar.
85
extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec1,
86
			  const unsigned char *rec2,
280 by Brian Aker
Removed my_bool from heap engine.
87
                          bool diff_if_only_endspace_difference);
481 by Brian Aker
Remove all of uchar.
88
extern void hp_make_key(HP_KEYDEF *keydef,unsigned char *key,const unsigned char *rec);
89
extern bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const unsigned char *record);
916.1.27 by Padraig O'Sullivan
Removing the declaration of a variable as register. Is this really needed
90
extern int hp_close(HP_INFO *info);
1 by brian
clean slate
91
extern void hp_clear(HP_SHARE *info);
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
92
93
   /* Chunkset management (alloc/free/encode/decode) functions */
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
94
482 by Brian Aker
Remove uint.
95
extern unsigned char *hp_allocate_chunkset(HP_DATASPACE *info, uint32_t chunk_count);
481 by Brian Aker
Remove all of uchar.
96
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.
97
extern void hp_clear_dataspace(HP_DATASPACE *info);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
98
482 by Brian Aker
Remove uint.
99
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.
100
extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
101
extern void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos);
1749.3.8 by Brian Aker
Cleaned up name of calls around datachunk
102
extern bool hp_compare_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
103
1689.3.6 by Brian Aker
Update for HEAP to convert its lock to boost.
104
extern boost::mutex THR_LOCK_heap;
398.1.9 by Monty Taylor
Cleaned up stuff out of global.h.
105