Commit 9d91e907 by Celine Mercier

When a column is created, its data is initialized to the NA value of the

obitype
parent 3f81dc01
......@@ -600,6 +600,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
int column_dir_file_descriptor;
size_t header_size;
size_t data_size;
size_t i, nb_elements;
new_column = NULL;
......@@ -730,6 +731,43 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
strncpy(header->name, column_name, OBIDMS_MAX_COLNAME);
// Fill the data with NA values
nb_elements = nb_lines*nb_elements_per_line;
switch (type) {
case OBI_VOID: // TODO;
break;
case OBI_INT: for (i=0;i<nb_elements;i++)
{
*(((obiint_t*) (new_column->data)) + i) = OBIInt_NA;
}
break;
case OBI_FLOAT: for (i=0;i<nb_elements;i++)
{
*(((obifloat_t*) (new_column->data)) + i) = OBIFloat_NA;
}
break;
case OBI_BOOL: for (i=0;i<nb_elements;i++)
{
*(((obibool_t*) (new_column->data)) + i) = OBIBool_NA;
}
break;
case OBI_CHAR: for (i=0;i<nb_elements;i++)
{
*(((obichar_t*) (new_column->data)) + i) = OBIChar_NA;
}
break;
case OBI_IDX: for (i=0;i<nb_elements;i++)
{
*(((obiidx_t*) (new_column->data)) + i) = OBIIdx_NA;
}
break;
}
free(column_file_name);
close(column_file_descriptor);
......
......@@ -14,8 +14,9 @@
#define OBIInt_NA (INT32_MIN)
#define OBIFloat_NA (NAN)
#define OBIIdx_NA (SIZE_MAX)
#define OBIFloat_NA (float_NA())
#define OBIChar_NA (0) // TODO not sure about this one as it can be impossible to distinguish from uninitialized values
/**
......@@ -47,6 +48,22 @@ typedef char obichar_t;
typedef size_t obiidx_t;
typedef union
{
double value;
unsigned int word[2];
} ieee_double;
static double float_NA(void) // as defined in R
{
volatile ieee_double x;
x.word[0] = 0x7ff00000;
x.word[1] = 1954;
return x.value;
}
/**
* @brief returns the memory size in bytes of an OBIType
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment