Obiblob_indexer API
This commit is contained in:
44
src/obidms.c
44
src/obidms.c
@ -249,7 +249,7 @@ OBIDMS_p obi_create_dms(const char* dms_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Get file descriptor of DMS directory to create the AVL trees directory
|
||||
// Get file descriptor of DMS directory to create the indexer directory
|
||||
dms_dir = opendir(directory_name);
|
||||
if (dms_dir == NULL)
|
||||
{
|
||||
@ -269,11 +269,11 @@ OBIDMS_p obi_create_dms(const char* dms_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create the AVL trees directory
|
||||
if (mkdirat(dms_file_descriptor, AVL_TREES_DIR_NAME, 00777) < 0)
|
||||
// Create the indexer directory
|
||||
if (mkdirat(dms_file_descriptor, INDEXER_DIR_NAME, 00777) < 0)
|
||||
{
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
obidebug(1, "\nProblem creating an AVL trees directory");
|
||||
obi_set_errno(OBI_INDEXER_ERROR);
|
||||
obidebug(1, "\nProblem creating an indexer directory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -392,24 +392,24 @@ OBIDMS_p obi_open_dms(const char* dms_name)
|
||||
|
||||
dms->little_endian = little_endian_dms;
|
||||
|
||||
// Open the AVL trees directory
|
||||
dms->avl_directory = opendir_in_dms(dms, AVL_TREES_DIR_NAME);
|
||||
if (dms->avl_directory == NULL)
|
||||
// Open the indexer directory
|
||||
dms->indexer_directory = opendir_in_dms(dms, INDEXER_DIR_NAME);
|
||||
if (dms->indexer_directory == NULL)
|
||||
{
|
||||
obi_set_errno(OBIDMS_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError opening the AVL trees directory");
|
||||
obidebug(1, "\nError opening the indexer directory");
|
||||
closedir(dms->directory);
|
||||
free(dms);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Store the AVL trees directory's file descriptor
|
||||
dms->avl_dir_fd = dirfd(dms->avl_directory);
|
||||
if (dms->avl_dir_fd < 0)
|
||||
// Store the indexer directory's file descriptor
|
||||
dms->indexer_dir_fd = dirfd(dms->indexer_directory);
|
||||
if (dms->indexer_dir_fd < 0)
|
||||
{
|
||||
obi_set_errno(OBIDMS_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError getting the file descriptor of the AVL trees directory");
|
||||
closedir(dms->avl_directory);
|
||||
obidebug(1, "\nError getting the file descriptor of the indexer directory");
|
||||
closedir(dms->indexer_directory);
|
||||
closedir(dms->directory);
|
||||
free(dms);
|
||||
return NULL;
|
||||
@ -420,10 +420,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 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;
|
||||
// Initialize the list of opened indexers // TODO should be handled somewhere else?
|
||||
dms->opened_indexers = (Opened_indexers_list_p) malloc(sizeof(Opened_indexers_list_t));
|
||||
(dms->opened_indexers)->indexers = (OBIDMS_avl_p*) malloc(MAX_NB_OPENED_INDEXERS*sizeof(OBIDMS_avl_p)); // TODO idk how to handle this
|
||||
(dms->opened_indexers)->nb_opened_indexers = 0;
|
||||
|
||||
return dms;
|
||||
}
|
||||
@ -456,7 +456,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 AVL trees directories
|
||||
// Close dms and indexer directories
|
||||
if (closedir(dms->directory) < 0)
|
||||
{
|
||||
obi_set_errno(OBIDMS_MEMORY_ERROR);
|
||||
@ -464,10 +464,10 @@ int obi_close_dms(OBIDMS_p dms)
|
||||
free(dms);
|
||||
return -1;
|
||||
}
|
||||
if (closedir(dms->avl_directory) < 0)
|
||||
if (closedir(dms->indexer_directory) < 0) // TODO should be handled somewhere else?
|
||||
{
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
obidebug(1, "\nError closing an AVL trees directory");
|
||||
obi_set_errno(OBI_INDEXER_ERROR);
|
||||
obidebug(1, "\nError closing an indexer directory");
|
||||
free(dms);
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user