DNA sequences and character strings are now handled using AVL trees.

This commit is contained in:
Celine Mercier
2015-12-11 17:24:44 +01:00
parent 1586956d57
commit c139367555
26 changed files with 2178 additions and 1711 deletions

View File

@ -12,7 +12,7 @@
../../../src/obitypes.c ../../../src/obitypes.c
../../../src/private_at_functions.h ../../../src/private_at_functions.h
../../../src/private_at_functions.c ../../../src/private_at_functions.c
../../../src/obiarray.h ../../../src/obiavl.h
../../../src/obiarray.c ../../../src/obiavl.c
../../../src/encode.h ../../../src/encode.h
../../../src/encode.c ../../../src/encode.c

View File

@ -25,7 +25,7 @@ cdef class OBIDMS:
index_t nb_lines=*, index_t nb_lines=*,
index_t nb_elements_per_line=*, index_t nb_elements_per_line=*,
list elements_names=*, list elements_names=*,
str array_name=*, str avl_name=*,
str comments=*) str comments=*)

View File

@ -133,7 +133,7 @@ cdef class OBIDMS :
index_t nb_lines=0, index_t nb_lines=0,
index_t nb_elements_per_line=0, index_t nb_elements_per_line=0,
list elements_names=None, list elements_names=None,
str array_name="default_obiarray", str avl_name="default_AVL_tree",
str comments=""): str comments=""):
# Declarations # Declarations
@ -263,7 +263,7 @@ cdef class OBIDMS :
referring, referring,
version_number, data_type, version_number, data_type,
nb_lines, nb_elements_per_line, nb_lines, nb_elements_per_line,
elements_names, array_name, elements_names, avl_name,
comments) comments)
return column return column
@ -284,13 +284,13 @@ cdef class OBIDMS_column :
index_t nb_lines, index_t nb_lines,
index_t nb_elements_per_line, index_t nb_elements_per_line,
list elements_names, list elements_names,
str array_name, str avl_name,
str comments): str comments):
# Declarations # Declarations
cdef bytes column_name_b cdef bytes column_name_b
cdef bytes dms_name_b cdef bytes dms_name_b
cdef bytes array_name_b cdef bytes avl_name_b
cdef bytes elements_names_b cdef bytes elements_names_b
cdef bytes comments_b cdef bytes comments_b
@ -304,7 +304,7 @@ cdef class OBIDMS_column :
# Format the character strings to send them to C functions # Format the character strings to send them to C functions
column_name_b = str2bytes(column_name) column_name_b = str2bytes(column_name)
dms_name_b = str2bytes(self.dms.dms_name) dms_name_b = str2bytes(self.dms.dms_name)
array_name_b = str2bytes(array_name) avl_name_b = str2bytes(avl_name)
comments_b = str2bytes(comments) comments_b = str2bytes(comments)
# Create, clone or open column # Create, clone or open column
@ -315,7 +315,7 @@ cdef class OBIDMS_column :
elements_names_b = str2bytes(";".join(elements_names)) elements_names_b = str2bytes(";".join(elements_names))
self.pointer = obi_create_column(self.dms.pointer, column_name_b, type, self.pointer = obi_create_column(self.dms.pointer, column_name_b, type,
nb_lines, nb_elements_per_line, nb_lines, nb_elements_per_line,
elements_names_b, array_name_b, comments_b, elements_names_b, avl_name_b, comments_b,
referring) referring)
else : else :
if clone : if clone :

View File

@ -14,5 +14,5 @@
../../../src/obitypes.c ../../../src/obitypes.c
../../../src/private_at_functions.h ../../../src/private_at_functions.h
../../../src/private_at_functions.c ../../../src/private_at_functions.c
../../../src/obiarray.h ../../../src/obiavl.h
../../../src/obiarray.c ../../../src/obiavl.c

View File

@ -14,5 +14,5 @@
../../../src/obitypes.c ../../../src/obitypes.c
../../../src/private_at_functions.h ../../../src/private_at_functions.h
../../../src/private_at_functions.c ../../../src/private_at_functions.c
../../../src/obiarray.h ../../../src/obiavl.h
../../../src/obiarray.c ../../../src/obiavl.c

View File

@ -14,5 +14,5 @@
../../../src/obitypes.c ../../../src/obitypes.c
../../../src/private_at_functions.h ../../../src/private_at_functions.h
../../../src/private_at_functions.c ../../../src/private_at_functions.c
../../../src/obiarray.h ../../../src/obiavl.h
../../../src/obiarray.c ../../../src/obiavl.c

View File

@ -14,5 +14,5 @@
../../../src/obitypes.c ../../../src/obitypes.c
../../../src/private_at_functions.h ../../../src/private_at_functions.h
../../../src/private_at_functions.c ../../../src/private_at_functions.c
../../../src/obiarray.h ../../../src/obiavl.h
../../../src/obiarray.c ../../../src/obiavl.c

View File

@ -14,5 +14,5 @@
../../../src/obitypes.c ../../../src/obitypes.c
../../../src/private_at_functions.h ../../../src/private_at_functions.h
../../../src/private_at_functions.c ../../../src/private_at_functions.c
../../../src/obiarray.h ../../../src/obiavl.h
../../../src/obiarray.c ../../../src/obiavl.c

View File

@ -14,5 +14,5 @@
../../../src/obitypes.c ../../../src/obitypes.c
../../../src/private_at_functions.h ../../../src/private_at_functions.h
../../../src/private_at_functions.c ../../../src/private_at_functions.c
../../../src/obiarray.h ../../../src/obiavl.h
../../../src/obiarray.c ../../../src/obiavl.c

View File

@ -30,7 +30,7 @@ cdef extern from "obidmscolumn.h" nogil:
bint referring bint referring
obiversion_t referred_column_version obiversion_t referred_column_version
const_char_p name const_char_p name
const_char_p array_name const_char_p avl_name
const_char_p comments const_char_p comments
ctypedef OBIDMS_column_header_t* OBIDMS_column_header_p ctypedef OBIDMS_column_header_t* OBIDMS_column_header_p
@ -47,7 +47,7 @@ cdef extern from "obidmscolumn.h" nogil:
index_t nb_lines, index_t nb_lines,
index_t nb_elements_per_line, index_t nb_elements_per_line,
const_char_p elements_names, const_char_p elements_names,
const_char_p array_name, const_char_p avl_name,
const_char_p comments, const_char_p comments,
bint referring) bint referring)

