First version of quality handling (not working yet) and now it is

checked that a column is writable before enlarging it
This commit is contained in:
Celine Mercier
2016-05-11 16:38:14 +02:00
parent b3c47809da
commit 8ae7644945
8 changed files with 540 additions and 8 deletions

View File

@ -587,7 +587,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
}
// Build the indexer name if needed
if ((data_type == OBI_STR) || (data_type == OBI_SEQ))
if ((data_type == OBI_STR) || (data_type == OBI_SEQ) || (data_type == OBI_QUAL))
{
if (strcmp(indexer_name, "") == 0)
{
@ -603,7 +603,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
}
returned_data_type = data_type;
if ((data_type == OBI_STR) || (data_type == OBI_SEQ))
if ((data_type == OBI_STR) || (data_type == OBI_SEQ) || (data_type == OBI_QUAL))
// stored data is indices referring to data stored elsewhere
stored_data_type = OBI_IDX;
else
@ -750,8 +750,8 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
if (comments != NULL)
strncpy(header->comments, comments, COMMENTS_MAX_LENGTH);
// If the data type is OBI_STR or OBI_SEQ, the associated obi_indexer is opened or created
if ((returned_data_type == OBI_STR) || (returned_data_type == OBI_SEQ))
// If the data type is OBI_STR, OBI_SEQ or OBI_QUAL, the associated obi_indexer is opened or created
if ((returned_data_type == OBI_STR) || (returned_data_type == OBI_SEQ) || (returned_data_type == OBI_QUAL))
{
new_column->indexer = obi_indexer(dms, final_indexer_name);
if (new_column->indexer == NULL)
@ -900,8 +900,8 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
column->writable = false;
// If the data type is OBI_STR or OBI_SEQ, the associated indexer is opened
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
// If the data type is OBI_STR, OBI_SEQ or OBI_QUAL, the associated indexer is opened
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ) || ((column->header)->returned_data_type == OBI_QUAL))
{
column->indexer = obi_open_indexer(dms, (column->header)->indexer_name);
if (column->indexer == NULL)
@ -1028,8 +1028,8 @@ int obi_close_column(OBIDMS_column_p column)
// Close column directory if it was the last column opened from that directory
close_dir = obi_dms_is_column_name_in_list(column->dms, (column->header)->name);
// If the data type is OBI_STR or OBI_SEQ, the associated indexer is closed
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
// If the data type is OBI_STR, OBI_SEQ or OBI_QUAL, the associated indexer is closed
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ) || ((column->header)->returned_data_type == OBI_QUAL))
if (obi_close_indexer(column->indexer) < 0)
ret_val = -1;
@ -1155,6 +1155,14 @@ int obi_enlarge_column(OBIDMS_column_p column)
int column_file_descriptor;
char* column_file_name;
// Check if the column is read-only
if (!(column->writable))
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError trying to enlarge a read-only column");
return -1;
}
// Get the column file name
column_file_name = build_column_file_name((column->header)->name, (column->header)->version);
if (column_file_name == NULL)
@ -1274,6 +1282,12 @@ void obi_ini_to_NA_values(OBIDMS_column_p column,
}
break;
case OBI_QUAL: for (i=start;i<end;i++)
{
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
}
break;
case OBI_STR: for (i=start;i<end;i++)
{
*(((index_t*) (column->data)) + i) = OBIIdx_NA;