#include <MasterTable.h>

Collaboration diagram for MasterTable:

Public Member Functions

 MasterTable ()
 
 ~MasterTable ()
 
ion_err_t initializeMasterTable ()
 Opens the master table. More...
 
ion_err_t closeMasterTable ()
 Closes the master table. More...
 
ion_err_t closeAllMasterTable ()
 Closes the master table and all dictionary instances in it. More...
 
ion_err_t deleteMasterTable ()
 Deletes the master table. More...
 
template<typename K , typename V >
ion_err_t addToMasterTable (Dictionary< K, V > *dictionary, ion_dictionary_size_t dictionary_size)
 Adds the given dictionary to the master table. More...
 
ion_dictionary_id_t getNextID ()
 Returns the next dictionary ID. More...
 
ion_err_t initializeHandler (ion_dictionary_type_t type)
 Retrieves the type of dictionary stored under a particular id in the master table. More...
 
ion_err_t lookupMasterTable (ion_dictionary_id_t id, ion_dictionary_config_info_t *config)
 Looks up the config of the given id. More...
 
ion_err_t findByUse (ion_dictionary_config_info_t *config, ion_dict_use_t use_type, char whence)
 Find first or last dictionary in master table with a given use. More...
 
ion_err_t deleteFromMasterTable (ion_dictionary_id_t id)
 Deletes a dictionary from the master table. More...
 
template<typename K , typename V >
ion_err_t openDictionary (Dictionary< K, V > *dictionary, ion_dictionary_id_t id)
 Finds the target dictionary and opens it. More...
 
template<typename K , typename V >
ion_err_t closeDictionary (Dictionary< K, V > *dictionary)
 Closes a given dictionary. More...
 
template<typename K , typename V >
Dictionary< K, V > * initializeDictionary (ion_key_type_t key_type, K k, V v, ion_key_size_t key_size, ion_value_size_t value_size, ion_dictionary_size_t dictionary_size, ion_dictionary_type_t dictionary_type)
 Creates a dictionary of a specified implementation. More...
 
template<typename K , typename V >
ion_err_t deleteDictionary (Dictionary< K, V > *dictionary)
 

Public Attributes

ion_dictionary_handler_t handler
 

Detailed Description

Definition at line 50 of file MasterTable.h.

Constructor & Destructor Documentation

MasterTable::MasterTable ( )
inline

Definition at line 55 of file MasterTable.h.

56  {
57  this->initializeMasterTable();
58 }
ion_err_t initializeMasterTable()
Opens the master table.
Definition: MasterTable.h:71

Here is the call graph for this function:

MasterTable::~MasterTable ( )
inline

Definition at line 60 of file MasterTable.h.

61  {
62  this->deleteMasterTable();
63 }
ion_err_t deleteMasterTable()
Deletes the master table.
Definition: MasterTable.h:103

Here is the call graph for this function:

Member Function Documentation

template<typename K , typename V >
ion_err_t MasterTable::addToMasterTable ( Dictionary< K, V > *  dictionary,
ion_dictionary_size_t  dictionary_size 
)
inline

Adds the given dictionary to the master table.

Parameters
dictionaryA pointer to the dictionary object to add to the master table.
dictionary_sizeThe implementation specific size parameter used when creating the dictionary. This parameter must be passed to this function by ion_master_table_create_dictionary, since not all implementations track the dictionary size.

Definition at line 120 of file MasterTable.h.

123  {
125 
127 
128  if (err_ok != err) {
129  return err;
130  }
131 
132  dictionary->dict.instance->id = id;
133 
135  .id = dictionary->dict.instance->id, .use_type = 0, .type = dictionary->dict.instance->key_type, .key_size = dictionary->dict.instance->record.key_size, .value_size = dictionary->dict.instance->record.value_size, .dictionary_size = dictionary_size, .dictionary_type = dictionary->dict.instance->type
136  };
137 
139 }
ion_record_info_t record
ion_dictionary_parent_t * instance
unsigned int ion_dictionary_id_t
A type used to identify dictionaries, specifically in the master table.
Struct containing details for opening a dictionary previously created.
ion_err_t ion_master_table_write(ion_dictionary_config_info_t *config, long where)
Write a record to the master table.
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_dictionary_id_t id
ion_key_size_t key_size
Definition: kv_system.h:307
ion_dictionary_type_t type
ion_key_type_t key_type
#define ION_MASTER_TABLE_WRITE_FROM_END
ion_dictionary_t dict
Definition: Dictionary.h:53
ion_err_t ion_master_table_get_next_id(ion_dictionary_id_t *id)
Returns the next dictionary ID, then increments.
ion_value_size_t value_size
Definition: kv_system.h:309

Here is the call graph for this function:

Here is the caller graph for this function:

ion_err_t MasterTable::closeAllMasterTable ( )
inline

Closes the master table and all dictionary instances in it.

For this method to work properly, all dictionary instances must already be closed or must have been closed previously and are now re-opened.

Returns
An error code describing the result of the operation.

Definition at line 93 of file MasterTable.h.

94  {
96 }
ion_err_t ion_close_all_master_table(void)
Closes the master table and all dictionary instances within it.

Here is the call graph for this function:

template<typename K , typename V >
ion_err_t MasterTable::closeDictionary ( Dictionary< K, V > *  dictionary)
inline

Closes a given dictionary.

Parameters
dictionaryA pointer to an allocated dictionary object, which will be closed.
Returns
An error code describing the result of the operation.

Definition at line 268 of file MasterTable.h.

270  {
271  ion_err_t err = dictionary->close();
272 
273  return err;
274 }
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_err_t close()
Closes a dictionary.
Definition: Dictionary.h:248

Here is the call graph for this function:

ion_err_t MasterTable::closeMasterTable ( )
inline

Closes the master table.

Returns
An error code describing the result of the operation.

Definition at line 81 of file MasterTable.h.

82  {
83  return ion_close_master_table();
84 }
ion_err_t ion_close_master_table(void)
Closes the master table.

Here is the call graph for this function:

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

Definition at line 372 of file MasterTable.h.

374  {
375  ion_dictionary_id_t id = dictionary->dict.instance->id;
376 
377  delete dictionary;
378 
379  return ion_delete_from_master_table(id);
380 }
ion_dictionary_parent_t * instance
unsigned int ion_dictionary_id_t
A type used to identify dictionaries, specifically in the master table.
ion_err_t ion_delete_from_master_table(ion_dictionary_id_t id)
Deletes a dictionary from the master table.
ion_dictionary_id_t id
ion_dictionary_t dict
Definition: Dictionary.h:53

Here is the call graph for this function:

ion_err_t MasterTable::deleteFromMasterTable ( ion_dictionary_id_t  id)
inline

Deletes a dictionary from the master table.

Returns
An error code describing the result of the operation.

Definition at line 214 of file MasterTable.h.

216  {
217  return ion_delete_from_master_table(id);
218 }
ion_err_t ion_delete_from_master_table(ion_dictionary_id_t id)
Deletes a dictionary from the master table.

Here is the call graph for this function:

ion_err_t MasterTable::deleteMasterTable ( )
inline

Deletes the master table.

Returns
An error code describing the result of the operation.

Definition at line 103 of file MasterTable.h.

104  {
105  return ion_delete_master_table();
106 }
ion_err_t ion_delete_master_table(void)
Deletes the master table.

Here is the call graph for this function:

Here is the caller graph for this function:

ion_err_t MasterTable::findByUse ( ion_dictionary_config_info_t config,
ion_dict_use_t  use_type,
char  whence 
)
inline

Find first or last dictionary in master table with a given use.

Parameters
configA pointer to an already allocated configuration object that will be used to open the found dictionary.
use_typeThe integral usage type for the dictionary. This is user defined.
whenceWhether to find the first or the last dictionary having use_type. This can take exactly two values, ION_MASTER_TABLE_FIND_FIRST or ION_MASTER_TABLE_FIND_LAST.
Returns
err_ok if a dictionary having usage type use_type is found, otherwise an error code properly describing the situation and outcome.

Definition at line 201 of file MasterTable.h.

205  {
206  return ion_find_by_use_master_table(config, use_type, whence);
207 }
ion_err_t ion_find_by_use_master_table(ion_dictionary_config_info_t *config, ion_dict_use_t use_type, char whence)
Find first or last dictionary in master table with a given use.

Here is the call graph for this function:

ion_dictionary_id_t MasterTable::getNextID ( )
inline

Returns the next dictionary ID.

Returns
The next ID to be used by the master table.

Definition at line 146 of file MasterTable.h.

147  {
149 }
ion_dictionary_id_t ion_master_table_next_id
Master table resposible for managing instances.
template<typename K , typename V >
Dictionary<K, V>* MasterTable::initializeDictionary ( ion_key_type_t  key_type,
k,
v,
ion_key_size_t  key_size,
ion_value_size_t  value_size,
ion_dictionary_size_t  dictionary_size,
ion_dictionary_type_t  dictionary_type 
)
inline

Creates a dictionary of a specified implementation.

This method is not currently used for creation of a C++ dictionary.

Parameters
key_typeThe type of key to be used with this dictionary, which determines the key comparison operator.
kThe type of key to be used with this dictionary.
vThe type of value to be used with this dictionary.
key_sizeThe size of the key type to be used with this dictionary.
value_sizeThe size of the value type to be used with this dictionary.
dictionary_sizeThe dictionary implementation specific dictionary size parameter.
dictionary_typeThe type of dictionary to be created.
Returns
An error code describing the result of the operation.

Definition at line 299 of file MasterTable.h.

