DNA sequences and character strings are now handled using AVL trees.

This commit is contained in:
Celine Mercier
2015-12-11 17:24:44 +01:00
parent 1586956d57
commit c139367555
26 changed files with 2178 additions and 1711 deletions

View File

@ -29,7 +29,7 @@
#include "obierrno.h"
#include "obidebug.h"
#include "obilittlebigman.h"
#include "obiarray.h"
#include "obiavl.h"
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
@ -514,14 +514,14 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
index_t nb_lines,
index_t nb_elements_per_line,
const char* elements_names,
const char* array_name,
const char* avl_name,
const char* comments,
bool referring)
{
OBIDMS_column_p new_column;
OBIDMS_column_directory_p column_directory;
OBIDMS_column_header_p header;
OBIDMS_array_p array;
OBIDMS_avl_p avl;
size_t file_size;
obiversion_t version_number;
char* column_file_name;
@ -552,9 +552,9 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
obidebug(1, "\nCan't create column because of invalid data type");
return NULL;
}
if (((data_type == OBI_STR) || (data_type == OBI_SEQ)) && (array_name == NULL))
if (((data_type == OBI_STR) || (data_type == OBI_SEQ)) && (avl_name == NULL))
{
obidebug(1, "\nCan't create column because of empty array name");
obidebug(1, "\nCan't create column because of empty avl name");
return NULL;
}
@ -732,20 +732,20 @@ 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_array is opened or created
// If the data type is OBI_STR or OBI_SEQ, the associated obi_avl is opened or created
if ((returned_data_type == OBI_STR) || (returned_data_type == OBI_SEQ))
{
array = obi_array(dms, array_name);
if (array == NULL)
avl = obi_avl(dms, avl_name);
if (avl == NULL)
{
obidebug(1, "\nError opening or creating the array associated with a column");
obidebug(1, "\nError opening or creating the aVL tree associated with a column");
munmap(new_column->header, header_size);
close(column_file_descriptor);
free(new_column);
return NULL;
}
new_column->array = array;
strncpy(header->array_name, array_name, ARRAY_MAX_NAME);
new_column->avl = avl;
strncpy(header->avl_name, avl_name, AVL_MAX_NAME);
}
// Fill the data with NA values
@ -768,7 +768,7 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
{
OBIDMS_column_p column;
OBIDMS_column_directory_p column_directory;
OBIDMS_array_p array;
OBIDMS_avl_p avl;
char* column_file_name;
int column_file_descriptor;
size_t header_size;
@ -886,19 +886,19 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
column->writable = false;
// If the data type is OBI_STR or OBI_SEQ, the associated obi_array is opened
// If the data type is OBI_STR or OBI_SEQ, the associated AVL tree is opened
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
{
array = obi_array(dms, (column->header)->array_name);
if (array == NULL)
avl = obi_avl(dms, (column->header)->avl_name);
if (avl == NULL)
{
obidebug(1, "\nError opening the array associated with a column");
obidebug(1, "\nError opening the AVL tree associated with a column");
munmap(column->header, header_size);
close(column_file_descriptor);
free(column);
return NULL;
}
column->array = array;
column->avl = avl;
}
if ((column->header)->referring)
@ -973,7 +973,7 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms,
nb_lines,
nb_elements_per_line,
(column_to_clone->header)->elements_names,
(column_to_clone->header)->array_name,
(column_to_clone->header)->avl_name,
(column_to_clone->header)->comments,
referring);
@ -1052,10 +1052,10 @@ int obi_close_column(OBIDMS_column_p column)
if ((column->header)->referring)
obi_close_column(column->referred_column);
// If the data type is OBI_STR or OBI_SEQ, the associated obi_array is closed
// If the data type is OBI_STR or OBI_SEQ, the associated AVL tree is closed
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
{
if (obi_close_array(column->array) < 0)
if (obi_close_avl(column->avl) < 0)
return -1;
}