~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/heap/heap_priv.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 */
17
 
#ifndef PLUGIN_HEAP_HEAP_PRIV_H
18
 
#define PLUGIN_HEAP_HEAP_PRIV_H
19
 
 
20
 
#include "config.h"
21
 
#include <drizzled/base.h>
22
 
 
23
 
#include "drizzled/internal/my_sys.h"
24
 
#include "drizzled/charset_info.h"
25
 
#include "drizzled/internal/my_pthread.h"
26
 
#include "heap.h"                       /* Structs & some defines */
27
 
#include "drizzled/my_tree.h"
28
 
#include <list>
29
 
 
30
 
/*
31
 
  When allocating keys /rows in the internal block structure, do it
32
 
  within the following boundaries.
33
 
 
34
 
  The challenge is to find the balance between allocate as few blocks
35
 
  as possible and keep memory consumption down.
36
 
*/
37
 
 
38
 
#define CHUNK_STATUS_DELETED 0    /* this chunk has been deleted and can be reused */
39
 
#define CHUNK_STATUS_ACTIVE  1    /* this chunk represents the first part of a live record */
40
 
#define CHUNK_STATUS_LINKED  2    /* this chunk is a continuation from another chunk (part of chunkset) */
41
 
 
42
 
        /* Some extern variables */
43
 
 
44
 
extern std::list<HP_SHARE *> heap_share_list;
45
 
extern std::list<HP_INFO *> heap_open_list;
46
 
 
47
 
#define test_active(info) \
48
 
if (!(info->update & HA_STATE_AKTIV))\
49
 
{ errno=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)->s->recordspace.block,pos)
54
 
 
55
 
#define get_chunk_status(info,ptr) (ptr[(info)->offset_status])
56
 
 
57
 
#define get_chunk_count(info,rec_length) ((rec_length + (info)->chunk_dataspace_length - 1) / (info)->chunk_dataspace_length)
58
 
 
59
 
typedef struct st_hp_hash_info
60
 
{
61
 
  struct st_hp_hash_info *next_key;
62
 
  unsigned char *ptr_to_rec;
63
 
} HASH_INFO;
64
 
 
65
 
typedef struct {
66
 
  HA_KEYSEG *keyseg;
67
 
  uint32_t key_length;
68
 
  uint32_t search_flag;
69
 
} heap_rb_param;
70
 
 
71
 
        /* Prototypes for intern functions */
72
 
 
73
 
extern HP_SHARE *hp_find_named_heap(const char *name);
74
 
extern int hp_rectest(HP_INFO *info,const unsigned char *old);
75
 
extern unsigned char *hp_find_block(HP_BLOCK *info,uint32_t pos);
76
 
extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length);
77
 
extern void hp_free(HP_SHARE *info);
78
 
extern unsigned char *hp_free_level(HP_BLOCK *block,uint32_t level,HP_PTRS *pos,
79
 
                           unsigned char *last_pos);
80
 
extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
81
 
                        const unsigned char *record, unsigned char *recpos);
82
 
extern int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
83
 
                           const unsigned char *record, unsigned char *recpos);
84
 
extern int hp_rb_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
85
 
                            const unsigned char *record,unsigned char *recpos,int flag);
86
 
extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
87
 
                         const unsigned char *record,unsigned char *recpos,int flag);
88
 
extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,uint32_t pos);
89
 
extern unsigned char *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const unsigned char *key,
90
 
                       uint32_t nextflag);
91
 
extern unsigned char *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
92
 
                            const unsigned char *key, HASH_INFO *pos);
93
 
extern uint32_t hp_rec_hashnr(HP_KEYDEF *keyinfo,const unsigned char *rec);
94
 
extern uint32_t hp_mask(uint32_t hashnr,uint32_t buffmax,uint32_t maxlength);
95
 
extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
96
 
                         HASH_INFO *newlink);
97
 
extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec1,
98
 
                          const unsigned char *rec2,
99
 
                          bool diff_if_only_endspace_difference);
100
 
extern void hp_make_key(HP_KEYDEF *keydef,unsigned char *key,const unsigned char *rec);
101
 
extern uint32_t hp_rb_make_key(HP_KEYDEF *keydef, unsigned char *key,
102
 
                           const unsigned char *rec, unsigned char *recpos);
103
 
extern uint32_t hp_rb_key_length(HP_KEYDEF *keydef, const unsigned char *key);
104
 
extern uint32_t hp_rb_null_key_length(HP_KEYDEF *keydef, const unsigned char *key);
105
 
extern uint32_t hp_rb_var_key_length(HP_KEYDEF *keydef, const unsigned char *key);
106
 
extern bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const unsigned char *record);
107
 
extern int hp_close(HP_INFO *info);
108
 
extern void hp_clear(HP_SHARE *info);
109
 
extern uint32_t hp_rb_pack_key(HP_KEYDEF *keydef,
110
 
                               unsigned char *key, const unsigned char *old,
111
 
                               drizzled::key_part_map keypart_map);
112
 
 
113
 
   /* Chunkset management (alloc/free/encode/decode) functions */
114
 
 
115
 
extern unsigned char *hp_allocate_chunkset(HP_DATASPACE *info, uint32_t chunk_count);
116
 
extern int hp_reallocate_chunkset(HP_DATASPACE *info, uint32_t chunk_count, unsigned char* pos);
117
 
extern void hp_free_chunks(HP_DATASPACE *info, unsigned char *pos);
118
 
extern void hp_clear_dataspace(HP_DATASPACE *info);
119
 
 
120
 
extern uint32_t hp_get_encoded_data_length(HP_SHARE *info, const unsigned char *record, uint32_t *chunk_count);
121
 
extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
122
 
extern void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos);
123
 
extern uint32_t hp_process_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos, uint32_t is_compare);
124
 
 
125
 
 
126
 
 
127
 
extern pthread_mutex_t THR_LOCK_heap;
128
 
 
129
 
#endif /* PLUGIN_HEAP_HEAP_PRIV_H */