View File

@ -16,7 +16,8 @@
#include <math.h> #include <math.h>
#include "encode.h" #include "encode.h"
#include "obiarray.h" #include "obierrno.h"
#include "obitypes.h" // For byte_t type
#include "obidebug.h" #include "obidebug.h"

View File

@ -15,7 +15,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "obiarray.h" #include "obitypes.h"
#define NUC_MASK_2B 0x3 /**< Binary: 11 to use when decoding 2 bits sequences */ #define NUC_MASK_2B 0x3 /**< Binary: 11 to use when decoding 2 bits sequences */

File diff suppressed because it is too large Load Diff

View File

@ -1,322 +0,0 @@
/****************************************************************************
* OBIDMS array header file *
****************************************************************************/
/**
* @file obiarray.h
* @author Celine Mercier
* @date October 19th 2015
* @brief Header file for handling arrays for storing and retrieving byte arrays (i.e. coding for character strings).
*/
#ifndef OBIARRAY_H_
#define OBIARRAY_H_
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <sys/types.h>
#include <dirent.h>
#include "obidms.h"
#include "obitypes.h"
#define ARRAY_MAX_NAME (1024) /**< The maximum length of an array name.
*/
#define ARRAY_GROWTH_FACTOR (2) /**< The growth factor when an array is enlarged.
*/
#define BYTE_ARRAY_HEADER_SIZE (9) /**< The size of the header of a byte array.
*/
typedef char byte_t; /**< Defining byte type since data is stored in bits
* and char (stored on one byte) is the smallest addressable unit.
*/
/**
* @brief OBIDMS array data header structure.
*/
typedef struct OBIDMS_array_data_header {
int header_size; /**< Size of the header in bytes.
*/
index_t data_size_used; /**< Size of the data used in bytes.
*/
index_t data_size_max; /**< Max size of the data in bytes.
*/
index_t nb_items; /**< Number of items.
*/
char array_name[ARRAY_MAX_NAME+1]; /**< The array name as a NULL terminated string.
*/
time_t creation_date; /**< Date of creation of the file.
*/
} OBIDMS_array_data_header_t, *OBIDMS_array_data_header_p;
/**
* @brief OBIDMS array data structure.
*/
typedef struct OBIDMS_array_data {
OBIDMS_array_data_header_p header; /**< A pointer to the header of the array data.
*/
byte_t* data; /**< A pointer to the beginning of the data.
*/
} OBIDMS_array_data_t, *OBIDMS_array_data_p;
/**
* @brief OBIDMS array header structure.
*/
typedef struct OBIDMS_array_header {
int header_size; /**< Size of the header in bytes.
*/
size_t array_size; /**< Size of the array in bytes.
*/
index_t nb_items; /**< Number of items in the array.
*/
index_t nb_items_max; /**< Maximum number of items in the array before it has to be enlarged.
*/
char array_name[ARRAY_MAX_NAME+1]; /**< The array name as a NULL terminated string.
*/
time_t creation_date; /**< Date of creation of the file.
*/
} OBIDMS_array_header_t, *OBIDMS_array_header_p;
/**
* @brief OBIDMS array structure.
*/
typedef struct OBIDMS_array {
OBIDMS_p dms; /**< A pointer to the OBIDMS structure to which the array belongs.
*/
OBIDMS_array_header_p header; /**< A pointer to the header of the array.
*/
index_t* first; /**< A pointer to the beginning of the array itself.
*/
OBIDMS_array_data_p data; /**< A pointer to the structure containing the data
* that the array references.
*/
DIR* directory; /**< A directory entry usable to
* refer and scan the array directory.
*/
int dir_fd; /**< The file descriptor of the directory entry
* usable to refer and scan the array directory.
*/
size_t counter; /**< Indicates by how many threads/programs (TODO) the array is used.
*/
} OBIDMS_array_t, *OBIDMS_array_p;
/**
* @brief Checks if an obiarray already exists or not.
*
* @param dms The OBIDMS to which the obiarray belongs.
* @param array_name The name of the obiarray.
*
* @returns A value indicating whether the obiarray exists or not.
* @retval 1 if the obiarray exists.
* @retval 0 if the obiarray does not exist.
* @retval -1 if an error occurred.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int obi_array_exists(OBIDMS_p dms, const char* array_name);
/**
* @brief Opens an obiarray and creates it if it does not already exist.
*
* Note: An obiarray is made of two files (referred to by two structures).
* One file contains the indices referring to the data, and the other
* file contains the data itself. The obiarray as a whole is referred
* to via the OBIDMS_array structure.
*
* @param dms The OBIDMS to which the obiarray belongs.
* @param array_name The name of the obiarray.
*
* @returns A pointer to the obiarray structure.
* @retval NULL if an error occurred.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
OBIDMS_array_p obi_array(OBIDMS_p dms, const char* array_name);
/**
* @brief Creates an obiarray. Fails if it already exists.
*
* Note: An obiarray is made of two files (referred to by two structures).
* One file contains the indices referring to the data, and the other
* file contains the data itself. The obiarray as a whole is referred
* to via the OBIDMS_array structure.
*
* @param dms The OBIDMS to which the obiarray belongs.
* @param array_name The name of the obiarray.
*
* @returns A pointer to the newly created obiarray structure.
* @retval NULL if an error occurred.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
OBIDMS_array_p obi_create_array(OBIDMS_p dms, const char* array_name);
/**
* @brief Opens an obiarray. Fails if it does not already exist.
*
* Note: An obiarray is made of two files (referred to by two structures).
* One file contains the indices referring to the data, and the other
* file contains the data itself. The obiarray as a whole is referred
* to via the OBIDMS_array structure.
*
* @param dms The OBIDMS to which the obiarray belongs.
* @param array_name The name of the obiarray.
*
* @returns A pointer to the obiarray structure.
* @retval NULL if an error occurred.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
OBIDMS_array_p obi_open_array(OBIDMS_p dms, const char* array_name);
/**
* @brief Closes an obiarray.
*
* Note: An obiarray is made of two files (referred to by two structures).
* One file contains the indices referring to the data, and the other
* file contains the data itself. The obiarray as a whole is referred
* to via the OBIDMS_array structure.
*
* @param array A pointer to the obiarray structure to close and free.
*
* @retval 0 if the operation was successfully completed.
* @retval -1 if an error occurred.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int obi_close_array(OBIDMS_array_p array);
/**
* @brief Adds a value (byte array) in an obiarray, checking first if it is already in it.
*
* @warning The byte array to add must already be encoded and contain its header.
*
* @param array A pointer to the obiarray.
* @param value The byte array to add in the obiarray.
*
* @returns The index of the value, whether it was added or already in the obiarray.
* @retval -1 if an error occurred.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
index_t obi_array_add(OBIDMS_array_p array, byte_t* value);
/**
* @brief Recovers a value (byte array) in an obiarray.
*
* @warning The byte array recovered is encoded and contains its header.
*
* @param array A pointer to the obiarray.
* @param index The index of the value in the data array.
*
* @returns A pointer to the byte array recovered.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
byte_t* obi_array_get(OBIDMS_array_p array, index_t index);
/**
* @brief Searches a value (byte array) in an obiarray performing a binary search.
*
* @warning The byte array to search must already be encoded and contain its header.
*
* @param array A pointer to the obiarray.
* @param value The byte array to add in the obiarray.
*
* @returns If the value is found, its data index is returned.
* If the value is not found, the array index indicating where the value's data index
* should be in the array is returned in the form (- (index + 1)), as data indices in an
* obiarray are sorted according to the ascending order of the values (byte arrays) themselves.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
index_t obi_array_search(OBIDMS_array_p array, byte_t* value);
/**
* @brief Converts a character string to a byte array with a header.
*
* @warning The byte array must be freed by the caller.
*
* @param value The character string to convert.
*
* @returns A pointer to the byte array created.
* @retval NULL if an error occurred.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
byte_t* obi_str_to_obibytes(char* value);
/**
* @brief Converts a byte array to a character string.
*
* @param value_b The byte array to convert.
*
* @returns A pointer to the character string contained in the byte array.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
const char* obi_obibytes_to_str(byte_t* value_b);
/**
* @brief Converts a DNA sequence to a byte array with a header.
*
* @warning The byte array must be freed by the caller.
*
* @param value The DNA sequence to convert.
*
* @returns A pointer to the byte array created.
* @retval NULL if an error occurred.
*
* @since November 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
byte_t* obi_seq_to_obibytes(char* seq);
/**
* @brief Converts a byte array to a DNA sequence.
*
* @param value_b The byte array to convert.
*
* @returns A pointer to the DNA sequence contained in the byte array.
* @retval NULL if an error occurred.
*
* @since November 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
const char* obi_obibytes_to_seq(byte_t* value_b);
#endif /* OBIARRAY_H_ */

1717
src/obiavl.c Normal file

File diff suppressed because it is too large Load Diff

344
src/obiavl.h Normal file
View File

@ -0,0 +1,344 @@
/****************************************************************************
* OBIDMS AVL tree header file *
****************************************************************************/
/**
* @file obiavl.h
* @author Celine Mercier
* @date December 3rd 2015
* @brief Header file for handling AVL trees for storing and retrieving byte arrays (i.e. coding for character strings).
*/
#ifndef OBIAVL_H_
#define OBIAVL_H_
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdbool.h>
#include "obidms.h"
#include "obitypes.h"
#define AVL_MAX_NAME (1024) /**< The maximum length of an AVL tree name.
*/
#define AVL_GROWTH_FACTOR (2) /**< The growth factor when an AVL tree is enlarged.
*/
#define AVL_MAX_DEPTH (50) /**< The maximum depth of an AVL tree.
*/
#define LEFT_CHILD(node) (avl->tree)+(node->left_child) /**< Pointer to the left child of a node in an AVL tree.
*/
#define RIGHT_CHILD(node) (avl->tree)+(node->right_child) /**< Pointer to the right child of a node in an AVL tree.
*/
#define BYTE_ARRAY_HEADER_SIZE (9) /**< The size of the header of a byte array.
*/
/**
* @brief AVL tree node structure.
*/
typedef struct AVL_node {
index_t left_child; /**< Index of left less child node.
*/
index_t right_child; /**< Index of right greater child node.
*/
int8_t balance_factor; /**< Balance factor of the node.
*/
index_t value; /**< Index of the value associated with the node in the data array.
*/
} AVL_node_t, *AVL_node_p;
/**
* @brief OBIDMS AVL tree data header structure.
*/
typedef struct OBIDMS_avl_data_header {
int header_size; /**< Size of the header in bytes.
*/
index_t data_size_used; /**< Size of the data used in bytes.
*/
index_t data_size_max; /**< Max size of the data in bytes.
*/
index_t nb_items; /**< Number of items.
*/
char avl_name[AVL_MAX_NAME+1]; /**< The AVL tree name as a NULL terminated string.
*/
time_t creation_date; /**< Date of creation of the file.
*/
} OBIDMS_avl_data_header_t, *OBIDMS_avl_data_header_p;
/**
* @brief OBIDMS AVL tree data structure.
*/
typedef struct OBIDMS_avl_data {
OBIDMS_avl_data_header_p header; /**< A pointer to the header of the AVL tree data.
*/
byte_t* data; /**< A pointer to the beginning of the data.
*/
} OBIDMS_avl_data_t, *OBIDMS_avl_data_p;
/**
* @brief OBIDMS AVL tree header structure.
*/
typedef struct OBIDMS_avl_header {
int header_size; /**< Size of the header in bytes.
*/
size_t avl_size; /**< Size of the AVL tree in bytes.
*/
index_t nb_items; /**< Number of items in the AVL tree.
*/
index_t nb_items_max; /**< Maximum number of items in the AVL tree before it has to be enlarged.
*/
index_t root_idx; /**< Index of the root of the AVL tree.
*/
char avl_name[AVL_MAX_NAME+1]; /**< The AVL tree name as a NULL terminated string.
*/
time_t creation_date; /**< Date of creation of the file.
*/
} OBIDMS_avl_header_t, *OBIDMS_avl_header_p;
/**
* @brief OBIDMS AVL tree structure.
*/
typedef struct OBIDMS_avl {
OBIDMS_p dms; /**< A pointer to the OBIDMS structure to which the AVL tree belongs.
*/
OBIDMS_avl_header_p header; /**< A pointer to the header of the AVL tree.
*/
struct AVL_node* tree; /**< A pointer to the root of the AVL tree.
*/
index_t path_idx[AVL_MAX_DEPTH]; /**< The path taken to a node from the root as an array of node indices.
*/
int8_t path_dir[AVL_MAX_DEPTH]; /**< The path taken to a node from the root as an array of directions
* (0 for left, -1 for right).
*/
OBIDMS_avl_data_p data; /**< A pointer to the structure containing the data
* that the AVL tree references.
*/
DIR* directory; /**< A directory entry usable to
* refer and scan the AVL tree directory.
*/
int dir_fd; /**< The file descriptor of the directory entry
* usable to refer and scan the AVL tree directory.
*/
size_t counter; /**< Indicates by how many threads/programs (TODO) the AVL tree is used.
*/
} OBIDMS_avl_t, *OBIDMS_avl_p;
/**
* @brief Checks if an AVL tree already exists or not.
*
* @param dms The OBIDMS to which the AVL tree belongs.
* @param avl_name The name of the AVL tree.
*
* @returns A value indicating whether the AVL tree exists or not.
* @retval 1 if the AVL tree exists.
* @retval 0 if the AVL tree does not exist.
* @retval -1 if an error occurred.
*
* @since December 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int obi_avl_exists(OBIDMS_p dms, const char* avl_name);
/**
* @brief Opens an AVL tree and creates it if it does not already exist.
*
* Note: An AVL tree is made of two files (referred to by two structures).
* One file contains the indices referring to the data, and the other
* file contains the data itself. The AVL tree as a whole is referred
* to via the OBIDMS_avl structure.
*
* @param dms The OBIDMS to which the AVL tree belongs.
* @param avl_name The name of the AVL tree.
*
* @returns A pointer to the AVL tree structure.
* @retval NULL if an error occurred.
*
* @since December 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
OBIDMS_avl_p obi_avl(OBIDMS_p dms, const char* avl_name);
/**
* @brief Creates an AVL tree. Fails if it already exists.
*
* Note: An AVL tree is made of two files (referred to by two structures).
* One file contains the indices referring to the data, and the other
* file contains the data itself. The AVL tree as a whole is referred
* to via the OBIDMS_avl structure.
*
* @param dms The OBIDMS to which the AVL tree belongs.
* @param avl_name The name of the AVL tree.
*
* @returns A pointer to the newly created AVL tree structure.
* @retval NULL if an error occurred.
*
* @since December 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name);
/**
* @brief Opens an AVL tree. Fails if it does not already exist.
*
* Note: An AVL tree is made of two files (referred to by two structures).
* One file contains the indices referring to the data, and the other
* file contains the data itself. The AVL tree as a whole is referred
* to via the OBIDMS_avl structure.
*
* @param dms The OBIDMS to which the AVL tree belongs.
* @param avl_name The name of the AVL tree.
*
* @returns A pointer to the AVL tree structure.
* @retval NULL if an error occurred.
*
* @since December 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name);
/**
* @brief Closes an AVL tree.
*
* Note: An AVL tree is made of two files (referred to by two structures).
* One file contains the indices referring to the data, and the other
* file contains the data itself. The AVL tree as a whole is referred
* to via the OBIDMS_avl structure.
*
* @param avl A pointer to the AVL tree structure to close and free.
*
* @retval 0 if the operation was successfully completed.
* @retval -1 if an error occurred.
*
* @since December 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int obi_close_avl(OBIDMS_avl_p avl);
/**
* @brief Adds a value (byte array) in an AVL tree, checking if it is already in it.
*
* @warning The byte array to add must already be encoded and contain its header.
*
* @param avl A pointer to the AVL tree.
* @param value The byte array to add in the AVL tree.
*
* @returns The index of the value, whether it was added or already in the AVL tree.
* @retval -1 if an error occurred.
*
* @since December 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
index_t obi_avl_add(OBIDMS_avl_p avl, byte_t* value);
/**
* @brief Finds a value (byte array) in an AVL tree, checking first if it is already in it.
*
* @warning The byte array to add must already be encoded and contain its header.
*
* @param avl A pointer to the AVL tree.
* @param value The byte array to add in the AVL tree.
*
* @returns The data index of the value.
* @retval -1 if the value is not in the tree.
*
* @since December 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
index_t obi_avl_find(OBIDMS_avl_p avl, byte_t* value);
/**
* @brief Recovers a value (byte array) in an AVL tree.
*
* @warning The byte array recovered is encoded and contains its header.
*
* @param avl A pointer to the AVL tree.
* @param index The index of the value in the data array.
*
* @returns A pointer to the byte array recovered.
*
* @since December 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
byte_t* obi_avl_get(OBIDMS_avl_p avl, index_t index);
/**
* @brief Converts a character string to a byte array with a header.
*
* @warning The byte array must be freed by the caller.
*
* @param value The character string to convert.
*
* @returns A pointer to the byte array created.
* @retval NULL if an error occurred.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
byte_t* obi_str_to_obibytes(char* value);
/**
* @brief Converts a byte array to a character string.
*
* @param value_b The byte array to convert.
*
* @returns A pointer to the character string contained in the byte array.
*
* @since October 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
const char* obi_obibytes_to_str(byte_t* value_b);
/**
* @brief Converts a DNA sequence to a byte array with a header.
*
* @warning The byte array must be freed by the caller.
*
* @param value The DNA sequence to convert.
*
* @returns A pointer to the byte array created.
* @retval NULL if an error occurred.
*
* @since November 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
byte_t* obi_seq_to_obibytes(char* seq);
/**
* @brief Converts a byte array to a DNA sequence.
*
* @param value_b The byte array to convert.
*
* @returns A pointer to the DNA sequence contained in the byte array.
* @retval NULL if an error occurred.
*
* @since November 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
const char* obi_obibytes_to_seq(byte_t* value_b);
#endif /* OBIAVL_H_ */

