Added functions to recover the indexes themselves from any column
referring to indexed values
This commit is contained in:
@ -44,3 +44,24 @@ index_t obi_column_get_index(OBIDMS_column_p column, index_t line_nb)
|
||||
return *(((index_t*) (column->data)) + line_nb);
|
||||
}
|
||||
|
||||
|
||||
index_t obi_column_get_index_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx)
|
||||
{
|
||||
if (obi_column_prepare_to_get_value(column, line_nb) < 0)
|
||||
return OBIIdx_NA;
|
||||
|
||||
return *(((index_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx);
|
||||
}
|
||||
|
||||
|
||||
index_t obi_column_get_index_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name)
|
||||
{
|
||||
index_t element_idx = obi_column_get_element_index_from_name(column, element_name);
|
||||
if (element_idx == OBIIdx_NA)
|
||||
return OBIIdx_NA;
|
||||
|
||||
return obi_column_get_index_with_elt_idx(column, line_nb, element_idx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -64,5 +64,38 @@ int obi_column_set_index(OBIDMS_column_p column, index_t line_nb, index_t value)
|
||||
index_t obi_column_get_index(OBIDMS_column_p column, index_t line_nb);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Recovers a value in an OBIDMS column containing data with the type OBI_IDX.
|
||||
*
|
||||
* @param column A pointer as returned by obi_create_column().
|
||||
* @param line_nb The number of the line where the value should be recovered.
|
||||
* @param element_idx The index of the element that should be recovered in the line.
|
||||
*
|
||||
* @returns The recovered value.
|
||||
* @retval OBIIdx_NA the NA value of the type if an error occurred and obi_errno is set.
|
||||
*
|
||||
* @since November 2016
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
index_t obi_column_get_index_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Recovers a value in an OBIDMS column containing data with the type OBI_IDX,
|
||||
* using the name of the element in the line.
|
||||
*
|
||||
* @param column A pointer as returned by obi_create_column() or obi_clone_column().
|
||||
* @param line_nb The number of the line where the value should be recovered.
|
||||
* @param element_name The name of the element that should be recovered in the line.
|
||||
*
|
||||
* @returns The recovered value.
|
||||
* @retval OBIIdx_NA the NA value of the type if an error occurred and obi_errno is set.
|
||||
*
|
||||
* @since November 2016
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
index_t obi_column_get_index_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name);
|
||||
|
||||
|
||||
#endif /* OBIDMSCOLUMN_IDX_H_ */
|
||||
|
||||
|
@ -2721,3 +2721,44 @@ const char* obi_get_str_with_elt_name_and_col_name_in_view(Obiview_p view, const
|
||||
|
||||
/****************************************/
|
||||
|
||||
|
||||
/*********** FOR COLUMNS WITH INDEXED VALUES ***********/
|
||||
|
||||
index_t obi_get_index_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, index_t element_idx)
|
||||
{
|
||||
if (prepare_to_get_value_from_column(view, &line_nb) < 0)
|
||||
return OBIIdx_NA;
|
||||
return obi_column_get_index_with_elt_idx(column, line_nb, element_idx);
|
||||
}
|
||||
|
||||
|
||||
index_t obi_get_index_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, const char* element_name)
|
||||
{
|
||||
index_t element_idx = obi_column_get_element_index_from_name(column, element_name);
|
||||
if (element_idx == OBIIdx_NA)
|
||||
return OBIIdx_NA;
|
||||
return obi_get_index_with_elt_idx_and_col_p_in_view(view, column, line_nb, element_idx);
|
||||
}
|
||||
|
||||
|
||||
index_t obi_get_index_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx)
|
||||
{
|
||||
OBIDMS_column_p column_p;
|
||||
column_p = obi_view_get_column(view, column_name);
|
||||
if (column_p == NULL)
|
||||
return OBIIdx_NA;
|
||||
return obi_get_index_with_elt_idx_and_col_p_in_view(view, column_p, line_nb, element_idx);
|
||||
}
|
||||
|
||||
|
||||
index_t obi_get_index_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name)
|
||||
{
|
||||
OBIDMS_column_p column_p;
|
||||
column_p = obi_view_get_column(view, column_name);
|
||||
if (column_p == NULL)
|
||||
return OBIIdx_NA;
|
||||
return obi_get_index_with_elt_name_and_col_p_in_view(view, column_p, line_nb, element_name);
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
|
||||
|
@ -1314,4 +1314,53 @@ const char* obi_get_str_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_c
|
||||
const char* obi_get_str_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Recovers a value in an OBIDMS column containing indexes, in the context of a view.
|
||||
*
|
||||
* This enables to recover the indexes in columns containing any type of indexed data (OBI_SEQ, OBI_STR...), for example to quickly test if
|
||||
* the values are identical (same index in the same indexer).
|
||||
*
|
||||
* @param view A pointer on the opened view.
|
||||
* @param column A pointer on the column.
|
||||
* @param line_nb The number of the line where the value should be recovered.
|
||||
* @param element_idx The index of the element that should be recovered in the line.
|
||||
*
|
||||
* @returns The recovered value.
|
||||
* @retval OBIIdx_NA the NA value of the type if an error occurred and obi_errno is set.
|
||||
*
|
||||
* @since November 2016
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
index_t obi_get_index_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx);
|
||||
|
||||
|
||||
// TODO
|
||||
index_t obi_get_index_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Recovers a value in an OBIDMS column containing indexes,
|
||||
* using the name of the element in the line, in the context of a view.
|
||||
*
|
||||
* This enables to recover the indexes in columns containing any type of indexed data (OBI_SEQ, OBI_STR...), for example to quickly test if
|
||||
* the values are identical (same index in the same indexer).
|
||||
*
|
||||
* @param view A pointer on the opened view.
|
||||
* @param column A pointer on the column.
|
||||
* @param line_nb The number of the line where the value should be recovered.
|
||||
* @param element_name The name of the element that should be recovered in the line.
|
||||
*
|
||||
* @returns The recovered value.
|
||||
* @retval OBIIdx_NA the NA value of the type if an error occurred and obi_errno is set.
|
||||
*
|
||||
* @since November 2016
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
index_t obi_get_index_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name);
|
||||
|
||||
|
||||
// TODO
|
||||
index_t obi_get_index_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name);
|
||||
|
||||
|
||||
#endif /* OBIVIEW_H_ */
|
||||
|
Reference in New Issue
Block a user