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:
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)
|
||||
|
Reference in New Issue
Block a user