Major update: Column aliases. Columns are now identified in the context
of a view by an alias that can be modified.
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
#include "obidms.h"
|
||||
#include "obidmscolumn.h"
|
||||
#include "obierrno.h"
|
||||
#include "hashtable.h"
|
||||
|
||||
|
||||
#define OBIVIEW_NAME_MAX_LENGTH (1000) /**< The maximum length of an OBIDMS view name.
|
||||
@ -54,6 +55,18 @@
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Structure for column aliases.
|
||||
* Column aliases are alternative names used to identify a column in the context of a view.
|
||||
*/
|
||||
typedef struct Alias_column_pair {
|
||||
Column_reference_t column_refs; /**< References (name and version) of the column.
|
||||
*/
|
||||
char alias[OBIDMS_COLUMN_MAX_NAME+1]; /**< Alias of the column in the context of a view.
|
||||
*/
|
||||
} Alias_column_pair_t, *Alias_column_pair_p;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Structure for a closed view stored in the view file.
|
||||
* Views are identified by their name.
|
||||
@ -77,8 +90,8 @@ typedef struct Obiview_infos {
|
||||
*/
|
||||
int column_count; /**< The number of columns in the view.
|
||||
*/
|
||||
Column_reference_t column_references[MAX_NB_OPENED_COLUMNS]; /**< References (name and version) for all the columns in the view.
|
||||
*/
|
||||
Alias_column_pair_t column_references[MAX_NB_OPENED_COLUMNS]; /**< References (name, version and alias) for all the columns in the view.
|
||||
*/
|
||||
char comments[OBIVIEW_COMMENTS_MAX_LENGTH+1]; /**< Comments, additional informations on the view.
|
||||
*/
|
||||
} Obiview_infos_t, *Obiview_infos_p;
|
||||
@ -88,27 +101,30 @@ typedef struct Obiview_infos {
|
||||
* @brief Structure for an opened view.
|
||||
*/
|
||||
typedef struct Obiview {
|
||||
Obiview_infos_p infos; /**< A pointer on the mapped view informations.
|
||||
*/
|
||||
OBIDMS_p dms; /**< A pointer on the DMS to which the view belongs.
|
||||
*/
|
||||
bool read_only; /**< Whether the view is read-only or can be modified.
|
||||
Obiview_infos_p infos; /**< A pointer on the mapped view informations.
|
||||
*/
|
||||
OBIDMS_p dms; /**< A pointer on the DMS to which the view belongs.
|
||||
*/
|
||||
bool read_only; /**< Whether the view is read-only or can be modified.
|
||||
*/
|
||||
OBIDMS_column_p line_selection; /**< A pointer on the column containing the line selection
|
||||
OBIDMS_column_p line_selection; /**< A pointer on the column containing the line selection
|
||||
* associated with the view if there is one.
|
||||
* This line selection is read-only, and when a line from the view is read,
|
||||
* it is this line selection that is used.
|
||||
*/
|
||||
OBIDMS_column_p new_line_selection; /**< A pointer on the column containing the new line selection being built
|
||||
OBIDMS_column_p new_line_selection; /**< A pointer on the column containing the new line selection being built
|
||||
* to associate with the view, if there is one.
|
||||
* When a line is selected with obi_select_line() or obi_select_lines(),
|
||||
* it is recorded in this line selection.
|
||||
*/
|
||||
OBIDMS_column_p columns[MAX_NB_OPENED_COLUMNS]; /**< Array of pointers on all the columns of the view.
|
||||
OBIDMS_column_p columns[MAX_NB_OPENED_COLUMNS]; /**< Array of pointers on all the columns of the view.
|
||||
*/
|
||||
int nb_predicates; /**< Number of predicates to test when closing the view.
|
||||
hashtable_p column_dict; /**< Hash table storing the pairs of column names or aliases with the associated
|
||||
* column pointers.
|
||||
*/
|
||||
int nb_predicates; /**< Number of predicates to test when closing the view.
|
||||
*/
|
||||
char* (**predicate_functions)(struct Obiview* view); /**< Array of pointers on all predicate functions to test when closing the view.
|
||||
char* (**predicate_functions)(struct Obiview* view); /**< Array of pointers on all predicate functions to test when closing the view.
|
||||
*/
|
||||
} Obiview_t, *Obiview_p;
|
||||
|
||||
@ -275,6 +291,7 @@ Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name);
|
||||
* @param view A pointer on the view.
|
||||
* @param column_name The name of the column.
|
||||
* @param version_number The version of the column if it should be opened and not created (if -1, the latest version is retrieved).
|
||||
* @param alias The unique name used to identify the column in the context of this view.
|
||||
* @param data_type The OBIType code of the data.
|
||||
* @param nb_lines The number of lines to be stored.
|
||||
* @param nb_elements_per_line The number of elements per line.
|
||||
@ -293,6 +310,7 @@ Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name);
|
||||
int obi_view_add_column(Obiview_p view,
|
||||
const char* column_name,
|
||||
obiversion_t version_number,
|
||||
const char* alias,
|
||||
OBIType_t data_type,
|
||||
index_t nb_lines,
|
||||
index_t nb_elements_per_line,
|
||||
@ -354,6 +372,27 @@ OBIDMS_column_p obi_view_get_column(Obiview_p view, const char* column_name);
|
||||
OBIDMS_column_p* obi_view_get_pointer_on_column_in_view(Obiview_p view, const char* column_name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Changes the name that identifies a column in the context of a view.
|
||||
*
|
||||
* In the context of a view, each column is identified by a name that is unique in this view.
|
||||
*
|
||||
* @warning The view must be writable.
|
||||
*
|
||||
* @param view A pointer on the view.
|
||||
* @param current_name The current name that identifies the column in this view.
|
||||
* @param alias The new name that should be used to identify the column in this view.
|
||||
*
|
||||
* @returns A value indicating the success of the operation.
|
||||
* @retval 0 if the operation was successfully completed.
|
||||
* @retval -1 if an error occurred.
|
||||
*
|
||||
* @since July 2016
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
int obi_view_create_column_alias(Obiview_p view, const char* current_name, const char* alias);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Selects a line in the context of a view.
|
||||
*
|
||||
@ -450,22 +489,7 @@ int obi_close_view(Obiview_p view);
|
||||
int obi_save_and_close_view(Obiview_p view);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Closes the structure containing all the informations written in the view file.
|
||||
*
|
||||
* @param views A pointer on the view informations structure.
|
||||
*
|
||||
* @returns A value indicating the success of the operation.
|
||||
* @retval 0 if the operation was successfully completed.
|
||||
* @retval -1 if an error occurred.
|
||||
*
|
||||
* @since February 2016
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
int obi_close_view_infos(Obiviews_infos_all_p views);
|
||||
|
||||
|
||||
// TODO in following functions would it be better to use column names instead of column pointers?
|
||||
// in following functions would it be better to use column names instead of column pointers?
|
||||
// check if it would be a gain or loss of time
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user