Description
Handler liaison between dictionary API and skiplist implementation.
- 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 skip_list_handler.h.
Function Documentation
ion_err_t sldict_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 as well as the dictionary_size
, which is the maximum number of levels in the skiplist. By nature of the structure, the maximum number of elements is bounded only by memory use.
- 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 376 of file skip_list_handler.c.
ion_status_t sldict_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 412 of file skip_list_handler.c.
ion_err_t sldict_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 420 of file skip_list_handler.c.
ion_err_t sldict_destroy_dictionary | ( | ion_dictionary_id_t | id | ) |
Deletes an instance of a closed dictionary.
- Parameters
-
id The identifier identifying the dictionary to destroy.
- Returns
- Status of dictionary deletion.
Definition at line 431 of file skip_list_handler.c.
void sldict_init | ( | ion_dictionary_handler_t * | handler | ) |
Registers a skiplist handler to a dictionary instance.
Binds each unique skiplist function to the generic dictionary interface. Only needs to be called once when the skiplist 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 351 of file skip_list_handler.c.
ion_status_t sldict_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 367 of file skip_list_handler.c.
ion_status_t sldict_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 439 of file skip_list_handler.c.