Branch to refactor and debug (AVLs bugged)
This commit is contained in:
@ -30,6 +30,7 @@
|
||||
#include "obidebug.h"
|
||||
#include "obilittlebigman.h"
|
||||
#include "obiavl.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
|
||||
@ -726,15 +727,15 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
|
||||
// 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))
|
||||
{
|
||||
new_column->avl = obi_create_avl_group(dms, avl_name);
|
||||
// if (avl == NULL) TODO
|
||||
// {
|
||||
// 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->avl = obi_avl_group(dms, avl_name);
|
||||
if (new_column->avl == NULL)
|
||||
{
|
||||
obidebug(1, "\nError opening or creating the AVL group associated with a column");
|
||||
munmap(new_column->header, header_size);
|
||||
close(column_file_descriptor);
|
||||
free(new_column);
|
||||
return NULL;
|
||||
}
|
||||
strncpy(header->avl_name, avl_name, AVL_MAX_NAME);
|
||||
}
|
||||
|
||||
@ -762,7 +763,6 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
|
||||
int column_file_descriptor;
|
||||
size_t header_size;
|
||||
size_t i;
|
||||
OBIDMS_avl_p avl;
|
||||
|
||||
column = NULL;
|
||||
|
||||
@ -770,7 +770,7 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
|
||||
column_directory = obi_open_column_directory(dms, column_name);
|
||||
if (column_directory == NULL)
|
||||
{
|
||||
//obidebug(1, "\nError opening a column directory structure");
|
||||
//obidebug(1, "\nError opening a column directory structure"); // TODO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -879,8 +879,8 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
|
||||
// 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))
|
||||
{
|
||||
avl = obi_avl(dms, (column->header)->avl_name);
|
||||
if (avl == NULL)
|
||||
column->avl = obi_open_avl_group(dms, (column->header)->avl_name);
|
||||
if (column->avl == NULL)
|
||||
{
|
||||
obidebug(1, "\nError opening the AVL tree associated with a column");
|
||||
munmap(column->header, header_size);
|
||||
@ -888,7 +888,6 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
|
||||
free(column);
|
||||
return NULL;
|
||||
}
|
||||
//column->avl = avl; TODO
|
||||
}
|
||||
|
||||
close(column_file_descriptor);
|
||||
@ -964,18 +963,13 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms,
|
||||
}
|
||||
else if (clone_data && (line_selection != NULL))
|
||||
{
|
||||
obidebug(1, "\nCloning data from line selection\n");
|
||||
line_size = obi_sizeof((new_column->header)->stored_data_type) * (new_column->header)->nb_elements_per_line;
|
||||
fprintf(stderr, "\nline size = %ld\n", line_size);
|
||||
for (i=0; i<((line_selection->header)->lines_used); i++)
|
||||
{
|
||||
index = *(((index_t*) (line_selection->data)) + i);
|
||||
fprintf(stderr, "\nindex = %lld, i = %lld\n", index, i);
|
||||
memcpy((new_column->data)+(i*line_size), (column_to_clone->data)+(index*line_size), line_size);
|
||||
fprintf(stderr, "\nmemcpied\n");
|
||||
}
|
||||
(new_column->header)->lines_used = (line_selection->header)->lines_used;
|
||||
obidebug(1, "\nCloned data from line selection\n");
|
||||
}
|
||||
|
||||
// Close column_to_clone
|
||||
@ -1022,12 +1016,12 @@ int obi_close_column(OBIDMS_column_p column)
|
||||
}
|
||||
}
|
||||
|
||||
// If the data type is OBI_STR or OBI_SEQ, the associated AVL tree is closed TODO
|
||||
// if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
|
||||
// {
|
||||
// if (obi_close_avl(column->avl) < 0)
|
||||
// return -1;
|
||||
// }
|
||||
// If the data type is OBI_STR or OBI_SEQ, the associated AVL group is closed
|
||||
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
|
||||
{
|
||||
if (obi_close_avl_group(column->avl) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Munmap data
|
||||
if (munmap(column->data, (column->header)->data_size) < 0)
|
||||
@ -1045,10 +1039,10 @@ int obi_close_column(OBIDMS_column_p column)
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(column);
|
||||
|
||||
if (close_dir)
|
||||
obi_close_column_directory(column->column_directory);
|
||||
|
||||
free(column);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user