The default name of an AVL is now the column name + '_indexer', and when
an AVL is opened (as opposed to created), it is read-only
This commit is contained in:
@ -352,7 +352,7 @@ cdef class OBIView :
|
||||
index_t nb_lines=0,
|
||||
index_t nb_elements_per_line=1, # TODO 1?
|
||||
list elements_names=None,
|
||||
str indexer_name="default_indexer",
|
||||
str indexer_name="",
|
||||
str comments="",
|
||||
bint create=True # TODO
|
||||
) :
|
||||
|
29
src/obiavl.c
29
src/obiavl.c
@ -1672,7 +1672,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
|
||||
return NULL;
|
||||
|
||||
// Open file
|
||||
avl_data_file_descriptor = openat(avl_dir_file_descriptor, avl_data_file_name, O_RDWR, 0777);
|
||||
avl_data_file_descriptor = openat(avl_dir_file_descriptor, avl_data_file_name, O_RDONLY, 0777);
|
||||
if (avl_data_file_descriptor < 0)
|
||||
{
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
@ -1710,7 +1710,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
|
||||
// Fill the avl data structure
|
||||
avl_data->header = mmap(NULL,
|
||||
header_size,
|
||||
PROT_READ | PROT_WRITE,
|
||||
PROT_READ,
|
||||
MAP_SHARED,
|
||||
avl_data_file_descriptor,
|
||||
0
|
||||
@ -1728,7 +1728,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
|
||||
|
||||
avl_data->data = mmap(NULL,
|
||||
(avl_data->header)->data_size_max,
|
||||
PROT_READ | PROT_WRITE,
|
||||
PROT_READ,
|
||||
MAP_SHARED,
|
||||
avl_data_file_descriptor,
|
||||
header_size
|
||||
@ -1759,7 +1759,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
|
||||
}
|
||||
|
||||
// Open file
|
||||
avl_file_descriptor = openat(avl_dir_file_descriptor, avl_file_name, O_RDWR, 0777);
|
||||
avl_file_descriptor = openat(avl_dir_file_descriptor, avl_file_name, O_RDONLY, 0777);
|
||||
if (avl_file_descriptor < 0)
|
||||
{
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
@ -1799,7 +1799,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
|
||||
// Fill the avl structure
|
||||
avl->header = mmap(NULL,
|
||||
header_size,
|
||||
PROT_READ | PROT_WRITE,
|
||||
PROT_READ,
|
||||
MAP_SHARED,
|
||||
avl_file_descriptor,
|
||||
0
|
||||
@ -1818,7 +1818,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
|
||||
|
||||
avl->tree = mmap(NULL,
|
||||
(((avl->header)->nb_items_max) * sizeof(AVL_node_t)),
|
||||
PROT_READ | PROT_WRITE,
|
||||
PROT_READ,
|
||||
MAP_SHARED,
|
||||
avl_file_descriptor,
|
||||
header_size
|
||||
@ -1899,6 +1899,9 @@ OBIDMS_avl_group_p obi_create_avl_group(OBIDMS_p dms, const char* avl_name)
|
||||
// Set counter to 1
|
||||
avl_group->counter = 1;
|
||||
|
||||
// Set as writable
|
||||
avl_group->writable = true;
|
||||
|
||||
return avl_group;
|
||||
}
|
||||
|
||||
@ -1956,6 +1959,9 @@ OBIDMS_avl_group_p obi_open_avl_group(OBIDMS_p dms, const char* avl_name)
|
||||
// Set counter to 1
|
||||
avl_group->counter = 1;
|
||||
|
||||
// Set as read-only
|
||||
avl_group->writable = false;
|
||||
|
||||
return avl_group;
|
||||
}
|
||||
|
||||
@ -2247,7 +2253,16 @@ index_t obi_avl_group_add(OBIDMS_avl_group_p avl_group, Obi_blob_p value)
|
||||
}
|
||||
|
||||
// Not found in any AVL: add in current
|
||||
// First, check if make new AVL
|
||||
|
||||
// Check if the AVL group is writable
|
||||
if (!(avl_group->writable))
|
||||
{
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
obidebug(1, "\nTrying to add a value in an AVL group that is read-only.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check if need to make new AVL
|
||||
if (((((avl_group->sub_avls)[avl_group->current_avl_idx])->header)->nb_items == MAX_NODE_COUNT_PER_AVL) || (((((avl_group->sub_avls)[avl_group->current_avl_idx])->data)->header)->data_size_used >= MAX_DATA_SIZE_PER_AVL))
|
||||
{
|
||||
if (add_new_avl_in_group(avl_group) < 0)
|
||||
|
@ -167,6 +167,8 @@ typedef struct OBIDMS_avl_group {
|
||||
*/
|
||||
OBIDMS_p dms; /**< Pointer to the OBIDMS structure to which the AVL group belongs.
|
||||
*/
|
||||
bool writable; /**< Indicates whether the AVL group is read-only or not.
|
||||
*/
|
||||
size_t counter; /**< Indicates by how many threads/programs (TODO) the AVL group is used.
|
||||
*/
|
||||
} OBIDMS_avl_group_t, *OBIDMS_avl_group_p;
|
||||
|
@ -535,6 +535,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
|
||||
index_t minimum_line_count;
|
||||
OBIType_t returned_data_type;
|
||||
OBIType_t stored_data_type;
|
||||
char final_indexer_name[INDEXER_MAX_NAME];
|
||||
|
||||
new_column = NULL;
|
||||
|
||||
@ -554,11 +555,13 @@ 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)) && (indexer_name == NULL))
|
||||
{
|
||||
obidebug(1, "\nCan't create column because of empty indexer name");
|
||||
return NULL;
|
||||
if (((data_type == OBI_STR) || (data_type == OBI_SEQ)) && (strcmp(indexer_name, "") == 0))
|
||||
{ // TODO make function in obiblob_indexer.c and discuss the fact that it's here
|
||||
strcpy(final_indexer_name, column_name);
|
||||
strcat(final_indexer_name, "_indexer");
|
||||
}
|
||||
else
|
||||
strcpy(final_indexer_name, indexer_name);
|
||||
|
||||
returned_data_type = data_type;
|
||||
if ((data_type == OBI_STR) || (data_type == OBI_SEQ))
|
||||
@ -727,7 +730,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
|
||||
// If the data type is OBI_STR or OBI_SEQ, the associated obi_indexer is opened or created
|
||||
if ((returned_data_type == OBI_STR) || (returned_data_type == OBI_SEQ))
|
||||
{
|
||||
new_column->indexer = obi_indexer(dms, indexer_name);
|
||||
new_column->indexer = obi_indexer(dms, final_indexer_name);
|
||||
if (new_column->indexer == NULL)
|
||||
{
|
||||
obidebug(1, "\nError opening or creating the indexer associated with a column");
|
||||
@ -736,7 +739,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
|
||||
free(new_column);
|
||||
return NULL;
|
||||
}
|
||||
strncpy(header->indexer_name, indexer_name, INDEXER_MAX_NAME);
|
||||
strncpy(header->indexer_name, final_indexer_name, INDEXER_MAX_NAME);
|
||||
}
|
||||
|
||||
// Fill the data with NA values
|
||||
|
Reference in New Issue
Block a user