Drizzled Public API Documentation

heap_priv.h
00001 /* Copyright (C) 2000-2002, 2004 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 /* This file is included in all heap-files */
00017 #pragma once
00018 
00019 #include <config.h>
00020 #include <drizzled/base.h>
00021 
00022 #include <drizzled/internal/my_sys.h>
00023 #include <drizzled/charset_info.h>
00024 #include <drizzled/internal/my_pthread.h>
00025 #include "heap.h"     /* Structs & some defines */
00026 #include <drizzled/tree.h>
00027 #include <list>
00028 
00029 #include <boost/thread/mutex.hpp>
00030 
00031 /*
00032   When allocating keys /rows in the internal block structure, do it
00033   within the following boundaries.
00034 
00035   The challenge is to find the balance between allocate as few blocks
00036   as possible and keep memory consumption down.
00037 */
00038 
00039 #define CHUNK_STATUS_DELETED 0    /* this chunk has been deleted and can be reused */
00040 #define CHUNK_STATUS_ACTIVE  1    /* this chunk represents the first part of a live record */
00041 
00042   /* Some extern variables */
00043 
00044 extern std::list<HP_SHARE *> heap_share_list;
00045 extern std::list<HP_INFO *> heap_open_list;
00046 
00047 #define test_active(info) \
00048 if (!(info->update & HA_STATE_AKTIV))\
00049 { errno= drizzled::HA_ERR_NO_ACTIVE_RECORD; return(-1); }
00050 #define hp_find_hash(A,B) ((HASH_INFO*) hp_find_block((A),(B)))
00051 
00052   /* Find pos for record and update it in info->current_ptr */
00053 #define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->getShare()->recordspace.block,pos)
00054 
00055 #define get_chunk_status(info,ptr) (ptr[(info)->offset_status])
00056 
00057 typedef struct st_hp_hash_info
00058 {
00059   struct st_hp_hash_info *next_key;
00060   unsigned char *ptr_to_rec;
00061 } HASH_INFO;
00062 
00063   /* Prototypes for intern functions */
00064 
00065 extern HP_SHARE *hp_find_named_heap(const char *name);
00066 extern int hp_rectest(HP_INFO *info,const unsigned char *old);
00067 extern unsigned char *hp_find_block(HP_BLOCK *info,uint32_t pos);
00068 extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length);
00069 extern void hp_free(HP_SHARE *info);
00070 extern unsigned char *hp_free_level(HP_BLOCK *block,uint32_t level,HP_PTRS *pos,
00071                                     unsigned char *last_pos);
00072 extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo,
00073       const unsigned char *record, unsigned char *recpos);
00074 extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo,
00075        const unsigned char *record,unsigned char *recpos,int flag);
00076 extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,uint32_t pos);
00077 extern unsigned char *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const unsigned char *key,
00078            uint32_t nextflag);
00079 extern unsigned char *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
00080           const unsigned char *key, HASH_INFO *pos);
00081 extern uint32_t hp_rec_hashnr(HP_KEYDEF *keyinfo,const unsigned char *rec);
00082 extern uint32_t hp_mask(uint32_t hashnr,uint32_t buffmax,uint32_t maxlength);
00083 extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
00084        HASH_INFO *newlink);
00085 extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const unsigned char *rec1,
00086         const unsigned char *rec2,
00087                           bool diff_if_only_endspace_difference);
00088 extern void hp_make_key(HP_KEYDEF *keydef,unsigned char *key,const unsigned char *rec);
00089 extern bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const unsigned char *record);
00090 extern int hp_close(HP_INFO *info);
00091 extern void hp_clear(HP_SHARE *info);
00092 
00093    /* Chunkset management (alloc/free/encode/decode) functions */
00094 
00095 extern unsigned char *hp_allocate_chunkset(HP_DATASPACE *info, uint32_t chunk_count);
00096 extern void hp_free_chunks(HP_DATASPACE *info, unsigned char *pos);
00097 extern void hp_clear_dataspace(HP_DATASPACE *info);
00098 
00099 extern uint32_t hp_get_encoded_data_length(HP_SHARE *info, const unsigned char *record, uint32_t *chunk_count);
00100 extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
00101 extern void hp_extract_record(HP_SHARE *info, unsigned char *record, const unsigned char *pos);
00102 extern bool hp_compare_record_data_to_chunkset(HP_SHARE *info, const unsigned char *record, unsigned char *pos);
00103 
00104 extern boost::mutex THR_LOCK_heap;
00105