The number of lines used is updated in the header when a value is set,

and the iteration on the values of a column is done on the number of
lines used (instead of on the total line count).
This commit is contained in:
Celine Mercier
2015-08-26 17:25:15 +02:00
parent 34ade161de
commit 3b7536c0df
9 changed files with 37 additions and 8 deletions

View File

@ -26,7 +26,7 @@ cdef extern from "obidmscolumn.h" nogil:
ctypedef int32_t obiversion_t
OBIDMS_column_p obi_create_column(OBIDMS_p dms, const char* column_name, OBIType_t type, size_t nb_lines, size_t nb_elements_per_line, const char* elements_names)
size_t obi_column_get_line_count(OBIDMS_column_p column)
size_t obi_column_get_nb_lines_used(OBIDMS_column_p column)
const char* obi_column_get_elements_names(OBIDMS_column_p column)
void obi_column_make_unwritable(OBIDMS_column_p column)
OBIDMS_column_p obi_open_column(OBIDMS_p dms, const char* column_name, obiversion_t version_number)

View File

@ -43,8 +43,8 @@ cdef class OBIDMS_column:
multiple_elements = True
else :
element_name = elements_names[0]
line_count = obi_column_get_line_count(self.pointer)
for line_nb in xrange(line_count):
lines_used = obi_column_get_nb_lines_used(self.pointer)
for line_nb in xrange(lines_used):
if multiple_elements :
line = []
for element_name in elements_names :

View File

@ -1089,6 +1089,12 @@ size_t obi_column_get_line_count(OBIDMS_column_p column)
}
size_t obi_column_get_nb_lines_used(OBIDMS_column_p column)
{
return (column->header)->lines_used;
}
OBIType_t obi_column_get_data_type(OBIDMS_column_p column)
{
return (column->header)->data_type;

View File

@ -243,6 +243,19 @@ void obi_column_make_unwritable(OBIDMS_column_p column);
size_t obi_column_get_line_count(OBIDMS_column_p column);
/**
* @brief Recovers the number of lines used in an OBIDMS column.
*
* @param column a pointer on an OBIDMS column
*
* @return the number of lines used in the column
*
* @since August 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
size_t obi_column_get_nb_lines_used(OBIDMS_column_p column);
/**
* @brief Recovers the data type of an OBIDMS column.
*

View File

@ -30,7 +30,9 @@
int obi_column_set_bool_with_elt_idx(OBIDMS_column_p column, size_t line_nb, size_t element_idx, obibool_t value)
{
// when/where check if can write?
// Update lines used
if ((line_nb+1) > (column->header)->lines_used)
(column->header)->lines_used = line_nb+1;
*(((obibool_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx) = value;
return 0;
}

View File

@ -30,7 +30,9 @@
int obi_column_set_char_with_elt_idx(OBIDMS_column_p column, size_t line_nb, size_t element_idx, obichar_t* value)
{
// when/where check if can write?
// Update lines used
if ((line_nb+1) > (column->header)->lines_used)
(column->header)->lines_used = line_nb+1;
*(((obichar_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx) = value[0];
return 0;
}

View File

@ -30,7 +30,9 @@
int obi_column_set_float_with_elt_idx(OBIDMS_column_p column, size_t line_nb, size_t element_idx, obifloat_t value)
{
// when/where check if can write?
// Update lines used
if ((line_nb+1) > (column->header)->lines_used)
(column->header)->lines_used = line_nb+1;
*(((obifloat_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx) = value;
return 0;
}

View File

@ -30,7 +30,9 @@
int obi_column_set_idx_with_elt_idx(OBIDMS_column_p column, size_t line_nb, size_t element_idx, obiidx_t value)
{
// when/where check if can write?
// Update lines used
if ((line_nb+1) > (column->header)->lines_used)
(column->header)->lines_used = line_nb+1;
*(((obiidx_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx) = value;
return 0;
}

View File

@ -30,7 +30,9 @@
int obi_column_set_int_with_elt_idx(OBIDMS_column_p column, size_t line_nb, size_t element_idx, obiint_t value)
{
// when/where check if can write?
// Update lines used
if ((line_nb+1) > (column->header)->lines_used)
(column->header)->lines_used = line_nb+1;
*(((obiint_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx) = value;
return 0;
}