View File

@ -247,7 +247,7 @@ OBIDMS_p obi_create_dms(const char* dms_name)
return NULL; return NULL;
} }
// Get file descriptor of DMS directory to create the arrays directory // Get file descriptor of DMS directory to create the AVL trees directory
dms_dir = opendir(directory_name); dms_dir = opendir(directory_name);
if (dms_dir == NULL) if (dms_dir == NULL)
{ {
@ -267,11 +267,11 @@ OBIDMS_p obi_create_dms(const char* dms_name)
return NULL; return NULL;
} }
// Create the arrays directory // Create the AVL trees directory
if (mkdirat(dms_file_descriptor, ARRAYS_DIR_NAME, 00777) < 0) if (mkdirat(dms_file_descriptor, AVL_TREES_DIR_NAME, 00777) < 0)
{ {
obi_set_errno(OBI_ARRAY_ERROR); obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nProblem creating an arrays directory"); obidebug(1, "\nProblem creating an AVL trees directory");
return NULL; return NULL;
} }
@ -390,24 +390,24 @@ OBIDMS_p obi_open_dms(const char* dms_name)
dms->little_endian = little_endian_dms; dms->little_endian = little_endian_dms;
// Open the arrays directory // Open the AVL trees directory
dms->array_directory = private_opendirat(dms->dir_fd, ARRAYS_DIR_NAME); dms->avl_directory = private_opendirat(dms->dir_fd, AVL_TREES_DIR_NAME);
if (dms->array_directory == NULL) if (dms->avl_directory == NULL)
{ {
obi_set_errno(OBIDMS_UNKNOWN_ERROR); obi_set_errno(OBIDMS_UNKNOWN_ERROR);
obidebug(1, "\nError opening the arrays directory"); obidebug(1, "\nError opening the AVL trees directory");
closedir(dms->directory); closedir(dms->directory);
free(dms); free(dms);
return NULL; return NULL;
} }
// Store the array directory's file descriptor // Store the AVL trees directory's file descriptor
dms->array_dir_fd = dirfd(dms->array_directory); dms->avl_dir_fd = dirfd(dms->avl_directory);
if (dms->array_dir_fd < 0) if (dms->avl_dir_fd < 0)
{ {
obi_set_errno(OBIDMS_UNKNOWN_ERROR); obi_set_errno(OBIDMS_UNKNOWN_ERROR);
obidebug(1, "\nError getting the file descriptor of the arrays directory"); obidebug(1, "\nError getting the file descriptor of the AVL trees directory");
closedir(dms->array_directory); closedir(dms->avl_directory);
closedir(dms->directory); closedir(dms->directory);
free(dms); free(dms);
return NULL; return NULL;
@ -418,10 +418,10 @@ OBIDMS_p obi_open_dms(const char* dms_name)
(dms->opened_columns)->columns = (OBIDMS_column_p*) malloc(MAX_NB_OPENED_COLUMNS*sizeof(OBIDMS_column_p)); (dms->opened_columns)->columns = (OBIDMS_column_p*) malloc(MAX_NB_OPENED_COLUMNS*sizeof(OBIDMS_column_p));
(dms->opened_columns)->nb_opened_columns = 0; (dms->opened_columns)->nb_opened_columns = 0;
// Initialize the list of opened arrays // Initialize the list of opened AVL trees
dms->opened_arrays = (Opened_arrays_list_p) malloc(sizeof(Opened_arrays_list_t)); dms->opened_avls = (Opened_avls_list_p) malloc(sizeof(Opened_avls_list_t));
(dms->opened_arrays)->arrays = (OBIDMS_array_p*) malloc(MAX_NB_OPENED_ARRAYS*sizeof(OBIDMS_array_p)); (dms->opened_avls)->avls = (OBIDMS_avl_p*) malloc(MAX_NB_OPENED_AVL_TREES*sizeof(OBIDMS_avl_p));
(dms->opened_arrays)->nb_opened_arrays = 0; (dms->opened_avls)->nb_opened_avls = 0;
return dms; return dms;
} }
@ -454,7 +454,7 @@ int obi_close_dms(OBIDMS_p dms)
while ((dms->opened_columns)->nb_opened_columns > 0) while ((dms->opened_columns)->nb_opened_columns > 0)
obi_close_column(*((dms->opened_columns)->columns)); obi_close_column(*((dms->opened_columns)->columns));
// Close dms and array directories // Close dms and AVL trees directories
if (closedir(dms->directory) < 0) if (closedir(dms->directory) < 0)
{ {
obi_set_errno(OBIDMS_MEMORY_ERROR); obi_set_errno(OBIDMS_MEMORY_ERROR);
@ -462,10 +462,10 @@ int obi_close_dms(OBIDMS_p dms)
free(dms); free(dms);
return -1; return -1;
} }
if (closedir(dms->array_directory) < 0) if (closedir(dms->avl_directory) < 0)
{ {
obi_set_errno(OBI_ARRAY_ERROR); obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError closing an array directory"); obidebug(1, "\nError closing an AVL trees directory");
free(dms); free(dms);
return -1; return -1;
} }

View File

@ -25,14 +25,14 @@
#include "obierrno.h" #include "obierrno.h"
#define OBIDMS_MAX_NAME (2048) /**< The maximum length of an OBIDMS name. #define OBIDMS_MAX_NAME (2048) /**< The maximum length of an OBIDMS name.
*/ */
#define ARRAYS_DIR_NAME "arrays" /**< The name of the arrays directory. #define AVL_TREES_DIR_NAME "AVL_trees" /**< The name of the AVL trees directory.
*/ */
#define MAX_NB_OPENED_COLUMNS (100) /**< The maximum number of columns open at the same time. #define MAX_NB_OPENED_COLUMNS (100) /**< The maximum number of columns open at the same time.
*/ */
#define MAX_NB_OPENED_ARRAYS (100) /**< The maximum number of arrays open at the same time. #define MAX_NB_OPENED_AVL_TREES (100) /**< The maximum number of AVL trees open at the same time.
*/ */
struct OBIDMS_column; // TODO struct OBIDMS_column; // TODO
@ -43,12 +43,12 @@ typedef struct Opened_columns_list {
} Opened_columns_list_t, *Opened_columns_list_p; } Opened_columns_list_t, *Opened_columns_list_p;
struct OBIDMS_array; // TODO struct OBIDMS_avl; // TODO
typedef struct Opened_arrays_list { typedef struct Opened_avls_list {
size_t nb_opened_arrays; size_t nb_opened_avls;
struct OBIDMS_array** arrays; struct OBIDMS_avl** avls;
} Opened_arrays_list_t, *Opened_arrays_list_p; } Opened_avls_list_t, *Opened_avls_list_p;
/** /**
@ -67,17 +67,17 @@ typedef struct OBIDMS {
int dir_fd; /**< The file descriptor of the directory entry int dir_fd; /**< The file descriptor of the directory entry
* usable to refer and scan the database directory. * usable to refer and scan the database directory.
*/ */
DIR* array_directory; /**< A directory entry usable to DIR* avl_directory; /**< A directory entry usable to
* refer and scan the array directory. * refer and scan the AVL trees directory.
*/ */
int array_dir_fd; /**< The file descriptor of the directory entry int avl_dir_fd; /**< The file descriptor of the directory entry
* usable to refer and scan the array directory. * usable to refer and scan the AVL trees directory.
*/ */
bool little_endian; /**< Endianness of the database. bool little_endian; /**< Endianness of the database.
*/ */
Opened_columns_list_p opened_columns; /**< List of opened columns. Opened_columns_list_p opened_columns; /**< List of opened columns.
*/ */
Opened_arrays_list_p opened_arrays; /**< List of opened arrays. Opened_avls_list_p opened_avls; /**< List of opened AVL trees.
*/ */
} OBIDMS_t, *OBIDMS_p; } OBIDMS_t, *OBIDMS_p;
@ -105,7 +105,7 @@ int obi_dms_exists(const char* dms_name);
* if a directory with this name does not already exist * if a directory with this name does not already exist
* before creating the new database. * before creating the new database.
* *
* A directory to store obiarrays is also created. * A directory to store AVL trees is also created.
* *
* @param dms_name A pointer to a C string containing the name of the database. * @param dms_name A pointer to a C string containing the name of the database.
* The actual directory name used to store the DMS will be * The actual directory name used to store the DMS will be

View File

@ -29,7 +29,7 @@
#include "obierrno.h" #include "obierrno.h"
#include "obidebug.h" #include "obidebug.h"
#include "obilittlebigman.h" #include "obilittlebigman.h"
#include "obiarray.h" #include "obiavl.h"
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?) #define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
@ -514,14 +514,14 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
index_t nb_lines, index_t nb_lines,
index_t nb_elements_per_line, index_t nb_elements_per_line,
const char* elements_names, const char* elements_names,
const char* array_name, const char* avl_name,
const char* comments, const char* comments,
bool referring) bool referring)
{ {
OBIDMS_column_p new_column; OBIDMS_column_p new_column;
OBIDMS_column_directory_p column_directory; OBIDMS_column_directory_p column_directory;
OBIDMS_column_header_p header; OBIDMS_column_header_p header;
OBIDMS_array_p array; OBIDMS_avl_p avl;
size_t file_size; size_t file_size;
obiversion_t version_number; obiversion_t version_number;
char* column_file_name; char* column_file_name;
@ -552,9 +552,9 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
obidebug(1, "\nCan't create column because of invalid data type"); obidebug(1, "\nCan't create column because of invalid data type");
return NULL; return NULL;
} }
if (((data_type == OBI_STR) || (data_type == OBI_SEQ)) && (array_name == NULL)) if (((data_type == OBI_STR) || (data_type == OBI_SEQ)) && (avl_name == NULL))
{ {
obidebug(1, "\nCan't create column because of empty array name"); obidebug(1, "\nCan't create column because of empty avl name");
return NULL; return NULL;
} }
@ -732,20 +732,20 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
if (comments != NULL) if (comments != NULL)
strncpy(header->comments, comments, COMMENTS_MAX_LENGTH); strncpy(header->comments, comments, COMMENTS_MAX_LENGTH);
// If the data type is OBI_STR or OBI_SEQ, the associated obi_array is opened or created // 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)) if ((returned_data_type == OBI_STR) || (returned_data_type == OBI_SEQ))
{ {
array = obi_array(dms, array_name); avl = obi_avl(dms, avl_name);
if (array == NULL) if (avl == NULL)
{ {
obidebug(1, "\nError opening or creating the array associated with a column"); obidebug(1, "\nError opening or creating the aVL tree associated with a column");
munmap(new_column->header, header_size); munmap(new_column->header, header_size);
close(column_file_descriptor); close(column_file_descriptor);
free(new_column); free(new_column);
return NULL; return NULL;
} }
new_column->array = array; new_column->avl = avl;
strncpy(header->array_name, array_name, ARRAY_MAX_NAME); strncpy(header->avl_name, avl_name, AVL_MAX_NAME);
} }
// Fill the data with NA values // Fill the data with NA values
@ -768,7 +768,7 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
{ {
OBIDMS_column_p column; OBIDMS_column_p column;
OBIDMS_column_directory_p column_directory; OBIDMS_column_directory_p column_directory;
OBIDMS_array_p array; OBIDMS_avl_p avl;
char* column_file_name; char* column_file_name;
int column_file_descriptor; int column_file_descriptor;
size_t header_size; size_t header_size;
@ -886,19 +886,19 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
column->writable = false; column->writable = false;
// If the data type is OBI_STR or OBI_SEQ, the associated obi_array is opened // 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)) if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
{ {
array = obi_array(dms, (column->header)->array_name); avl = obi_avl(dms, (column->header)->avl_name);
if (array == NULL) if (avl == NULL)
{ {
obidebug(1, "\nError opening the array associated with a column"); obidebug(1, "\nError opening the AVL tree associated with a column");
munmap(column->header, header_size); munmap(column->header, header_size);
close(column_file_descriptor); close(column_file_descriptor);
free(column); free(column);
return NULL; return NULL;
} }
column->array = array; column->avl = avl;
} }
if ((column->header)->referring) if ((column->header)->referring)
@ -973,7 +973,7 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms,
nb_lines, nb_lines,
nb_elements_per_line, nb_elements_per_line,
(column_to_clone->header)->elements_names, (column_to_clone->header)->elements_names,
(column_to_clone->header)->array_name, (column_to_clone->header)->avl_name,
(column_to_clone->header)->comments, (column_to_clone->header)->comments,
referring); referring);
@ -1052,10 +1052,10 @@ int obi_close_column(OBIDMS_column_p column)
if ((column->header)->referring) if ((column->header)->referring)
obi_close_column(column->referred_column); obi_close_column(column->referred_column);
// If the data type is OBI_STR or OBI_SEQ, the associated obi_array is closed // If the data type is OBI_STR or OBI_SEQ, the associated AVL tree is closed
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ)) if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
{ {
if (obi_close_array(column->array) < 0) if (obi_close_avl(column->avl) < 0)
return -1; return -1;
} }

