open_address_hash_dictionary_handler.c
Go to the documentation of this file.
101 ion_hash_bucket_t *item = (((ion_hash_bucket_t *) ((hash_map->entry + (hash_map->super.record.key_size + hash_map->super.record.value_size + SIZEOF(STATUS)) * loc))));
110 ion_boolean_t key_satisfies_predicate = test_predicate(&(cursor->super), item->data); /* assumes that the key is first */
177 if (((*cursor)->predicate->statement.equality.equality_value = malloc((((ion_hashmap_t *) dictionary->instance)->super.record.key_size))) == NULL) {
184 memcpy((*cursor)->predicate->statement.equality.equality_value, predicate->statement.equality.equality_value, ((((ion_hashmap_t *) dictionary->instance)->super.record.key_size)));
189 if (oah_find_item_loc((ion_hashmap_t *) dictionary->instance, (*cursor)->predicate->statement.equality.equality_value, &location) == err_item_not_found) {
210 if (((*cursor)->predicate->statement.range.lower_bound = malloc((((ion_hashmap_t *) dictionary->instance)->super.record.key_size))) == NULL) {
217 memcpy((*cursor)->predicate->statement.range.lower_bound, predicate->statement.range.lower_bound, (((ion_hashmap_t *) dictionary->instance)->super.record.key_size));
220 if (((*cursor)->predicate->statement.range.upper_bound = malloc((((ion_hashmap_t *) dictionary->instance)->super.record.key_size))) == NULL) {
228 memcpy((*cursor)->predicate->statement.range.upper_bound, predicate->statement.range.upper_bound, (((ion_hashmap_t *) dictionary->instance)->super.record.key_size));
367 oah_initialize((ion_hashmap_t *) dictionary->instance, oah_compute_simple_hash, key_type, key_size, value_size, dictionary_size); /* just pick an arbitary size for testing atm */
453 /* if the cursor is initialized but not active, then just read the data and set cursor active */
458 ion_hash_bucket_t *item = (((ion_hash_bucket_t *) ((hash_map->entry + (data_length + SIZEOF(STATUS)) * oadict_cursor->current /*idx*/))));
462 memcpy(record->value, (item->data + hash_map->super.record.key_size), hash_map->super.record.value_size);
478 if (memcmp(key1, key2, (((ion_hashmap_t *) dict->instance)->super.record.key_size)) == ION_IS_EQUAL) {
ion_status_t(* insert)(ion_dictionary_t *, ion_key_t, ion_value_t)
Definition: dictionary_types.h:208
Definition: kv_system.h:276
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.
Definition: dictionary_types.h:139
ion_err_t oadict_open_dictionary(ion_dictionary_handler_t *handler, ion_dictionary_t *dictionary, ion_dictionary_config_info_t *config, ion_dictionary_compare_t compare)
Opens a specific open address hash instance of a dictionary.
Definition: open_address_hash_dictionary_handler.c:294
ion_cursor_status_t oadict_next(ion_dict_cursor_t *cursor, ion_record_t *record)
Next function to query and retrieve the next <K,V> that stratifies the predicate of the cursor...
Definition: open_address_hash_dictionary_handler.c:420
Struct used to maintain an instance of an in memory hashmap.
Definition: open_address_hash.h:70
void oadict_destroy_cursor(ion_dict_cursor_t **cursor)
Destroys the cursor.
Definition: open_address_hash_dictionary_handler.c:487
ion_err_t oah_initialize(ion_hashmap_t *hashmap, ion_hash_t(*hashing_function)(ion_hashmap_t *, ion_key_t, int), ion_key_type_t key_type, ion_key_size_t key_size, ion_value_size_t value_size, int size)
This function initializes an open address in memory hash map.
Definition: open_address_hash.c:46
ion_status_t oadict_update(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Updates the value for a given key.
Definition: open_address_hash_dictionary_handler.c:411
ion_err_t oah_destroy(ion_hashmap_t *hash_map)
Destroys the map in memory.
Definition: open_address_hash.c:94
ion_err_t oadict_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: open_address_hash_dictionary_handler.c:403
ion_status_t oah_get(ion_hashmap_t *hash_map, ion_key_t key, ion_value_t value)
Locates the record if it exists.
Definition: open_address_hash.c:267
ion_status_t(* remove)(ion_dictionary_t *, ion_key_t)
Definition: dictionary_types.h:243
ion_status_t oadict_delete(ion_dictionary_t *dictionary, ion_key_t key)
Deletes the key and assoicated value from the dictionary instance.
Definition: open_address_hash_dictionary_handler.c:384
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
Struct containing details for opening a dictionary previously created.
Definition: dictionary_types.h:183
void oadict_init(ion_dictionary_handler_t *handler)
Registers a specific handler for a dictionary instance.
Definition: open_address_hash_dictionary_handler.c:324
ion_boolean_t test_predicate(ion_dict_cursor_t *cursor, ion_key_t key)
Tests the supplied key against the predicate registered in the cursor. If the supplied cursor if of t...
Definition: dictionary.c:571
ion_status_t oah_delete(ion_hashmap_t *hash_map, ion_key_t key)
Deletes item from map.
Definition: open_address_hash.c:241
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
ion_hash_t oah_compute_simple_hash(ion_hashmap_t *hashmap, ion_key_t key, int size_of_key)
A simple hashing algorithm implementation.
Definition: open_address_hash.c:337
ion_err_t oadict_find(ion_dictionary_t *dictionary, ion_predicate_t *predicate, ion_dict_cursor_t **cursor)
Finds multiple instances of a keys that satisfy the provided predicate in the dictionary.
Definition: open_address_hash_dictionary_handler.c:149
ion_status_t oah_update(ion_hashmap_t *hash_map, ion_key_t key, ion_value_t value)
Updates a value in the map.
Definition: open_address_hash.c:114
The handler for a hash table using linear probing.
Definition: kv_system.h:176
ion_status_t(* update)(ion_dictionary_t *, ion_key_t, ion_value_t)
Definition: dictionary_types.h:231
Struct used to maintain individual records in the hashmap.
Definition: dictionary_types.h:445
Definition: kv_system.h:278
Definition: dictionary_types.h:126
A dictionary contains information regarding an instance of the storage element and the associated han...
Definition: dictionary_types.h:273
ion_boolean_t oadict_is_equal(ion_dictionary_t *dict, ion_key_t key1, ion_key_t key2)
Compares two keys and determines if they are equal assuming that they are equal is length (in size)...
Definition: open_address_hash_dictionary_handler.c:473
Definition: dictionary_types.h:305
ion_err_t oadict_delete_dictionary(ion_dictionary_t *dictionary)
Deletes an instance of the dictionary and associated data.
Definition: open_address_hash_dictionary_handler.c:392
ion_err_t(* close_dictionary)(ion_dictionary_t *)
Definition: dictionary_types.h:263
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
ion_err_t oadict_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: open_address_hash_dictionary_handler.c:349
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: dictionary_types.h:306
Definition: dictionary_types.h:128
Definition: dictionary_types.h:307
Definition: kv_system.h:173
Definition: kv_system.h:203
ion_err_t(* delete_dictionary)(ion_dictionary_t *)
Definition: dictionary_types.h:248
ion_status_t oadict_get(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Queries a dictionary instance for the given key and returns the associated value. ...
Definition: open_address_hash_dictionary_handler.c:64
Definition: kv_system.h:162
ion_err_t(* find)(ion_dictionary_t *, ion_predicate_t *, ion_dict_cursor_t **)
Definition: dictionary_types.h:237
ion_err_t oah_find_item_loc(ion_hashmap_t *hash_map, ion_key_t key, int *location)
Locates item in map.
Definition: open_address_hash.c:194
ion_err_t oadict_close_dictionary(ion_dictionary_t *dictionary)
Closes an open address hash instance of a dictionary.
Definition: open_address_hash_dictionary_handler.c:316
Definition: dictionary_types.h:130
ion_err_t oadict_scan(ion_oadict_cursor_t *cursor)
Starts scanning map looking for conditions that match predicate and returns result.
Definition: open_address_hash_dictionary_handler.c:86
Definition: open_address_hash_dictionary.h:46
ion_status_t oah_insert(ion_hashmap_t *hash_map, ion_key_t key, ion_value_t value)
Insert record into hashmap.
Definition: open_address_hash.c:130
Definition: kv_system.h:212
Definition: dictionary_types.h:143
ion_status_t oadict_insert(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Inserts a key and value into the dictionary.
Definition: open_address_hash_dictionary_handler.c:340
Definition: dictionary_types.h:308
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
Definition: dictionary_types.h:133
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290