~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/ha0storage.h

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file include/ha0storage.h
20
21
Hash storage.
21
22
Provides a data structure that stores chunks of data in
22
23
its own storage, avoiding duplicates.
29
30
 
30
31
#include "univ.i"
31
32
 
32
 
/* This value is used by default by ha_storage_create(). More memory
 
33
/** This value is used by default by ha_storage_create(). More memory
33
34
is allocated later when/if it is needed. */
34
35
#define HA_STORAGE_DEFAULT_HEAP_BYTES   1024
35
36
 
36
 
/* This value is used by default by ha_storage_create(). It is a
 
37
/** This value is used by default by ha_storage_create(). It is a
37
38
constant per ha_storage's lifetime. */
38
39
#define HA_STORAGE_DEFAULT_HASH_CELLS   4096
39
40
 
 
41
/** Hash storage */
40
42
typedef struct ha_storage_struct        ha_storage_t;
41
43
 
42
 
/***********************************************************************
 
44
/*******************************************************************//**
43
45
Creates a hash storage. If any of the parameters is 0, then a default
44
 
value is used. */
 
46
value is used.
 
47
@return own: hash storage */
45
48
UNIV_INLINE
46
49
ha_storage_t*
47
50
ha_storage_create(
48
51
/*==============*/
49
 
                                        /* out, own: hash storage */
50
 
        ulint   initial_heap_bytes,     /* in: initial heap's size */
51
 
        ulint   initial_hash_cells);    /* in: initial number of cells
 
52
        ulint   initial_heap_bytes,     /*!< in: initial heap's size */
 
53
        ulint   initial_hash_cells);    /*!< in: initial number of cells
52
54
                                        in the hash table */
53
55
 
54
 
/***********************************************************************
 
56
/*******************************************************************//**
55
57
Copies data into the storage and returns a pointer to the copy. If the
56
58
same data chunk is already present, then pointer to it is returned.
57
59
Data chunks are considered to be equal if len1 == len2 and
59
61
data_len bytes need to be allocated) and the size of storage is going to
60
62
become more than "memlim" then "data" is not added and NULL is returned.
61
63
To disable this behavior "memlim" can be set to 0, which stands for
62
 
"no limit". */
63
 
 
 
64
"no limit".
 
65
@return pointer to the copy */
 
66
UNIV_INTERN
64
67
const void*
65
68
ha_storage_put_memlim(
66
69
/*==================*/
67
 
                                        /* out: pointer to the copy */
68
 
        ha_storage_t*   storage,        /* in/out: hash storage */
69
 
        const void*     data,           /* in: data to store */
70
 
        ulint           data_len,       /* in: data length */
71
 
        ulint           memlim);        /* in: memory limit to obey */
72
 
 
73
 
/***********************************************************************
74
 
Same as ha_storage_put_memlim() but without memory limit. */
75
 
 
 
70
        ha_storage_t*   storage,        /*!< in/out: hash storage */
 
71
        const void*     data,           /*!< in: data to store */
 
72
        ulint           data_len,       /*!< in: data length */
 
73
        ulint           memlim);        /*!< in: memory limit to obey */
 
74
 
 
75
/*******************************************************************//**
 
76
Same as ha_storage_put_memlim() but without memory limit.
 
77
@param storage  in/out: hash storage
 
78
@param data     in: data to store
 
79
@param data_len in: data length
 
80
@return         pointer to the copy of the string */
76
81
#define ha_storage_put(storage, data, data_len) \
77
82
        ha_storage_put_memlim((storage), (data), (data_len), 0)
78
83
 
79
 
/***********************************************************************
 
84
/*******************************************************************//**
80
85
Copies string into the storage and returns a pointer to the copy. If the
81
86
same string is already present, then pointer to it is returned.
82
 
Strings are considered to be equal if strcmp(str1, str2) == 0. */
83
 
 
 
87
Strings are considered to be equal if strcmp(str1, str2) == 0.
 
88
@param storage  in/out: hash storage
 
89
@param str      in: string to put
 
90
@return         pointer to the copy of the string */
84
91
#define ha_storage_put_str(storage, str)        \
85
92
        ((const char*) ha_storage_put((storage), (str), strlen(str) + 1))
86
93
 
87
 
/***********************************************************************
 
94
/*******************************************************************//**
88
95
Copies string into the storage and returns a pointer to the copy obeying
89
 
a memory limit. */
90
 
 
 
96
a memory limit.
 
97
If the same string is already present, then pointer to it is returned.
 
98
Strings are considered to be equal if strcmp(str1, str2) == 0.
 
99
@param storage  in/out: hash storage
 
100
@param str      in: string to put
 
101
@param memlim   in: memory limit to obey
 
102
@return         pointer to the copy of the string */
91
103
#define ha_storage_put_str_memlim(storage, str, memlim) \
92
104
        ((const char*) ha_storage_put_memlim((storage), (str),  \
93
105
                                             strlen(str) + 1, (memlim)))
94
106
 
95
 
/***********************************************************************
 
107
/*******************************************************************//**
96
108
Empties a hash storage, freeing memory occupied by data chunks.
97
109
This invalidates any pointers previously returned by ha_storage_put().
98
110
The hash storage is not invalidated itself and can be used again. */
100
112
void
101
113
ha_storage_empty(
102
114
/*=============*/
103
 
        ha_storage_t**  storage);       /* in/out: hash storage */
 
115
        ha_storage_t**  storage);       /*!< in/out: hash storage */
104
116
 
105
 
/***********************************************************************
 
117
/*******************************************************************//**
106
118
Frees a hash storage and everything it contains, it cannot be used after
107
119
this call.
108
 
This invalidates any pointers previously returned by ha_storage_put().
109
 
*/
 
120
This invalidates any pointers previously returned by ha_storage_put(). */
110
121
UNIV_INLINE
111
122
void
112
123
ha_storage_free(
113
124
/*============*/
114
 
        ha_storage_t*   storage);       /* in/out: hash storage */
 
125
        ha_storage_t*   storage);       /*!< in, own: hash storage */
115
126
 
116
 
/***********************************************************************
117
 
Gets the size of the memory used by a storage. */
 
127
/*******************************************************************//**
 
128
Gets the size of the memory used by a storage.
 
129
@return bytes used */
118
130
UNIV_INLINE
119
131
ulint
120
132
ha_storage_get_size(
121
133
/*================*/
122
 
                                                /* out: bytes used */
123
 
        const ha_storage_t*     storage);       /* in: hash storage */
 
134
        const ha_storage_t*     storage);       /*!< in: hash storage */
124
135
 
125
136
#ifndef UNIV_NONINL
126
137
#include "ha0storage.ic"