Major update: new type of columns containing indices referring to lines
in other columns
This commit is contained in:
@ -34,6 +34,14 @@ int obi_column_set_obistr_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
|
||||
byte_t* value_b;
|
||||
index_t idx;
|
||||
|
||||
// Check that the column is not referring another
|
||||
if ((column->header)->referring)
|
||||
{
|
||||
obi_set_errno(OBICOL_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError: Setting a value from a referring column is not allowed. The referred column must be cloned to be modified");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check that the line number is not greater than the maximum allowed
|
||||
if (line_nb >= MAXIMUM_LINE_COUNT)
|
||||
{
|
||||
@ -65,7 +73,7 @@ int obi_column_set_obistr_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
|
||||
return -1;
|
||||
|
||||
// Add the value's index in the column
|
||||
*(((index_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx) = idx;
|
||||
*(((index_t*) (column->data)) + (line_nb * ((column->header)->stored_nb_elements_per_line)) + element_idx) = idx;
|
||||
|
||||
free(value_b);
|
||||
|
||||
@ -77,6 +85,7 @@ const char* obi_column_get_obistr_with_elt_idx(OBIDMS_column_p column, index_t l
|
||||
{
|
||||
index_t idx;
|
||||
byte_t* value_b;
|
||||
index_t referring_idx;
|
||||
|
||||
if ((line_nb+1) > (column->header)->lines_used)
|
||||
{
|
||||
@ -85,7 +94,13 @@ const char* obi_column_get_obistr_with_elt_idx(OBIDMS_column_p column, index_t l
|
||||
return "\0"; // TODO
|
||||
}
|
||||
|
||||
idx = *(((index_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx);
|
||||
if ((column->header)->referring)
|
||||
{
|
||||
referring_idx = *(((index_t*) (column->data)) + line_nb);
|
||||
idx = *(((index_t*) ((column->referred_column)->data)) + (referring_idx * ((column->header)->returned_nb_elements_per_line)) + element_idx);
|
||||
}
|
||||
else
|
||||
idx = *(((index_t*) (column->data)) + (line_nb * ((column->header)->stored_nb_elements_per_line)) + element_idx);
|
||||
|
||||
// Check NA
|
||||
if (idx == OBIIdx_NA)
|
||||
|
Reference in New Issue
Block a user