Dictionary< K, V > Class Template Reference

#include <Dictionary.h>

Inheritance diagram for Dictionary< K, V >:
Collaboration diagram for Dictionary< K, V >:

Public Member Functions

 ~Dictionary ()
 
ion_err_t initializeDictionary (ion_dictionary_id_t dict_id, ion_key_type_t k_type, ion_key_size_t k_size, ion_value_size_t v_size, ion_dictionary_size_t dictionary_size)
 Creates a dictionary with a specific identifier (for use through the master table). More...
 
ion_status_t insert (K key, V value)
 Insert a value into a dictionary. More...
 
get (K key)
 Retrieve a value given a key. More...
 
ion_status_t deleteRecord (K key)
 Delete a value given a key. More...
 
ion_status_t update (K key, V value)
 Update all records with a given key. More...
 
ion_err_t deleteDictionary ()
 Deletes dictionary. More...
 
ion_err_t destroyDictionary (ion_dictionary_id_t id)
 Destroys dictionary. More...
 
ion_err_t open (ion_dictionary_config_info_t config_info)
 Opens a dictionary, given the desired config. More...
 
ion_err_t close ()
 Closes a dictionary. More...
 
Cursor< K, V > * range (K min_key, K max_key)
 Sets up cursor and predicate to perform a range query on a dictionary. More...
 
Cursor< K, V > * equality (K key)
 Sets up cursor and predicate perform an equality query on a dictionary for a given key. More...
 
Cursor< K, V > * allRecords ()
 Sets up cursor and predicate in order to find all records present in the dictionary. More...
 

Public Attributes

ion_dictionary_handler_t handler
 
ion_dictionary_t dict
 
ion_key_type_t key_type
 
ion_key_size_t key_size
 
ion_value_size_t value_size
 
ion_dictionary_size_t dict_size
 
ion_status_t last_status
 

Detailed Description

template<typename K, typename V>
class Dictionary< K, V >

Definition at line 49 of file Dictionary.h.

Constructor & Destructor Documentation

template<typename K, typename V>
Dictionary< K, V >::~Dictionary ( )
inline

Definition at line 60 of file Dictionary.h.

61  {
62  this->deleteDictionary();
63 }
ion_err_t deleteDictionary()
Deletes dictionary.
Definition: Dictionary.h:196

Here is the call graph for this function:

Member Function Documentation

template<typename K, typename V>
Cursor<K, V>* Dictionary< K, V >::allRecords ( )
inline

Sets up cursor and predicate in order to find all records present in the dictionary.

Returns
An initialized cursor for the particular query.

Definition at line 306 of file Dictionary.h.

307  {
309 
311  return new Cursor<K, V>(&dict, &predicate);
312 }
Definition: Cursor.h:42
A supertype for cursor predicate objects.
ion_dictionary_t dict
Definition: Dictionary.h:53
ion_err_t dictionary_build_predicate(ion_predicate_t *predicate, ion_predicate_type_t type,...)
Builds a predicate based on the type given.
Definition: dictionary.c:512

Here is the call graph for this function:

template<typename K, typename V>
ion_err_t Dictionary< K, V >::close ( )
inline

Closes a dictionary.

Definition at line 248 of file Dictionary.h.

249  {
251 
252  last_status.error = err;
253 
254  return err;
255 }
ion_err_t error
Definition: kv_system.h:291
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_status_t last_status
Definition: Dictionary.h:58
ion_err_t dictionary_close(ion_dictionary_t *dictionary)
Closes a dictionary.
Definition: dictionary.c:372
ion_dictionary_t dict
Definition: Dictionary.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename K, typename V>
ion_err_t Dictionary< K, V >::deleteDictionary ( )
inline

Deletes dictionary.

Returns
An error message describing the total destruction of the dictionary.

Definition at line 196 of file Dictionary.h.

197  {
199 
200  last_status.error = err;
201 
202  return err;
203 }
ion_err_t error
Definition: kv_system.h:291
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_err_t dictionary_delete_dictionary(ion_dictionary_t *dictionary)
Destroys dictionary.
Definition: dictionary.c:178
ion_status_t last_status
Definition: Dictionary.h:58
ion_dictionary_t dict
Definition: Dictionary.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename K, typename V>
ion_status_t Dictionary< K, V >::deleteRecord ( key)
inline

Delete a value given a key.

Parameters
keyThe key to be deleted.
Returns
An error message describing the result of the deletion.

Definition at line 156 of file Dictionary.h.

158  {
159  ion_key_t ion_key = &key;
160  ion_status_t status = dictionary_delete(&dict, ion_key);
161 
162  this->last_status = status;
163 
164  return status;
165 }
#define key(k)
Definition: bpp_tree.c:75
ion_status_t dictionary_delete(ion_dictionary_t *dictionary, ion_key_t key)
Delete a value given a key.
Definition: dictionary.c:199
void * ion_key_t
A dictionary key.
Definition: kv_system.h:241
ion_status_t last_status
Definition: Dictionary.h:58
ion_dictionary_t dict
Definition: Dictionary.h:53
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Here is the call graph for this function:

template<typename K, typename V>
ion_err_t Dictionary< K, V >::destroyDictionary ( ion_dictionary_id_t  id)
inline

Destroys dictionary.

Parameters
idThe identifier identifying the dictionary to destroy.
Returns
The status of the total destruction of the dictionary.

Definition at line 212 of file Dictionary.h.

214  {
216 
218 
219  return error;
220 }
ion_err_t error
Definition: kv_system.h:291
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_err_t dictionary_destroy_dictionary(ion_dictionary_handler_t *handler, ion_dictionary_id_t id)
Destroys dictionary.
Definition: dictionary.c:185
ion_status_t last_status
Definition: Dictionary.h:58
ion_dictionary_handler_t handler
Definition: Dictionary.h:52
#define error(rc)
Definition: bpp_tree.c:151

Here is the call graph for this function:

template<typename K, typename V>
Cursor<K, V>* Dictionary< K, V >::equality ( key)
inline

Sets up cursor and predicate perform an equality query on a dictionary for a given key.

Parameters
keyThe key used to determine equality.
Returns
An initialized cursor for the particular query.

Definition at line 289 of file Dictionary.h.

291  {
293  ion_key_t ion_key = &key;
294 
295  dictionary_build_predicate(&predicate, predicate_equality, ion_key);
296  return new Cursor<K, V>(&dict, &predicate);
297 }
#define key(k)
Definition: bpp_tree.c:75
void * ion_key_t
A dictionary key.
Definition: kv_system.h:241
Definition: Cursor.h:42
A supertype for cursor predicate objects.
ion_dictionary_t dict
Definition: Dictionary.h:53
ion_err_t dictionary_build_predicate(ion_predicate_t *predicate, ion_predicate_type_t type,...)
Builds a predicate based on the type given.
Definition: dictionary.c:512

Here is the call graph for this function:

template<typename K, typename V>
V Dictionary< K, V >::get ( key)
inline

Retrieve a value given a key.

Parameters
keyThe key to retrieve the value for.
Returns
value A pointer to the value byte array to copy data into.

Definition at line 137 of file Dictionary.h.

139  {
140  ion_key_t ion_key = &key;
142 
143  this->last_status = dictionary_get(&dict, ion_key, ion_value);
144 
145  return *((V *) ion_value);
146 }
unsigned char ion_byte_t
A byte type.
Definition: kv_system.h:232
ion_record_info_t record
ion_dictionary_parent_t * instance
#define key(k)
Definition: bpp_tree.c:75
void * ion_key_t
A dictionary key.
Definition: kv_system.h:241
ion_status_t dictionary_get(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Retrieve a value given a key.
Definition: dictionary.c:160
ion_status_t last_status
Definition: Dictionary.h:58
ion_dictionary_t dict
Definition: Dictionary.h:53
ion_value_size_t value_size
Definition: kv_system.h:309

Here is the call graph for this function:

template<typename K, typename V>
ion_err_t Dictionary< K, V >::initializeDictionary ( ion_dictionary_id_t  dict_id,
ion_key_type_t  k_type,
ion_key_size_t  k_size,
ion_value_size_t  v_size,
ion_dictionary_size_t  dictionary_size 
)
inline

Creates a dictionary with a specific identifier (for use through the master table).

Parameters
dict_idA unique identifier important for use of the dictionary through the master table. If the dictionary is being created without the master table, this identifier can be 0.
k_typeThe type of key to be used with this dictionary, which determines the key comparison operator.
k_sizeThe size of the key type to be used with this dictionary.
v_sizeThe size of the value type to be used with this dictionary.
dictionary_sizeThe dictionary implementation specific dictionary size parameter.
Returns
An error code describing the result of the operation.

Definition at line 85 of file Dictionary.h.

91  {
92  key_type = k_type;
93  key_size = k_size;
94  value_size = v_size;
95  dict_size = dictionary_size;
96 
97  ion_err_t err = dictionary_create(&handler, &dict, dict_id, k_type, k_size, v_size, dictionary_size);
98 
99  last_status.error = err;
100 
101  return err;
102 }
ion_key_type_t key_type
Definition: Dictionary.h:54
ion_value_size_t value_size
Definition: Dictionary.h:56
ion_err_t error
Definition: kv_system.h:291
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_err_t dictionary_create(ion_dictionary_handler_t *handler, ion_dictionary_t *dictionary, ion_dictionary_id_t id, ion_key_type_t key_type, ion_key_size_t key_size, ion_value_size_t value_size, ion_dictionary_size_t dictionary_size)
Creates as instance of a specific type of dictionary.
Definition: dictionary.c:125
ion_key_size_t key_size
Definition: Dictionary.h:55
ion_status_t last_status
Definition: Dictionary.h:58
ion_dictionary_handler_t handler
Definition: Dictionary.h:52
ion_dictionary_t dict
Definition: Dictionary.h:53
ion_dictionary_size_t dict_size
Definition: Dictionary.h:57

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename K, typename V>
ion_status_t Dictionary< K, V >::insert ( key,
value 
)
inline

Insert a value into a dictionary.

Parameters
keyThe key that identifies value.
valueThe value to store under key.
Returns
An error message describing the result of the insertion.

Definition at line 114 of file Dictionary.h.

117  {
118  ion_key_t ion_key = &key;
119  ion_value_t ion_value = &value;
120 
121  ion_status_t status = dictionary_insert(&dict, ion_key, ion_value);
122 
123  this->last_status = status;
124 
125  return status;
126 }
#define key(k)
Definition: bpp_tree.c:75
ion_status_t dictionary_insert(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Insert a value into a dictionary.
Definition: dictionary.c:151
void * ion_key_t
A dictionary key.
Definition: kv_system.h:241
void * ion_value_t
A dictionary value.
Definition: kv_system.h:246
ion_status_t last_status
Definition: Dictionary.h:58
ion_dictionary_t dict
Definition: Dictionary.h:53
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Here is the call graph for this function:

template<typename K, typename V>
ion_err_t Dictionary< K, V >::open ( ion_dictionary_config_info_t  config_info)
inline

Opens a dictionary, given the desired config.

Parameters
config_infoThe configuration of the dictionary to be opened.
Returns
An error message describing the result of of the open.

Definition at line 230 of file Dictionary.h.

232  {
233  ion_err_t err = dictionary_open(&handler, &dict, &config_info);
234 
235  key_type = config_info.type;
236  key_size = config_info.key_size;
237  value_size = config_info.value_size;
238  dict_size = config_info.dictionary_size;
239  last_status.error = err;
240 
241  return err;
242 }
ion_key_type_t key_type
Definition: Dictionary.h:54
ion_value_size_t value_size
Definition: Dictionary.h:56
ion_err_t error
Definition: kv_system.h:291
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_key_size_t key_size
Definition: Dictionary.h:55
ion_status_t last_status
Definition: Dictionary.h:58
ion_dictionary_handler_t handler
Definition: Dictionary.h:52
ion_err_t dictionary_open(ion_dictionary_handler_t *handler, ion_dictionary_t *dictionary, ion_dictionary_config_info_t *config)
Opens a dictionary, given the desired config.
Definition: dictionary.c:287
ion_dictionary_size_t dictionary_size
ion_dictionary_t dict
Definition: Dictionary.h:53
ion_dictionary_size_t dict_size
Definition: Dictionary.h:57

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename K, typename V>
Cursor<K, V>* Dictionary< K, V >::range ( min_key,
max_key 
)
inline

Sets up cursor and predicate to perform a range query on a dictionary.

Parameters
min_keyThe minimum key to be included in the query.
max_keyThe maximum key to be included in the query.
Returns
An initialized cursor for the particular query.

Definition at line 268 of file Dictionary.h.

271  {
273  ion_key_t ion_min_key = &min_key;
274  ion_key_t ion_max_key = &max_key;
275 
276  dictionary_build_predicate(&predicate, predicate_range, ion_min_key, ion_max_key);
277  return new Cursor<K, V>(&dict, &predicate);
278 }
void * ion_key_t
A dictionary key.
Definition: kv_system.h:241
Definition: Cursor.h:42
A supertype for cursor predicate objects.
ion_dictionary_t dict
Definition: Dictionary.h:53
ion_err_t dictionary_build_predicate(ion_predicate_t *predicate, ion_predicate_type_t type,...)
Builds a predicate based on the type given.
Definition: dictionary.c:512

Here is the call graph for this function:

template<typename K, typename V>
ion_status_t Dictionary< K, V >::update ( key,
value 
)
inline

Update all records with a given key.

Parameters
keyThe key to identify records for updating.
valueThe value to update records with.
Returns
An error message describing the result of the update.

Definition at line 177 of file Dictionary.h.

180  {
181  ion_key_t ion_key = &key;
182  ion_value_t ion_value = &value;
183  ion_status_t status = dictionary_update(&dict, ion_key, ion_value);
184 
185  this->last_status = status;
186 
187  return status;
188 }
#define key(k)
Definition: bpp_tree.c:75
ion_status_t dictionary_update(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Update all records with a given key.
Definition: dictionary.c:169
void * ion_key_t
A dictionary key.
Definition: kv_system.h:241
void * ion_value_t
A dictionary value.
Definition: kv_system.h:246
ion_status_t last_status
Definition: Dictionary.h:58
ion_dictionary_t dict
Definition: Dictionary.h:53
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290

Here is the call graph for this function:

Member Data Documentation

template<typename K, typename V>
ion_dictionary_t Dictionary< K, V >::dict

Definition at line 53 of file Dictionary.h.

template<typename K, typename V>
ion_dictionary_size_t Dictionary< K, V >::dict_size

Definition at line 57 of file Dictionary.h.

template<typename K, typename V>
ion_dictionary_handler_t Dictionary< K, V >::handler

Definition at line 52 of file Dictionary.h.

template<typename K, typename V>
ion_key_size_t Dictionary< K, V >::key_size

Definition at line 55 of file Dictionary.h.

template<typename K, typename V>
ion_key_type_t Dictionary< K, V >::key_type

Definition at line 54 of file Dictionary.h.

template<typename K, typename V>
ion_status_t Dictionary< K, V >::last_status

Definition at line 58 of file Dictionary.h.

template<typename K, typename V>
ion_value_size_t Dictionary< K, V >::value_size

Definition at line 56 of file Dictionary.h.


The documentation for this class was generated from the following file: