Commit c225cfd8 authored by Celine Mercier's avatar Celine Mercier

Fixed bug with retrieval of values from AVLs (bad cast in byte array

structure)
parent 966b1325
......@@ -310,7 +310,7 @@ int byte_array_compare(Obi_byte_array_p value_1, Obi_byte_array_p value_2);
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int32_t byte_array_sizeof(Obi_byte_array_p value);
int byte_array_sizeof(Obi_byte_array_p value);
/**
......@@ -1006,7 +1006,6 @@ int byte_array_compare(Obi_byte_array_p value_1, Obi_byte_array_p value_2)
comp = 0;
while (!comp && (b < value_1->length_encoded_value))
{
//fprintf(stderr, "\ncomparing %c and %c", *((value_1->value)+b), *((value_2->value)+b));
comp = *((value_1->value)+b) - *((value_2->value)+b);
b++;
}
......@@ -1014,7 +1013,7 @@ int byte_array_compare(Obi_byte_array_p value_1, Obi_byte_array_p value_2)
}
int32_t byte_array_sizeof(Obi_byte_array_p value)
int byte_array_sizeof(Obi_byte_array_p value)
{
return (sizeof(Obi_byte_array_t) + (value->length_encoded_value));
}
......@@ -1023,7 +1022,7 @@ int32_t byte_array_sizeof(Obi_byte_array_p value)
index_t avl_add_value_in_data_array(OBIDMS_avl_p avl, Obi_byte_array_p value)
{
index_t value_idx;
int32_t value_size;
int value_size;
value_idx = ((avl->data)->header)->data_size_used;
......@@ -2050,8 +2049,7 @@ int obi_close_avl_group(OBIDMS_avl_group_p avl_group)
Obi_byte_array_p obi_avl_get(OBIDMS_avl_p avl, index_t idx)
{
obidebug(1, "\ngetting >%s", ((Obi_byte_array_p)((avl->data)->data)+idx)->value);
return ((Obi_byte_array_p)((avl->data)->data)+idx);
return ((Obi_byte_array_p)(((avl->data)->data)+idx));
}
......@@ -2211,11 +2209,8 @@ index_t obi_avl_find(OBIDMS_avl_p avl, Obi_byte_array_p value)
if (comp == 0)
{ // Check if really same value
//fprintf(stderr, "\ngonna get\n");
to_compare = obi_avl_get(avl, current_node->value);
//fprintf(stderr, "\ngot, gonna compare\n");
comp = byte_array_compare(to_compare, value);
//fprintf(stderr, "\ncompared\n");
}
if (comp > 0)
......@@ -2239,14 +2234,9 @@ Obi_byte_array_p obi_avl_group_get(OBIDMS_avl_group_p avl_group, index_t idx)
int32_t avl_idx;
index_t idx_in_avl;
//fprintf(stderr, "\noriginal index = %lld", idx);
avl_idx = (int32_t) (idx >> 32);
idx_in_avl = idx & 0x00000000FFFFFFFF;
//fprintf(stderr, "\navl index = %d", avl_idx);
//fprintf(stderr, "\nindex in avl = %lld", idx_in_avl);
return obi_avl_get((avl_group->sub_avls)[avl_idx], idx_in_avl);
}
......@@ -2257,13 +2247,9 @@ index_t obi_avl_group_add(OBIDMS_avl_group_p avl_group, Obi_byte_array_p value)
index_t index_with_avl;
int i;
//fprintf(stderr, "\nAdding %s", value->value);
if (maybe_in_avl((avl_group->sub_avls)[avl_group->current_avl_idx], value))
{
//fprintf(stderr, "\nmaybe in current AVL");
index_in_avl = (int32_t) obi_avl_find((avl_group->sub_avls)[avl_group->current_avl_idx], value);
//fprintf(stderr, "\nfind went fine\n");
if (index_in_avl >= 0)
{
index_with_avl = avl_group->current_avl_idx;
......@@ -2276,7 +2262,6 @@ index_t obi_avl_group_add(OBIDMS_avl_group_p avl_group, Obi_byte_array_p value)
{
if (maybe_in_avl((avl_group->sub_avls)[i], value))
{
//fprintf(stderr, "\nmaybe in AVL %d", i);
if (remap_an_avl((avl_group->sub_avls)[i]) < 0)
return -1;
index_in_avl = (int32_t) obi_avl_find((avl_group->sub_avls)[i], value);
......@@ -2300,8 +2285,6 @@ index_t obi_avl_group_add(OBIDMS_avl_group_p avl_group, Obi_byte_array_p value)
return -1;
}
//fprintf(stderr, "\nAdding in current AVL");
// Add in the current AVL
bloom_add(&((((avl_group->sub_avls)[avl_group->current_avl_idx])->header)->bloom_filter), value, byte_array_sizeof(value));
index_in_avl = (int32_t) obi_avl_add((avl_group->sub_avls)[avl_group->current_avl_idx], value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment