drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
heap_priv.h
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16/* This file is included in all heap-files */
17#pragma once
18
19#include <config.h>
20#include <drizzled/base.h>
21
22#include "heap.h" /* Structs & some defines */
23
24#include <list>
25
26
27namespace boost {
28 class mutex;
29}
30
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
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
42 /* Some extern variables */
43
44extern std::list<HP_SHARE *> heap_share_list;
45extern std::list<HP_INFO *> heap_open_list;
46
47#define test_active(info) \
48if (!(info->update & HA_STATE_AKTIV))\
49{ errno= drizzled::HA_ERR_NO_ACTIVE_RECORD; return(-1); }
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 */
53#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->getShare()->recordspace.block,pos)
54
55#define get_chunk_status(info,ptr) (ptr[(info)->offset_status])
56
57typedef struct st_hp_hash_info
58{
59 struct st_hp_hash_info *next_key;
60 unsigned char *ptr_to_rec;
61} HASH_INFO;
62
63 /* Prototypes for intern functions */
64
65extern HP_SHARE *hp_find_named_heap(const char *name);
66extern int hp_rectest(HP_INFO *info,const unsigned char *old);
67extern unsigned char *hp_find_block(HP_BLOCK *info,uint32_t pos);
68extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length);
69extern void hp_free(HP_SHARE *info);
70extern unsigned char *hp_free_level(HP_BLOCK *block,uint32_t level,HP_PTRS *pos,
71 unsigned char *last_pos);
72extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
73 const unsigned char *record, unsigned char *recpos);
74extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
75 const unsigned char *record,unsigned char *recpos,int flag);
76extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,uint32_t pos);
77extern unsigned char *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const unsigned char *key,
78 uint32_t nextflag);
79extern unsigned char *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
80 const unsigned char *key, HASH_INFO *pos);
81extern uint32_t hp_rec_hashnr(HP_KEYDEF *keyinfo,const unsigned char *rec);
82extern uint32_t hp_mask(uint32_t hashnr,uint32_t buffmax,uint32_t maxlength);
83extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
84 HASH_INFO *newlink);
85extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec1,
86 const unsigned char *rec2,
87 bool diff_if_only_endspace_difference);
88extern void hp_make_key(HP_KEYDEF *keydef,unsigned char *key,const unsigned char *rec);
89extern bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const unsigned char *record);
90extern int hp_close(HP_INFO *info);
91extern void hp_clear(HP_SHARE *info);
92
93 /* Chunkset management (alloc/free/encode/decode) functions */
94
95extern unsigned char *hp_allocate_chunkset(HP_DATASPACE *info, uint32_t chunk_count);
96extern void hp_free_chunks(HP_DATASPACE *info, unsigned char *pos);
97extern void hp_clear_dataspace(HP_DATASPACE *info);
98
99extern uint32_t hp_get_encoded_data_length(HP_SHARE *info, const unsigned char *record, uint32_t *chunk_count);
100extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
101extern void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos);
102extern bool hp_compare_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
103
104extern boost::mutex THR_LOCK_heap;
105