DNA sequences and character strings are now handled using AVL trees.
This commit is contained in:
44
src/obidms.c
44
src/obidms.c
@ -247,7 +247,7 @@ OBIDMS_p obi_create_dms(const char* dms_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Get file descriptor of DMS directory to create the arrays directory
|
||||
// Get file descriptor of DMS directory to create the AVL trees directory
|
||||
dms_dir = opendir(directory_name);
|
||||
if (dms_dir == NULL)
|
||||
{
|
||||
@ -267,11 +267,11 @@ OBIDMS_p obi_create_dms(const char* dms_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create the arrays directory
|
||||
if (mkdirat(dms_file_descriptor, ARRAYS_DIR_NAME, 00777) < 0)
|
||||
// Create the AVL trees directory
|
||||
if (mkdirat(dms_file_descriptor, AVL_TREES_DIR_NAME, 00777) < 0)
|
||||
{
|
||||
obi_set_errno(OBI_ARRAY_ERROR);
|
||||
obidebug(1, "\nProblem creating an arrays directory");
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
obidebug(1, "\nProblem creating an AVL trees directory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -390,24 +390,24 @@ OBIDMS_p obi_open_dms(const char* dms_name)
|
||||
|
||||
dms->little_endian = little_endian_dms;
|
||||
|
||||
// Open the arrays directory
|
||||
dms->array_directory = private_opendirat(dms->dir_fd, ARRAYS_DIR_NAME);
|
||||
if (dms->array_directory == NULL)
|
||||
// Open the AVL trees directory
|
||||
dms->avl_directory = private_opendirat(dms->dir_fd, AVL_TREES_DIR_NAME);
|
||||
if (dms->avl_directory == NULL)
|
||||
{
|
||||
obi_set_errno(OBIDMS_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError opening the arrays directory");
|
||||
obidebug(1, "\nError opening the AVL trees directory");
|
||||
closedir(dms->directory);
|
||||
free(dms);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Store the array directory's file descriptor
|
||||
dms->array_dir_fd = dirfd(dms->array_directory);
|
||||
if (dms->array_dir_fd < 0)
|
||||
// Store the AVL trees directory's file descriptor
|
||||
dms->avl_dir_fd = dirfd(dms->avl_directory);
|
||||
if (dms->avl_dir_fd < 0)
|
||||
{
|
||||
obi_set_errno(OBIDMS_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError getting the file descriptor of the arrays directory");
|
||||
closedir(dms->array_directory);
|
||||
obidebug(1, "\nError getting the file descriptor of the AVL trees directory");
|
||||
closedir(dms->avl_directory);
|
||||
closedir(dms->directory);
|
||||
free(dms);
|
||||
return NULL;
|
||||
@ -418,10 +418,10 @@ OBIDMS_p obi_open_dms(const char* dms_name)
|
||||
(dms->opened_columns)->columns = (OBIDMS_column_p*) malloc(MAX_NB_OPENED_COLUMNS*sizeof(OBIDMS_column_p));
|
||||
(dms->opened_columns)->nb_opened_columns = 0;
|
||||
|
||||
// Initialize the list of opened arrays
|
||||
dms->opened_arrays = (Opened_arrays_list_p) malloc(sizeof(Opened_arrays_list_t));
|
||||
(dms->opened_arrays)->arrays = (OBIDMS_array_p*) malloc(MAX_NB_OPENED_ARRAYS*sizeof(OBIDMS_array_p));
|
||||
(dms->opened_arrays)->nb_opened_arrays = 0;
|
||||
// Initialize the list of opened AVL trees
|
||||
dms->opened_avls = (Opened_avls_list_p) malloc(sizeof(Opened_avls_list_t));
|
||||
(dms->opened_avls)->avls = (OBIDMS_avl_p*) malloc(MAX_NB_OPENED_AVL_TREES*sizeof(OBIDMS_avl_p));
|
||||
(dms->opened_avls)->nb_opened_avls = 0;
|
||||
|
||||
return dms;
|
||||
}
|
||||
@ -454,7 +454,7 @@ int obi_close_dms(OBIDMS_p dms)
|
||||
while ((dms->opened_columns)->nb_opened_columns > 0)
|
||||
obi_close_column(*((dms->opened_columns)->columns));
|
||||
|
||||
// Close dms and array directories
|
||||
// Close dms and AVL trees directories
|
||||
if (closedir(dms->directory) < 0)
|
||||
{
|
||||
obi_set_errno(OBIDMS_MEMORY_ERROR);
|
||||
@ -462,10 +462,10 @@ int obi_close_dms(OBIDMS_p dms)
|
||||
free(dms);
|
||||
return -1;
|
||||
}
|
||||
if (closedir(dms->array_directory) < 0)
|
||||
if (closedir(dms->avl_directory) < 0)
|
||||
{
|
||||
obi_set_errno(OBI_ARRAY_ERROR);
|
||||
obidebug(1, "\nError closing an array directory");
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
obidebug(1, "\nError closing an AVL trees directory");
|
||||
free(dms);
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user