Obiblob_indexer API

This commit is contained in:
Celine Mercier
2016-04-12 14:53:33 +02:00
parent cd4e65e190
commit d8107533d8
21 changed files with 252 additions and 131 deletions

View File

@ -510,7 +510,7 @@ char* get_full_path_of_avl_dir(OBIDMS_p dms, const char* avl_name)
{
char* avl_dir_name;
avl_dir_name = get_full_path(dms, AVL_TREES_DIR_NAME);
avl_dir_name = get_full_path(dms, INDEXER_DIR_NAME);
if (avl_dir_name == NULL)
{
obidebug(1, "\nError getting path for the DMS AVL directory");
@ -1291,7 +1291,7 @@ int obi_avl_exists(OBIDMS_p dms, const char* avl_name)
int check_dir;
// Build the AVL tree file path
relative_path_size = strlen(avl_name) + strlen(AVL_TREES_DIR_NAME) + 2;
relative_path_size = strlen(avl_name) + strlen(INDEXER_DIR_NAME) + 2;
avl_dir_relative_path = (char*) malloc(relative_path_size*sizeof(char));
if (avl_dir_relative_path == NULL)
{
@ -1299,7 +1299,7 @@ int obi_avl_exists(OBIDMS_p dms, const char* avl_name)
obidebug(1, "\nError allocating memory for the path to the AVL directory");
return -1;
}
strcpy(avl_dir_relative_path, AVL_TREES_DIR_NAME);
strcpy(avl_dir_relative_path, INDEXER_DIR_NAME);
strcat(avl_dir_relative_path, "/");
strcat(avl_dir_relative_path, avl_name);
avl_dir_path = get_full_path(dms, avl_dir_relative_path);
@ -1367,7 +1367,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
// Create that AVL's directory if it doesn't already exist
if (check_dir < 0)
{
if (mkdirat(dms->avl_dir_fd, avl_dir_name, 00777) < 0)
if (mkdirat(dms->indexer_dir_fd, avl_dir_name, 00777) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError creating an AVL directory");
@ -1596,7 +1596,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
avl->dms = dms;
avl->data = avl_data;
avl->directory = dms->avl_directory;
avl->directory = dms->indexer_directory;
avl->dir_fd = avl_dir_fd;
avl->avl_fd = avl_file_descriptor;
@ -1612,8 +1612,8 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
bloom_init(&((avl->header)->bloom_filter), MAX_NODE_COUNT_PER_AVL);
// Add in the list of opened AVL trees
*(((dms->opened_avls)->avls)+((dms->opened_avls)->nb_opened_avls)) = avl;
((dms->opened_avls)->nb_opened_avls)++;
*(((dms->opened_indexers)->indexers)+((dms->opened_indexers)->nb_opened_indexers)) = avl;
((dms->opened_indexers)->nb_opened_indexers)++;
avl->counter = 1;
if (avl_idx >= 0)
@ -1658,14 +1658,14 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
}
// Check if the AVL tree is already in the list of opened AVL trees
for (i=0; i < ((dms->opened_avls)->nb_opened_avls); i++)
for (i=0; i < ((dms->opened_indexers)->nb_opened_indexers); i++)
{
if (!strcmp(((*(((dms->opened_avls)->avls)+i))->header)->avl_name, complete_avl_name))
if (!strcmp(((*(((dms->opened_indexers)->indexers)+i))->header)->avl_name, complete_avl_name))
{ // Found the AVL tree already opened
((*(((dms->opened_avls)->avls)+i))->counter)++;
((*(((dms->opened_indexers)->indexers)+i))->counter)++;
if (avl_idx >= 0)
free(complete_avl_name);
return *(((dms->opened_avls)->avls)+i);
return *(((dms->opened_indexers)->indexers)+i);
}
}
@ -1873,13 +1873,13 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
avl->dms = dms;
avl->data = avl_data;
avl->directory = dms->avl_directory;
avl->directory = dms->indexer_directory;
avl->dir_fd = avl_dir_file_descriptor;
avl->avl_fd = avl_file_descriptor;
// Add in the list of opened AVL trees
*(((dms->opened_avls)->avls)+((dms->opened_avls)->nb_opened_avls)) = avl;
((dms->opened_avls)->nb_opened_avls)++;
*(((dms->opened_indexers)->indexers)+((dms->opened_indexers)->nb_opened_indexers)) = avl;
((dms->opened_indexers)->nb_opened_indexers)++;
avl->counter = 1;
if (avl_idx >= 0)
@ -1983,26 +1983,26 @@ OBIDMS_avl_group_p obi_open_avl_group(OBIDMS_p dms, const char* avl_name)
int obi_close_avl(OBIDMS_avl_p avl)
{
int ret_val = 0;
size_t i;
Opened_avls_list_p avls_list;
OBIDMS_p dms;
int ret_val = 0;
size_t i;
Opened_indexers_list_p indexers_list;
OBIDMS_p dms;
dms = avl->dms;
avls_list = dms->opened_avls;
indexers_list = dms->opened_indexers;
(avl->counter)--;
if (avl->counter == 0)
{
// Delete from the list of opened avls
for (i=0; i < (avls_list->nb_opened_avls); i++)
for (i=0; i < (indexers_list->nb_opened_indexers); i++)
{
if (!strcmp(((*((avls_list->avls)+i))->header)->avl_name, (avl->header)->avl_name))
if (!strcmp(((*((indexers_list->indexers)+i))->header)->avl_name, (avl->header)->avl_name))
{ // Found the avl. Rearrange list
(avls_list->nb_opened_avls)--;
(avls_list->avls)[i] = (avls_list->avls)[avls_list->nb_opened_avls];
(indexers_list->nb_opened_indexers)--;
(indexers_list->indexers)[i] = (indexers_list->indexers)[indexers_list->nb_opened_indexers];
}
}