open_address_hash.c
Go to the documentation of this file.
65 hashmap->entry = malloc((hashmap->super.record.key_size + hashmap->super.record.value_size + 1) * hashmap->map_size);
79 ((ion_hash_bucket_t *) (hashmap->entry + ((hashmap->super.record.key_size + hashmap->super.record.value_size + SIZEOF(STATUS)) * i)))->status = ION_EMPTY;
135 ion_hash_t hash = hash_map->compute_hash(hash_map, key, hash_map->super.record.key_size); /* compute hash value for given key */
145 item = ((ion_hash_bucket_t *) ((hash_map->entry + (hash_map->super.record.key_size + hash_map->super.record.value_size + SIZEOF(STATUS)) * loc)));
150 if (hash_map->super.compare(item->data, key, hash_map->super.record.key_size) == ION_IS_EQUAL) {
157 memcpy(item->data + hash_map->super.record.key_size, value, (hash_map->super.record.value_size));
161 return ION_STATUS_ERROR(err_file_write_error); /* there is a configuration issue with write concern */
169 memcpy(item->data + hash_map->super.record.key_size, value, (hash_map->super.record.value_size));
210 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))));
255 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))));
280 ion_hash_bucket_t *item = (((ion_hash_bucket_t *) ((hash_map->entry + (data_length + SIZEOF(STATUS)) * loc))));
283 memcpy(value, (item->data + hash_map->super.record.key_size), hash_map->super.record.value_size);
318 printf("%d -- %i ", i, ((ion_hash_bucket_t *) ((hash_map->entry + (record->key_size + record->value_size + SIZEOF(STATUS)) * i)))->status);
320 if (((ion_hash_bucket_t *) ((hash_map->entry + (record->key_size + record->value_size + SIZEOF(STATUS)) * i)))->status == (ION_EMPTY | ION_DELETED)) {
327 printf("%X ", *(ion_byte_t *) (((ion_hash_bucket_t *) ((hash_map->entry + (record->key_size + record->value_size + SIZEOF(STATUS)) * i)))->data + j));
344 ion_hash_t hash = (ion_hash_t) (((*(int *) key) % hashmap->map_size) + hashmap->map_size) % hashmap->map_size;
int(* compute_hash)(ion_hashmap_t *, ion_key_t, int)
Definition: open_address_hash.h:76
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.
Struct used to maintain an instance of an in memory hashmap.
Definition: open_address_hash.h:70
A hash table using linear probing. Designed for in memory use.
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_err_t oah_destroy(ion_hashmap_t *hash_map)
Destroys the map in memory.
Definition: open_address_hash.c:94
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
Definition: dictionary_types.h:427
ion_status_t oah_delete(ion_hashmap_t *hash_map, ion_key_t key)
Deletes item from map.
Definition: open_address_hash.c:241
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_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
int oah_get_location(ion_hash_t num, int size)
Returns the theoretical location of item in hashmap.
Definition: open_address_hash.c:86
Struct used to maintain individual records in the hashmap.
Definition: dictionary_types.h:445
Definition: kv_system.h:168
Definition: kv_system.h:179
Definition: kv_system.h:165
Definition: kv_system.h:162
Definition: kv_system.h:171
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_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
char ion_write_concern_t
A type for write concern information used by hash table based dictionaries which limit insert/update ...
Definition: dictionary_types.h:440
Definition: dictionary_types.h:430
void oah_print(ion_hashmap_t *hash_map, int size, ion_record_info_t *record)
Helper function to print out map.
Definition: open_address_hash.c:308
Struct used to maintain information about size of key and value.
Definition: kv_system.h:306
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290