linear_hash_handler.c
Go to the documentation of this file.
61 return linear_hash_insert(key, value, insert_hash_to_bucket(key, (linear_hash_table_t *) dictionary->instance), (linear_hash_table_t *) dictionary->instance);
107 /* TODO Should we handle the possible error code returned by this? If yes, what sorts of errors does it return? */
108 ion_err_t result = linear_hash_init(id, dictionary_size, key_type, key_size, value_size, initial_size, split_threshold, records_per_bucket, (linear_hash_table_t *) dictionary->instance);
165 return linear_hash_create_dictionary(config->id, config->type, config->key_size, config->value_size, config->dictionary_size, compare, handler, dictionary);
ion_status_t linear_hash_get(ion_byte_t *key, ion_byte_t *value, linear_hash_table_t *linear_hash)
Retrieve a record from the linear hash. The key and value will be written to the key and value pointe...
Definition: linear_hash.c:673
ion_err_t linear_hash_destroy(linear_hash_table_t *linear_hash)
Close a linear hash instance and delete its associated .lhs and .lhd files.
Definition: linear_hash.c:1507
ion_status_t(* insert)(ion_dictionary_t *, ion_key_t, ion_value_t)
Definition: dictionary_types.h:208
Definition: kv_system.h:160
enum ION_KEY_TYPE ion_key_type_t
This is the available key types for ION_DB. All types will be based on system defines.
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: linear_hash_handler.c:159
void linear_hash_dict_init(ion_dictionary_handler_t *handler)
Registers a linear hash handler to a dictionary instance.
Definition: linear_hash_handler.c:40
ion_value_size_t value_size
Definition: dictionary_types.h:191
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.
Definition: linear_hash_handler.c:74
ion_status_t(* remove)(ion_dictionary_t *, ion_key_t)
Definition: dictionary_types.h:243
ion_err_t(* destroy_dictionary)(ion_dictionary_id_t id)
Definition: dictionary_types.h:252
unsigned int ion_dictionary_id_t
A type used to identify dictionaries, specifically in the master table.
Definition: dictionary_types.h:51
unsigned int ion_dictionary_size_t
The implementation specific size of the dictionary.
Definition: kv_system.h:264
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.
Definition: linear_hash_handler.c:56
Struct containing details for opening a dictionary previously created.
Definition: dictionary_types.h:183
ion_err_t linear_hash_close(linear_hash_table_t *linear_hash)
Close a linear hash instance with proper resource clean-up.
Definition: linear_hash.c:1466
ion_status_t linear_hash_dict_get(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Definition: linear_hash_handler.c:65
int insert_hash_to_bucket(ion_byte_t *key, linear_hash_table_t *linear_hash)
Map a key to the address space of the linear hash. Used to map records to buckets with an index less ...
Definition: linear_hash.c:1358
ion_status_t linear_hash_update(ion_key_t key, ion_value_t value, linear_hash_table_t *linear_hash)
Update the value of the first record matching the key specified in the linear hash.
Definition: linear_hash.c:774
char(* ion_dictionary_compare_t)(ion_key_t, ion_key_t, ion_key_size_t)
Function pointer type for dictionary comparison methods.
Definition: dictionary_types.h:83
int dictionary_get_filename(ion_dictionary_id_t id, char *ext, char *filename)
Given the ID, implementation specific extension, and a buffer to write to, writes back the formatted ...
Definition: dictionary.c:41
Definition: kv_system.h:176
ion_status_t(* update)(ion_dictionary_t *, ion_key_t, ion_value_t)
Definition: dictionary_types.h:231
ion_err_t linear_hash_close_dictionary(ion_dictionary_t *dictionary)
Definition: linear_hash_handler.c:169
A dictionary contains information regarding an instance of the storage element and the associated han...
Definition: dictionary_types.h:273
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.
Definition: linear_hash_handler.c:83
ion_err_t linear_hash_delete_dictionary(ion_dictionary_t *dictionary)
Deletes an instance of a dictionary and its associated data.
Definition: linear_hash_handler.c:148
ion_err_t linear_hash_init(ion_dictionary_id_t id, ion_dictionary_size_t dictionary_size, ion_key_type_t key_type, ion_key_size_t key_size, ion_value_size_t value_size, int initial_size, int split_threshold, int records_per_bucket, linear_hash_table_t *linear_hash)
Definition: linear_hash.c:47
ion_err_t(* close_dictionary)(ion_dictionary_t *)
Definition: dictionary_types.h:263
#define ION_MAX_FILENAME_LENGTH
Since the arduino conforms to 8.3 syntax, that's 8 + 3 = 11 + 1 (null terminator) characters...
Definition: kv_system.h:73
ion_err_t(* open_dictionary)(ion_dictionary_handler_t *, ion_dictionary_t *, ion_dictionary_config_info_t *, ion_dictionary_compare_t)
Definition: dictionary_types.h:256
Definition: linear_hash_types.h:69
ion_err_t(* create_dictionary)(ion_dictionary_id_t, ion_key_type_t, ion_key_size_t, ion_value_size_t, ion_dictionary_size_t, ion_dictionary_compare_t, ion_dictionary_handler_t *, ion_dictionary_t *)
Definition: dictionary_types.h:214
Definition: kv_system.h:149
Definition: kv_system.h:203
ion_err_t(* delete_dictionary)(ion_dictionary_t *)
Definition: dictionary_types.h:248
ion_status_t linear_hash_delete(ion_byte_t *key, linear_hash_table_t *linear_hash)
Delete all records with keys matching the key specified in the linear hash.
Definition: linear_hash.c:867
ion_status_t linear_hash_dict_find(ion_dictionary_t *dictionary)
Definition: linear_hash_handler.c:187
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 ...
Definition: linear_hash_handler.c:127
ion_dictionary_size_t dictionary_size
Definition: dictionary_types.h:192
Header for handler for a linear hash .
Definition: kv_system.h:191
ion_status_t linear_hash_insert(ion_key_t key, ion_value_t value, int hash_bucket_idx, linear_hash_table_t *linear_hash)
Insert a record into the linear hash.
Definition: linear_hash.c:573
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.
Definition: linear_hash_handler.c:119
ion_status_t(* get)(ion_dictionary_t *, ion_key_t, ion_value_t)
Definition: dictionary_types.h:225
A dictionary_handler is responsible for dealing with the specific interface for an underlying diction...
Definition: dictionary_types.h:207
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290