View File

@ -25,7 +25,7 @@
#include "obierrno.h" #include "obierrno.h"
#include "obilittlebigman.h" #include "obilittlebigman.h"
#include "obidmscolumndir.h" #include "obidmscolumndir.h"
#include "obiarray.h" #include "obiavl.h"
#define ONE_IF_ZERO(x) (((x)==0)?1:(x)) /**< If x is equal to 0, x takes the value 1. #define ONE_IF_ZERO(x) (((x)==0)?1:(x)) /**< If x is equal to 0, x takes the value 1.
@ -86,7 +86,7 @@ typedef struct OBIDMS_column_header {
*/ */
char name[OBIDMS_COLUMN_MAX_NAME+1]; /**< The column name as a NULL terminated string. char name[OBIDMS_COLUMN_MAX_NAME+1]; /**< The column name as a NULL terminated string.
*/ */
char array_name[ARRAY_MAX_NAME+1]; /**< If there is one, the obi_array name as a NULL terminated string. char avl_name[AVL_MAX_NAME+1]; /**< If there is one, the AVL tree name as a NULL terminated string.
*/ */
char comments[COMMENTS_MAX_LENGTH+1]; /**< Comments stored as a classical zero end C string. char comments[COMMENTS_MAX_LENGTH+1]; /**< Comments stored as a classical zero end C string.
*/ */
@ -106,7 +106,7 @@ typedef struct OBIDMS_column {
*/ */
OBIDMS_column_header_p header; /**< A pointer to the header of the column. OBIDMS_column_header_p header; /**< A pointer to the header of the column.
*/ */
OBIDMS_array_p array; /**< A pointer to the array associated with the column if there is one. OBIDMS_avl_p avl; /**< A pointer to the AVL tree associated with the column if there is one.
*/ */
struct OBIDMS_column* referred_column; /**< A pointer to the referred column if the column is referring. struct OBIDMS_column* referred_column; /**< A pointer to the referred column if the column is referring.
*/ */
@ -174,7 +174,7 @@ size_t obi_get_platform_header_size();
* @brief Creates a column. * @brief Creates a column.
* *
* The minimum data size allocated is one memory page, and the data is initialized to the NA value of the OBIType. * The minimum data size allocated is one memory page, and the data is initialized to the NA value of the OBIType.
* If there is an array associated with the column, it is opened or created if it does not already exist. * If there is an AVL tree associated with the column, it is opened or created if it does not already exist.
* *
* @warning If there is one element per line, elements_names should be equal to column_name. // TODO change this condition? * @warning If there is one element per line, elements_names should be equal to column_name. // TODO change this condition?
* *
@ -182,9 +182,9 @@ size_t obi_get_platform_header_size();
* @param column_name The name of the new column. * @param column_name The name of the new column.
* @param data_type The OBIType code of the data. * @param data_type The OBIType code of the data.
* @param nb_lines The number of lines to be stored. * @param nb_lines The number of lines to be stored.
* @param nb_elements_per_line The number of elements per line. * @param nb_elements_per_line The number of elements per line. // TODO talk about default values
* @param elements_names The names of the elements with ';' as separator. * @param elements_names The names of the elements with ';' as separator.
* @param array_name The name of the array if there is one associated with the column. * @param avl_name The name of the AVL tree if there is one associated with the column.
* @param comments Optional comments associated with the column. * @param comments Optional comments associated with the column.
* @param referring * @param referring
* *
@ -200,7 +200,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
index_t nb_lines, index_t nb_lines,
index_t nb_elements_per_line, index_t nb_elements_per_line,
const char* elements_names, const char* elements_names,
const char* array_name, const char* avl_name,
const char* comments, const char* comments,
bool referring); bool referring);

View File

@ -17,7 +17,7 @@
#include "obitypes.h" #include "obitypes.h"
#include "obierrno.h" #include "obierrno.h"
#include "obidebug.h" #include "obidebug.h"
#include "obiarray.h" #include "obiavl.h"
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?) #define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
@ -67,8 +67,8 @@ int obi_column_set_obiseq_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
if (value_b == NULL) if (value_b == NULL)
return -1; return -1;
// Add in the obiarray // Add in the AVL tree
idx = obi_array_add(column->array, value_b); idx = obi_avl_add(column->avl, value_b);
if (idx == -1) if (idx == -1)
return -1; return -1;
@ -106,7 +106,7 @@ const char* obi_column_get_obiseq_with_elt_idx(OBIDMS_column_p column, index_t l
if (idx == OBIIdx_NA) if (idx == OBIIdx_NA)
return "\0"; // TODO return "\0"; // TODO
value_b = obi_array_get(column->array, idx); value_b = obi_avl_get(column->avl, idx);
return obi_obibytes_to_seq(value_b); return obi_obibytes_to_seq(value_b);
} }

View File

@ -23,7 +23,7 @@
/** /**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to DNA sequences in an obiarray, using the index of the element in the line. * to DNA sequences in an AVL tree, using the index of the element in the line.
* *
* @warning Pointers returned by obi_open_column() don't allow writing. * @warning Pointers returned by obi_open_column() don't allow writing.
* *
@ -44,7 +44,7 @@ int obi_column_set_obiseq_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
/** /**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to DNA sequences in an obiarray, using the index of the element in the line. * to DNA sequences in an AVL tree, using the index of the element in the line.
* *
* @param column A pointer as returned by obi_create_column(). * @param column A pointer as returned by obi_create_column().
* @param line_nb The number of the line where the value should be recovered. * @param line_nb The number of the line where the value should be recovered.
@ -61,7 +61,7 @@ const char* obi_column_get_obiseq_with_elt_idx(OBIDMS_column_p column, index_t l
/** /**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to DNA sequences in an obiarray, using the name of the element in the line. * to DNA sequences in an AVL tree, using the name of the element in the line.
* *
* @warning Pointers returned by obi_open_column() don't allow writing. * @warning Pointers returned by obi_open_column() don't allow writing.
* *
@ -82,7 +82,7 @@ int obi_column_set_obiseq_with_elt_name(OBIDMS_column_p column, index_t line_nb,
/** /**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to DNA sequences in an obiarray, using the name of the element in the line. * to DNA sequences in an AVL tree, using the name of the element in the line.
* *
* @param column A pointer as returned by obi_create_column() or obi_clone_column(). * @param column A pointer as returned by obi_create_column() or obi_clone_column().
* @param line_nb The number of the line where the value should be recovered. * @param line_nb The number of the line where the value should be recovered.

View File

@ -17,7 +17,7 @@
#include "obitypes.h" #include "obitypes.h"
#include "obierrno.h" #include "obierrno.h"
#include "obidebug.h" #include "obidebug.h"
#include "obiarray.h" #include "obiavl.h"
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?) #define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
@ -67,8 +67,8 @@ int obi_column_set_obistr_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
if (value_b == NULL) if (value_b == NULL)
return -1; return -1;
// Add in the obiarray // Add in the AVL tree
idx = obi_array_add(column->array, value_b); idx = obi_avl_add(column->avl, value_b);
if (idx == -1) if (idx == -1)
return -1; return -1;
@ -106,7 +106,7 @@ const char* obi_column_get_obistr_with_elt_idx(OBIDMS_column_p column, index_t l
if (idx == OBIIdx_NA) if (idx == OBIIdx_NA)
return "\0"; // TODO return "\0"; // TODO
value_b = obi_array_get(column->array, idx); value_b = obi_avl_get(column->avl, idx);
return obi_obibytes_to_str(value_b); return obi_obibytes_to_str(value_b);
} }

View File

@ -23,7 +23,7 @@
/** /**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to character strings in an obiarray, using the index of the element in the line. * to character strings in an AVL tree, using the index of the element in the line.
* *
* @warning Pointers returned by obi_open_column() don't allow writing. * @warning Pointers returned by obi_open_column() don't allow writing.
* *
@ -44,7 +44,7 @@ int obi_column_set_obistr_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
/** /**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to character strings in an obiarray, using the index of the element in the line. * to character strings in an AVL tree, using the index of the element in the line.
* *
* @param column A pointer as returned by obi_create_column(). * @param column A pointer as returned by obi_create_column().
* @param line_nb The number of the line where the value should be recovered. * @param line_nb The number of the line where the value should be recovered.
@ -61,7 +61,7 @@ const char* obi_column_get_obistr_with_elt_idx(OBIDMS_column_p column, index_t l
/** /**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to character strings in an obiarray, using the name of the element in the line. * to character strings in an AVL tree, using the name of the element in the line.
* *
* @warning Pointers returned by obi_open_column() don't allow writing. * @warning Pointers returned by obi_open_column() don't allow writing.
* *
@ -82,7 +82,7 @@ int obi_column_set_obistr_with_elt_name(OBIDMS_column_p column, index_t line_nb,
/** /**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to character strings in an obiarray, using the name of the element in the line. * to character strings in an AVL tree, using the name of the element in the line.
* *
* @param column A pointer as returned by obi_create_column() or obi_clone_column(). * @param column A pointer as returned by obi_create_column() or obi_clone_column().
* @param line_nb The number of the line where the value should be recovered. * @param line_nb The number of the line where the value should be recovered.

View File

@ -98,7 +98,7 @@ extern int obi_errno;
*/ */
#define OBICOL_ACCESS_ERROR (19) /**< Permission error trying to access an OBIDSM column directory #define OBICOL_ACCESS_ERROR (19) /**< Permission error trying to access an OBIDSM column directory
*/ */
#define OBI_ARRAY_ERROR (20) /** Error while handling an array #define OBI_AVL_ERROR (20) /** Error while handling an AVL tree
*/ */
/**@}*/ /**@}*/

View File

@ -56,6 +56,12 @@ typedef double obifloat_t;
typedef char obichar_t; typedef char obichar_t;
// TODO same for obistr_t and obiseq_t ? // TODO same for obistr_t and obiseq_t ?
typedef char byte_t; /**< Defining byte type since the data referred to by AVL trees is stored in bits
* and char (stored on one byte) is the smallest addressable unit.
*/
/** /**
* @brief Union used to compute the NA value of the OBI_FLOAT OBIType. * @brief Union used to compute the NA value of the OBI_FLOAT OBIType.
*/ */