307  {
308  UNUSED(k);
309  UNUSED(v);
310 
312 
314 
315  switch (dictionary_type) {
317  dictionary = new BppTree<K, V>(id, key_type, key_size, value_size);
318 
319  break;
320  }
321 
323  dictionary = new FlatFile<K, V>(id, key_type, key_size, value_size, dictionary_size);
324 
325  break;
326  }
327 
329  dictionary = new OpenAddressFileHash<K, V>(id, key_type, key_size, value_size, dictionary_size);
330 
331  break;
332  }
333 
335  dictionary = new OpenAddressHash<K, V>(id, key_type, key_size, value_size, dictionary_size);
336 
337  break;
338  }
339 
341  dictionary = new SkipList<K, V>(id, key_type, key_size, value_size, dictionary_size);
342 
343  break;
344  }
345 
347  dictionary = new LinearHash<K, V>(id, key_type, key_size, value_size, dictionary_size);
348 
349  break;
350  }
351 
353  dictionary = new SkipList<K, V>(id, key_type, key_size, value_size, dictionary_size);
355  break;
356  }
357  }
358 
359  if ((dictionary_type != dictionary_type_error_t) && (ion_dictionary_status_error != dictionary->dict.status)) {
360  ion_err_t err = addToMasterTable(dictionary, dictionary_size);
361 
362  if (err_ok != err) {
364  }
365  }
366 
367  return dictionary;
368 }
unsigned int ion_dictionary_id_t
A type used to identify dictionaries, specifically in the master table.
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
A dictionary contains information regarding an instance of the storage element and the associated han...
#define UNUSED(x)
Definition: kv_system.h:102
ion_dictionary_id_t ion_master_table_next_id
Master table resposible for managing instances.
ion_err_t addToMasterTable(Dictionary< K, V > *dictionary, ion_dictionary_size_t dictionary_size)
Adds the given dictionary to the master table.
Definition: MasterTable.h:120
ion_dictionary_t dict
Definition: Dictionary.h:53
ion_dictionary_status_t status

Here is the call graph for this function:

ion_err_t MasterTable::initializeHandler ( ion_dictionary_type_t  type)
inline

Retrieves the type of dictionary stored under a particular id in the master table.

Parameters
typeThe type of dictionary instance to initialize the handler to.
Returns
An error code describing the result of the operation.

Definition at line 159 of file MasterTable.h.

161  {
162  return ion_switch_handler(type, &handler);
163 }
ion_err_t ion_switch_handler(ion_dictionary_type_t type, ion_dictionary_handler_t *handler)
Retrieves the type of dictionary stored under a particular id in the master table.
ion_dictionary_handler_t handler
Definition: MasterTable.h:53

Here is the call graph for this function:

ion_err_t MasterTable::initializeMasterTable ( )
inline

Opens the master table.

Can be safely called multiple times without closing.

Returns
An error code describing the result of the operation.

Definition at line 71 of file MasterTable.h.

72  {
73  return ion_init_master_table();
74 }
ion_err_t ion_init_master_table(void)
Opens the master table.

Here is the call graph for this function:

Here is the caller graph for this function:

ion_err_t MasterTable::lookupMasterTable ( ion_dictionary_id_t  id,
ion_dictionary_config_info_t config 
)
inline

Looks up the config of the given id.

Parameters
idThe identifier identifying the dictionary metadata in the master table which is to be looked up.
configA pointer to an already allocated configuration object that will be read into from the master table.
Returns
An error code describing the result of the operation.

Definition at line 176 of file MasterTable.h.

179  {
180  return ion_lookup_in_master_table(id, config);
181 }
ion_err_t ion_lookup_in_master_table(ion_dictionary_id_t id, ion_dictionary_config_info_t *config)
Looks up the config of the given id.

Here is the call graph for this function:

template<typename K , typename V >
ion_err_t MasterTable::openDictionary ( Dictionary< K, V > *  dictionary,
ion_dictionary_id_t  id 
)
inline

Finds the target dictionary and opens it.

Parameters
dictionaryA pointer to an allocated dictionary object, which will be opened.
idThe identifier identifying the dictionary metadata in the master table.
Returns
An error code describing the result of the operation.

Definition at line 232 of file MasterTable.h.

235  {
236  ion_err_t err;
238 
239  err = ion_lookup_in_master_table(id, &config);
240 
241  /* Lookup for id failed. */
242  if (err_ok != err) {
243  return err_uninitialized;
244  }
245 
247 
248  if (err_ok != err) {
249  return err;
250  }
251 
252  dictionary->dict.handler = &handler;
253 
254  err = dictionary->open(config);
255 
256  return err;
257 }
ion_err_t ion_lookup_in_master_table(ion_dictionary_id_t id, ion_dictionary_config_info_t *config)
Looks up the config of the given id.
ion_dictionary_type_t dictionary_type
ion_dictionary_handler_t * handler
ion_err_t ion_switch_handler(ion_dictionary_type_t type, ion_dictionary_handler_t *handler)
Retrieves the type of dictionary stored under a particular id in the master table.
Struct containing details for opening a dictionary previously created.
ion_dictionary_handler_t handler
Definition: MasterTable.h:53
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
ion_err_t open(ion_dictionary_config_info_t config_info)
Opens a dictionary, given the desired config.
Definition: Dictionary.h:230
ion_dictionary_t dict
Definition: Dictionary.h:53

Here is the call graph for this function:

Member Data Documentation

ion_dictionary_handler_t MasterTable::handler

Definition at line 53 of file MasterTable.h.


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