flat_file_dictionary_handler.c
Go to the documentation of this file.
73 err = flat_file_scan(flat_file, flat_file_cursor->current_location + 1, &flat_file_cursor->current_location, &throwaway_row, ION_FLAT_FILE_SCAN_FORWARDS, flat_file_predicate_key_match, cursor->predicate->statement.equality.equality_value);
79 err = flat_file_scan(flat_file, flat_file_cursor->current_location + 1, &flat_file_cursor->current_location, &throwaway_row, ION_FLAT_FILE_SCAN_FORWARDS, flat_file_predicate_within_bounds, cursor->predicate->statement.range.lower_bound, cursor->predicate->statement.range.upper_bound);
85 err = flat_file_scan(flat_file, flat_file_cursor->current_location + 1, &flat_file_cursor->current_location, &throwaway_row, ION_FLAT_FILE_SCAN_FORWARDS, flat_file_predicate_not_empty);
167 return ffdict_create_dictionary(config->id, config->type, config->key_size, config->value_size, config->dictionary_size, compare, handler, dictionary);
256 ion_err_t scan_result = flat_file_scan(flat_file, -1, &loc, &row, ION_FLAT_FILE_SCAN_FORWARDS, flat_file_predicate_key_match, target_key);
288 memcpy((*cursor)->predicate->statement.range.lower_bound, predicate->statement.range.lower_bound, key_size);
299 memcpy((*cursor)->predicate->statement.range.upper_bound, predicate->statement.range.upper_bound, key_size);
304 ion_err_t scan_result = flat_file_scan(flat_file, -1, &loc, &row, ION_FLAT_FILE_SCAN_FORWARDS, flat_file_predicate_within_bounds, (*cursor)->predicate->statement.range.lower_bound, (*cursor)->predicate->statement.range.upper_bound);
307 /* This means the returned node is smaller than the lower bound, which means that there are no valid records to return */
332 ion_err_t scan_result = flat_file_scan(flat_file, -1, &loc, &row, ION_FLAT_FILE_SCAN_FORWARDS, flat_file_predicate_not_empty);
417 ion_err_t result = flat_file_initialize((ion_flat_file_t *) dictionary->instance, id, key_type, key_size, value_size, dictionary_size);
Definition: kv_system.h:141
ion_status_t ffdict_delete(ion_dictionary_t *dictionary, ion_key_t key)
Removes all instances of any record with key equal to key.
Definition: flat_file_dictionary_handler.c:427
ion_status_t flat_file_get(ion_flat_file_t *flat_file, ion_key_t key, ion_value_t value)
Fetches the record stored with the given key.
Definition: flat_file.c:439
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.
Definition: dictionary_types.h:139
Container for the rows written in the flat file data file.
Definition: flat_file_types.h:107
Metadata container that holds flat file specific information.
Definition: flat_file_types.h:73
ion_status_t ffdict_update(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Updates all records stored at key to have value equal to value.
Definition: flat_file_dictionary_handler.c:461
ion_err_t ffdict_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: flat_file_dictionary_handler.c:446
ion_err_t flat_file_destroy(ion_flat_file_t *flat_file)
Destroys and cleans up any implementation specific memory or files.
Definition: flat_file.c:134
ion_err_t flat_file_initialize(ion_flat_file_t *flat_file, 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)
Initializes the flat file implementation and creates all necessary files.
Definition: flat_file.c:40
ion_value_size_t value_size
Definition: dictionary_types.h:191
ion_status_t flat_file_update(ion_flat_file_t *flat_file, ion_key_t key, ion_value_t value)
Updates all records stored with the given key to have value.
Definition: flat_file.c:560
ion_err_t ffdict_find(ion_dictionary_t *dictionary, ion_predicate_t *predicate, ion_dict_cursor_t **cursor)
Initializes a cursor query and returns an allocated cursor object.
Definition: flat_file_dictionary_handler.c:209
Function declarations at the dictionary interface level for the flat file store.
ion_status_t(* remove)(ion_dictionary_t *, ion_key_t)
Definition: dictionary_types.h:243
Definition: kv_system.h:200
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_err_t ffdict_open_dictionary(ion_dictionary_handler_t *handler, ion_dictionary_t *dictionary, ion_dictionary_config_info_t *config, ion_dictionary_compare_t compare)
Re-instances a previously created flat file store instance and prepares it to be used again...
Definition: flat_file_dictionary_handler.c:161
Struct containing details for opening a dictionary previously created.
Definition: dictionary_types.h:183
ion_boolean_t flat_file_predicate_within_bounds(ion_flat_file_t *flat_file, ion_flat_file_row_t *row, va_list *args)
Predicate function to return any row that has a key such that lower_bound <= key <= upper_bound holds...
Definition: flat_file.c:291
ion_err_t ffdict_close_dictionary(ion_dictionary_t *dictionary)
Closes this flat file store and persists everything to disk to be brought back later using dictionary...
Definition: flat_file_dictionary_handler.c:178
ion_status_t flat_file_delete(ion_flat_file_t *flat_file, ion_key_t key)
Deletes all records stored with the given key.
Definition: flat_file.c:495
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_status_t ffdict_get(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Performs a "get" operation on the dictionary to retrieve a single record.
Definition: flat_file_dictionary_handler.c:389
ion_err_t flat_file_read_row(ion_flat_file_t *flat_file, ion_fpos_t location, ion_flat_file_row_t *row)
Reads the row specified by the given location into the buffer.
Definition: flat_file.c:350
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 flat_file_scan(ion_flat_file_t *flat_file, ion_fpos_t start_location, ion_fpos_t *location, ion_flat_file_row_t *row, ion_byte_t scan_direction, ion_flat_file_predicate_t predicate,...)
Performs a linear scan of the flat file writing the first location seen that satisfies the given pred...
Definition: flat_file.c:157
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
Definition: dictionary_types.h:305
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
Implementation cursor type for the flat file store cursor.
Definition: flat_file_types.h:128
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
ion_cursor_status_t ffdict_next(ion_dict_cursor_t *cursor, ion_record_t *record)
Fetches the next record to be returned from a cursor that has already been initialized.
Definition: flat_file_dictionary_handler.c:53
Definition: dictionary_types.h:128
Definition: dictionary_types.h:307
void ffdict_init(ion_dictionary_handler_t *handler)
Given the handler instance, bind the appropriate flat file functions.
Definition: flat_file_dictionary_handler.c:364
ion_fpos_t current_location
Definition: flat_file_types.h:132
Definition: kv_system.h:173
ion_err_t(* delete_dictionary)(ion_dictionary_t *)
Definition: dictionary_types.h:248
ion_err_t ffdict_delete_dictionary(ion_dictionary_t *dictionary)
Cleans up all files created by the dictionary, and frees any allocated memory.
Definition: flat_file_dictionary_handler.c:435
void ffdict_destroy_cursor(ion_dict_cursor_t **cursor)
Destroys and frees the given cursor.
Definition: flat_file_dictionary_handler.c:134
ion_err_t flat_file_close(ion_flat_file_t *flat_file)
Closes and frees any memory associated with the flat file.
Definition: flat_file.c:624
ion_err_t(* find)(ion_dictionary_t *, ion_predicate_t *, ion_dict_cursor_t **)
Definition: dictionary_types.h:237
#define ION_FLAT_FILE_SCAN_FORWARDS
Signals to flat_file_scan to scan in a forward direction.
Definition: flat_file_types.h:64
ion_status_t ffdict_insert(ion_dictionary_t *dictionary, ion_key_t key, ion_value_t value)
Given a record ( key, value ), insert it into the dictionary.
Definition: flat_file_dictionary_handler.c:380
ion_err_t ffdict_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 flat file backed dictionary.
Definition: flat_file_dictionary_handler.c:398
ion_boolean_t flat_file_predicate_key_match(ion_flat_file_t *flat_file, ion_flat_file_row_t *row, va_list *args)
Predicate function to return any row that has an exact match to the given target key.
Definition: flat_file.c:280
Definition: dictionary_types.h:130
Definition: kv_system.h:212
ion_dictionary_size_t dictionary_size
Definition: dictionary_types.h:192
Definition: dictionary_types.h:143
ion_status_t flat_file_insert(ion_flat_file_t *flat_file, ion_key_t key, ion_value_t value)
Inserts the given record into the flat file store.
Definition: flat_file.c:388
Definition: kv_system.h:191
ion_boolean_t flat_file_predicate_not_empty(ion_flat_file_t *flat_file, ion_flat_file_row_t *row, va_list *args)
Predicate function to return any row that is not empty or deleted.
Definition: flat_file.c:268
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