skip_list_handler.c
Go to the documentation of this file.
95 if ((NULL == sl_cursor->current) || (test_predicate(cursor, sl_cursor->current->key) == boolean_false)) {
107 memcpy(record->value, sl_cursor->current->value, cursor->dictionary->instance->record.value_size);
215 if ((NULL == loc->key) || (dictionary->instance->compare(loc->key, target_key, key_size) != 0)) {
241 memcpy((*cursor)->predicate->statement.range.lower_bound, predicate->statement.range.lower_bound, key_size);
252 memcpy((*cursor)->predicate->statement.range.upper_bound, predicate->statement.range.upper_bound, key_size);
255 ion_sl_node_t *loc = sl_find_node((ion_skiplist_t *) dictionary->instance, (*cursor)->predicate->statement.range.upper_bound);
257 if ((NULL == loc->key) || (dictionary->instance->compare(loc->key, (*cursor)->predicate->statement.range.lower_bound, key_size) < 0)) {
258 /* This means the returned node is smaller than the lower bound, which means that there are no valid records to return */
263 loc = sl_find_node((ion_skiplist_t *) dictionary->instance, (*cursor)->predicate->statement.range.lower_bound);
266 /* If this happens, then we hit the head node. Just move to the first valid data item (if exists) */
270 /* Increment the location until we hit valid data. It is impossible to fall through here, since we just confirmed previously */
272 while (NULL != loc && (dictionary->instance->compare(loc->key, (*cursor)->predicate->statement.range.lower_bound, key_size) < 0)) {
402 ion_err_t result = sl_initialize((ion_skiplist_t *) dictionary->instance, key_type, key_size, value_size, dictionary_size, pnum, pden);
ion_status_t sl_insert(ion_skiplist_t *skiplist, ion_key_t key, ion_value_t value)
Inserts a key value pair into the skiplist.
Definition: skip_list.c:115
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_status_t sl_delete(ion_skiplist_t *skiplist, ion_key_t key)
Attempts to delete all key/value pairs stored at the given key.
Definition: skip_list.c:261
Definition: kv_system.h:147
ion_err_t sldict_find(ion_dictionary_t *dictionary, ion_predicate_t *predicate, ion_dict_cursor_t **cursor)
Finds multiple keys based on the provided predicate.
Definition: skip_list_handler.c:168
ion_status_t sl_get(ion_skiplist_t *skiplist, ion_key_t key, ion_value_t value)
Requests the value stored at the given key.
Definition: skip_list.c:206
Handler liaison between dictionary API and skiplist implementation.
Struct of the Skiplist, holds metadata and the entry point into the skiplist.
Definition: skip_list_types.h:67
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.
Definition: skip_list_handler.c:439
ion_err_t sl_initialize(ion_skiplist_t *skiplist, ion_key_type_t key_type, int key_size, int value_size, int maxheight, int pnum, int pden)
Initializes an in-memory skiplist.
Definition: skip_list.c:41
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
Struct containing details for opening a dictionary previously created.
Definition: dictionary_types.h:183
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.
Definition: skip_list_handler.c:376
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
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_err_t sldict_close_dictionary(ion_dictionary_t *dictionary)
Closes a skiplist instance of a dictionary.
Definition: skip_list_handler.c:125
Definition: kv_system.h:176
ion_status_t(* update)(ion_dictionary_t *, ion_key_t, ion_value_t)
Definition: dictionary_types.h:231
void sldict_destroy_cursor(ion_dict_cursor_t **cursor)
Destroys the cursor.
Definition: skip_list_handler.c:143
ion_status_t sldict_delete(ion_dictionary_t *dictionary, ion_key_t key)
Deletes the key and associated value from the given dictionary instance.
Definition: skip_list_handler.c:412
A dictionary contains information regarding an instance of the storage element and the associated han...
Definition: dictionary_types.h:273
ion_err_t sldict_destroy_dictionary(ion_dictionary_id_t id)
Deletes an instance of a closed dictionary.
Definition: skip_list_handler.c:431
Definition: dictionary_types.h:305
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(* 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 sldict_insert(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Inserts a key and value pair into the dictionary.
Definition: skip_list_handler.c:367
Definition: skip_list_types.h:78
ion_err_t(* find)(ion_dictionary_t *, ion_predicate_t *, ion_dict_cursor_t **)
Definition: dictionary_types.h:237
ion_sl_node_t * sl_find_node(ion_skiplist_t *skiplist, ion_key_t key)
Searches for a node with the given key. Used in conjunction with sl_query to perform key lookups...
Definition: skip_list.c:317
ion_err_t sl_destroy(ion_skiplist_t *skiplist)
Destroys the skiplist in memory.
Definition: skip_list.c:95
Definition: dictionary_types.h:130
ion_err_t sldict_delete_dictionary(ion_dictionary_t *dictionary)
Deletes an instance of a dictionary and its associated data.
Definition: skip_list_handler.c:420
Definition: dictionary_types.h:143
ion_cursor_status_t sldict_next(ion_dict_cursor_t *cursor, ion_record_t *record)
Next function queries and retrieves the next key/value pair that satisfies the predicate of the curso...
Definition: skip_list_handler.c:81
ion_status_t sldict_get(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Queries a dictionary instance for a given key and returns the corresponding value.
Definition: skip_list_handler.c:60
void sldict_init(ion_dictionary_handler_t *handler)
Registers a skiplist handler to a dictionary instance.
Definition: skip_list_handler.c:351
Definition: dictionary_types.h:308
ion_err_t sldict_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 skiplist instance of a dictionary.
Definition: skip_list_handler.c:337
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
ion_status_t sl_update(ion_skiplist_t *skiplist, ion_key_t key, ion_value_t value)
Updates the value stored at key with the new value.
Definition: skip_list.c:225
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290