#include "linear_hash.h"
Description
Header for handler for a linear hash .
- 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 linear_hash_handler.h.
Function Documentation
ion_err_t linear_hash_close_dictionary | ( | ion_dictionary_t * | dictionary | ) |
Definition at line 169 of file linear_hash_handler.c.
ion_err_t linear_hash_create_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, | ||
ion_dictionary_compare_t | compare, | ||
ion_dictionary_handler_t * | handler, | ||
ion_dictionary_t * | dictionary | ||
) |
Creates an instance of a dictionary.
Creates an instance of a dictionary given a key_size
and value_size
, in bytes. Given an By nature of the structure, the maximum number of elements is bounded only by memory.
- Parameters
-
id key_type key_size Size of the key in bytes. value_size Size of the value in bytes. dictionary_size compare handler Handler to be bound to the dictionary instance being created. Assumption is that the handler has been initialized prior. dictionary Pointer in which the created dictionary instance is to be stored. Assumption is that it has been properly allocated by the user.
- Returns
- Status of creation.
Definition at line 83 of file linear_hash_handler.c.
ion_err_t linear_hash_delete_dictionary | ( | ion_dictionary_t * | dictionary | ) |
Deletes an instance of a dictionary and its associated data.
- Parameters
-
dictionary The instance of the dictionary to be deleted.
- Returns
- Status of dictionary deletion.
Definition at line 148 of file linear_hash_handler.c.
ion_err_t linear_hash_destroy_dictionary | ( | ion_dictionary_id_t | id | ) |
Cleans up all files created by the dictionary, and frees any allocated memory, for an already closed dictionary.
- Parameters
-
id The identifier identifying the dictionary to delete.
- Returns
- The resulting status of the operation.
Definition at line 127 of file linear_hash_handler.c.
ion_status_t linear_hash_dict_delete | ( | ion_dictionary_t * | dictionary, |
ion_key_t | key | ||
) |
Deletes the key
and associated value from the given dictionary instance.
- Parameters
-
dictionary The instance of the dictionary to delete from. key The key to be deleted.
- Returns
- Status of deletion.
Definition at line 119 of file linear_hash_handler.c.
ion_status_t linear_hash_dict_find | ( | ion_dictionary_t * | dictionary | ) |
Definition at line 187 of file linear_hash_handler.c.
ion_status_t linear_hash_dict_get | ( | ion_dictionary_t * | dictionary, |
ion_key_t | key, | ||
ion_value_t | value | ||
) |
Definition at line 65 of file linear_hash_handler.c.
void linear_hash_dict_init | ( | ion_dictionary_handler_t * | handler | ) |
Registers a linear hash handler to a dictionary instance.
Binds each unique linear hash function to the generic dictionary interface. Only needs to be called once when the linear hash is initialized.
- Parameters
-
handler An instance of a dictionary handler that is to be bound. It is assumed handler
is initialized by the user.
Definition at line 40 of file linear_hash_handler.c.
ion_status_t linear_hash_dict_insert | ( | ion_dictionary_t * | dictionary, |
ion_key_t | key, | ||
ion_value_t | value | ||
) |
Inserts a key
and value
pair into the dictionary.
- Parameters
-
dictionary The dictionary instance to insert the value into. key The key to use. value The value to use.
- Returns
- Status of insertion.
Definition at line 56 of file linear_hash_handler.c.
ion_status_t linear_hash_dict_update | ( | ion_dictionary_t * | dictionary, |
ion_key_t | key, | ||
ion_value_t | value | ||
) |
Updates the value stored at a given key.
Updates the value for a given key
. If the key doesn't exist, the key value pair will be added as if it was an insert.
- Parameters
-
dictionary The instance of the dictionary to be updated. key The key that is to be updated. value The new value to be used.
- Returns
- Status of update.
Definition at line 74 of file linear_hash_handler.c.
ion_err_t linear_hash_open_dictionary | ( | ion_dictionary_handler_t * | handler, |
ion_dictionary_t * | dictionary, | ||
ion_dictionary_config_info_t * | config, | ||
ion_dictionary_compare_t | compare | ||
) |
Definition at line 159 of file linear_hash_handler.c.