#include "ion_master_table.h"
Description
Master table handling.
- Copyright
- Copyright 2017 The University of British Columbia, IonDB Project Contributors (see AUTHORS.md)
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- 1.Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- 2.Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- 3.Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file ion_master_table.c.
Variables | |
FILE * | ion_master_table_file = NULL |
Master table file. More... | |
ion_dictionary_id_t | ion_master_table_next_id = 1 |
Master table resposible for managing instances. More... | |
Function Documentation
ion_err_t ion_add_to_master_table | ( | ion_dictionary_t * | dictionary, |
ion_dictionary_size_t | dictionary_size | ||
) |
Adds the given dictionary to the master table.
- Parameters
-
dictionary A pointer to the dictionary object to add to the master table. dictionary_size The 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 338 of file ion_master_table.c.
ion_err_t ion_close_all_master_table | ( | void | ) |
Closes the master table and all dictionary instances within 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.
Definition at line 259 of file ion_master_table.c.
ion_err_t ion_close_dictionary | ( | ion_dictionary_t * | dictionary | ) |
Closes a given dictionary.
- Parameters
-
dictionary A pointer to the dictionary object to close.
Definition at line 486 of file ion_master_table.c.
ion_err_t ion_close_master_table | ( | void | ) |
Closes the master table.
Definition at line 244 of file ion_master_table.c.
ion_err_t ion_delete_dictionary | ( | ion_dictionary_t * | dictionary, |
ion_dictionary_id_t | id | ||
) |
Deletes a given dictionary instance and deletes it from the master table.
- Parameters
-
dictionary A pointer to the dictionary object to delete. id The identifier identifying the dictionary metadata in the master table. Required to delete a closed dictionary without reopening it.
Definition at line 496 of file ion_master_table.c.
ion_err_t ion_delete_from_master_table | ( | ion_dictionary_id_t | id | ) |
Deletes a dictionary from the master table.
- Parameters
-
id The identifier identifying the dictionary metadata in the master table.
- Returns
- An error code describing the result of the operation.
Definition at line 437 of file ion_master_table.c.
ion_err_t ion_delete_master_table | ( | void | ) |
Deletes the master table.
Definition at line 314 of file ion_master_table.c.
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.
- Parameters
-
config A pointer to an already allocated configuration object that will be used to open the found dictionary. use_type The integral usage type for the dictionary. This is user defined. whence Whether 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 typeuse_type
is found, otherwise an error code properly describing the situation and outcome.
Definition at line 396 of file ion_master_table.c.
ion_dictionary_type_t ion_get_dictionary_type | ( | ion_dictionary_id_t | id | ) |
Retrieves the type of dictionary stored under a particular id in the master table.
- Parameters
-
id The identifier identifying the dictionary metadata in the master table.
- Returns
- The type of dictionary implementation corresponding to the id.
Definition at line 447 of file ion_master_table.c.
ion_err_t ion_init_master_table | ( | void | ) |
Opens the master table.
Can be safely called multiple times without closing.
Definition at line 197 of file ion_master_table.c.
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.
- Parameters
-
id The identifier identifying the dictionary metadata in the master table which is to be looked up. config A pointer to an already allocated configuration object that will be read into from the master table.
Definition at line 379 of file ion_master_table.c.
ion_err_t ion_master_table_create_dictionary | ( | ion_dictionary_handler_t * | handler, |
ion_dictionary_t * | dictionary, | ||
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 a dictionary through use of the master table.
- Parameters
-
handler A pointer to an allocated and initialized dictionary handler object that contains all implementation specific data and function pointers. dictionary A pointer to an allocated dictionary object, which will be written into when opened. key_type The type of key to be used with this dictionary, which determines the key comparison operator. key_size The size of the key type to be used with this dictionary. value_size The size of the value type to be used with this dictionary. dictionary_size The dictionary implementation specific dictionary size parameter.
- Returns
- An error code describing the result of the operation.
Definition at line 350 of file ion_master_table.c.
ion_err_t ion_master_table_get_next_id | ( | ion_dictionary_id_t * | id | ) |
Returns the next dictionary ID, then increments.
- Parameters
-
id An identifier pointer to be written into.
- Returns
- An error code describing the result of the operation.
Definition at line 177 of file ion_master_table.c.
ion_err_t ion_master_table_read | ( | ion_dictionary_config_info_t * | config, |
long | where | ||
) |
Read a record to the master table.
Automatically, this call will reposition the file position back to where it was once the call is complete.
- Parameters
-
[out] config A pointer to a previously allocated config object to write to. [in] where An integral value representing where to read from in the file. This file offset is byte-aligned, not record aligned, in general.
One special flag can be passed in here:
ION_MASTER_TABLE_CALCULATE_POS
Calculate the position based on the passed-in config id.- Returns
- An error code describing the result of the call.
Definition at line 118 of file ion_master_table.c.
ion_err_t ion_master_table_write | ( | ion_dictionary_config_info_t * | config, |
long | where | ||
) |
Write a record to the master table.
Automatically, this call will reposition the file position back to where it was once the call is complete.
- Parameters
-
[in] config A pointer to a previously allocated config object to write from. [in] where An integral value representing where to write to in the file. This file offset is byte-aligned, not record aligned, in general.
Two special flags can be passed in here:
ION_MASTER_TABLE_CALCULATE_POS
Calculate the position based on the passed-in config id.ION_MASTER_TABLE_WRITE_FROM_END
Write the record at the end of the file.- Returns
- An error code describing the result of the call.
Definition at line 44 of file ion_master_table.c.
ion_err_t ion_open_dictionary | ( | ion_dictionary_handler_t * | handler, |
ion_dictionary_t * | dictionary, | ||
ion_dictionary_id_t | id | ||
) |
Finds the target dictionary and opens it.
- Parameters
-
handler A pointer to the handler object to be initialized. dictionary A pointer to the dictionary object to open. id The identifier identifying the dictionary metadata in the master table.
- Returns
- An error code describing the result of the operation.
Definition at line 463 of file ion_master_table.c.
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.
- Parameters
-
type The type of dictionary instance to initialize the handler to. handler A pointer to the handler to be set.
- Returns
- An error code describing the result of the operation.
Definition at line 537 of file ion_master_table.c.
Variable Documentation
FILE* ion_master_table_file = NULL |
Master table file.
Definition at line 40 of file ion_master_table.c.
ion_dictionary_id_t ion_master_table_next_id = 1 |
Master table resposible for managing instances.
Definition at line 41 of file ion_master_table.c.