Moved some blob functions to obiblob.c
This commit is contained in:
79
src/obiavl.c
79
src/obiavl.c
@ -108,7 +108,8 @@ static char* build_avl_data_file_name(const char* avl_name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Internal function returning the size of an AVL tree header on this platform.
|
||||
* @brief Internal function returning the size of an AVL tree header on this platform,
|
||||
* including the size of the bloom filter associated with the AVL tree.
|
||||
*
|
||||
* @returns The size of an AVL tree header in bytes.
|
||||
*
|
||||
@ -282,38 +283,6 @@ int add_new_avl_in_group(OBIDMS_avl_group_p avl_group);
|
||||
int maybe_in_avl(OBIDMS_avl_p avl, Obi_blob_p value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Internal function comparing two blobs.
|
||||
*
|
||||
* The encoding is compared first, then the length of the
|
||||
* values, then the values themselves.
|
||||
*
|
||||
* @param value_1 A pointer to the first blob structure.
|
||||
* @param value_2 A pointer to the second blob structure.
|
||||
*
|
||||
* @returns A value < 0 if value_1 < value_2,
|
||||
* a value > 0 if value_1 > value_2,
|
||||
* and 0 if value_1 == value_2.
|
||||
*
|
||||
* @since October 2015
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
int blob_compare(Obi_blob_p value_1, Obi_blob_p value_2);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Internal function calculating the size in bytes of a blob.
|
||||
*
|
||||
* @param value A pointer to the blob structure.
|
||||
*
|
||||
* @returns The size of the blob in bytes.
|
||||
*
|
||||
* @since October 2015
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
int blob_sizeof(Obi_blob_p value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Internal function storing a value (blob) in the data array referred to by an AVL tree.
|
||||
*
|
||||
@ -586,7 +555,7 @@ size_t get_avl_header_size()
|
||||
|
||||
header_size = sizeof(OBIDMS_avl_header_t) + bloom_filter_size(MAX_NODE_COUNT_PER_AVL, BLOOM_FILTER_ERROR_RATE);
|
||||
|
||||
multiple = ceil((double) header_size / (double) getpagesize());
|
||||
multiple = ceil((double) header_size / (double) getpagesize());
|
||||
|
||||
rounded_header_size = multiple * getpagesize();
|
||||
|
||||
@ -986,40 +955,6 @@ int maybe_in_avl(OBIDMS_avl_p avl, Obi_blob_p value)
|
||||
}
|
||||
|
||||
|
||||
int blob_compare(Obi_blob_p value_1, Obi_blob_p value_2)
|
||||
{
|
||||
int comp;
|
||||
int32_t b;
|
||||
|
||||
if (value_1->element_size != value_2->element_size)
|
||||
return (value_1->element_size - value_2->element_size);
|
||||
|
||||
if (value_1->length_encoded_value != value_2->length_encoded_value)
|
||||
return (value_1->length_encoded_value - value_2->length_encoded_value);
|
||||
|
||||
if (value_1->element_size != ELEMENT_SIZE_STR) // because if so, length_decoded_value == length_encoded_value
|
||||
{
|
||||
if (value_1->length_decoded_value != value_2->length_decoded_value)
|
||||
return (value_1->length_decoded_value - value_2->length_decoded_value);
|
||||
}
|
||||
|
||||
b = 0;
|
||||
comp = 0;
|
||||
while (!comp && (b < value_1->length_encoded_value))
|
||||
{
|
||||
comp = *((value_1->value)+b) - *((value_2->value)+b);
|
||||
b++;
|
||||
}
|
||||
return comp;
|
||||
}
|
||||
|
||||
|
||||
int blob_sizeof(Obi_blob_p value)
|
||||
{
|
||||
return (sizeof(Obi_blob_t) + (value->length_encoded_value));
|
||||
}
|
||||
|
||||
|
||||
index_t avl_add_value_in_data_array(OBIDMS_avl_p avl, Obi_blob_p value)
|
||||
{
|
||||
index_t value_idx;
|
||||
@ -1067,7 +1002,7 @@ AVL_node_p avl_create_node(OBIDMS_avl_p avl, index_t node_idx)
|
||||
// Update the balance factors of the nodes from the node that will need balancing
|
||||
void avl_update_balance_factors(OBIDMS_avl_p avl)
|
||||
{
|
||||
uint8_t n;
|
||||
uint8_t n;
|
||||
AVL_node_p node;
|
||||
|
||||
// Update balance factors from the node where balancing might be needed
|
||||
@ -1221,8 +1156,8 @@ index_t avl_balance_node(OBIDMS_avl_p avl, AVL_node_p node, index_t node_idx)
|
||||
// Balance a given tree
|
||||
void avl_balance(OBIDMS_avl_p avl)
|
||||
{
|
||||
index_t new_root;
|
||||
index_t node_index;
|
||||
index_t new_root;
|
||||
index_t node_index;
|
||||
AVL_node_p node_to_balance;
|
||||
AVL_node_p parent_of_node_to_balance;
|
||||
|
||||
@ -1968,7 +1903,7 @@ 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;
|
||||
int ret_val = 0;
|
||||
|
||||
ret_val = close_avl_data(avl->data);
|
||||
|
||||
|
Reference in New Issue
Block a user