Obiblob_indexer API

This commit is contained in:
Celine Mercier
2016-04-12 14:53:33 +02:00
parent cd4e65e190
commit d8107533d8
21 changed files with 252 additions and 131 deletions

View File

@ -28,3 +28,7 @@
../../../src/crc64.h
../../../src/utils.c
../../../src/utils.h
../../../src/obiblob.c
../../../src/obiblob.h
../../../src/obiblob_indexer.c
../../../src/obiblob_indexer.h

View File

@ -56,7 +56,7 @@ cdef class OBIView:
index_t nb_lines=*,
index_t nb_elements_per_line=*,
list elements_names=*,
str avl_name=*,
str indexer_name=*,
str comments=*,
bint create=*
)

View File

@ -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 avl_name="default_AVL_tree",
str indexer_name="default_indexer",
str comments="",
bint create=True # TODO
) :
@ -388,7 +388,7 @@ cdef class OBIView :
if (obi_view_add_column(self.pointer, column_name_b, version_number, # should return pointer on column?
data_type, nb_lines, nb_elements_per_line,
elements_names_b, str2bytes(avl_name),
elements_names_b, str2bytes(indexer_name),
str2bytes(comments), create) < 0) :
raise Exception("Problem adding a column in a view")

View File

@ -27,7 +27,7 @@ cdef extern from "obidmscolumn.h" nogil:
obiversion_t version
obiversion_t cloned_from
const_char_p name
const_char_p avl_name
const_char_p indexer_name
const_char_p comments
ctypedef OBIDMS_column_header_t* OBIDMS_column_header_p
@ -45,7 +45,7 @@ cdef extern from "obidmscolumn.h" nogil:
index_t nb_lines,
index_t nb_elements_per_line,
const_char_p elements_names,
const_char_p avl_name,
const_char_p indexer_name,
const_char_p comments)
OBIDMS_column_p obi_open_column(OBIDMS_p dms,

View File

@ -90,7 +90,7 @@ cdef extern from "obiview.h" nogil:
index_t nb_lines,
index_t nb_elements_per_line,
const_char_p elements_names,
const_char_p avl_name,
const_char_p indexer_name,
const_char_p comments,
bint create)

View File

@ -510,7 +510,7 @@ char* get_full_path_of_avl_dir(OBIDMS_p dms, const char* avl_name)
{
char* avl_dir_name;
avl_dir_name = get_full_path(dms, AVL_TREES_DIR_NAME);
avl_dir_name = get_full_path(dms, INDEXER_DIR_NAME);
if (avl_dir_name == NULL)
{
obidebug(1, "\nError getting path for the DMS AVL directory");
@ -1291,7 +1291,7 @@ int obi_avl_exists(OBIDMS_p dms, const char* avl_name)
int check_dir;
// Build the AVL tree file path
relative_path_size = strlen(avl_name) + strlen(AVL_TREES_DIR_NAME) + 2;
relative_path_size = strlen(avl_name) + strlen(INDEXER_DIR_NAME) + 2;
avl_dir_relative_path = (char*) malloc(relative_path_size*sizeof(char));
if (avl_dir_relative_path == NULL)
{
@ -1299,7 +1299,7 @@ int obi_avl_exists(OBIDMS_p dms, const char* avl_name)
obidebug(1, "\nError allocating memory for the path to the AVL directory");
return -1;
}
strcpy(avl_dir_relative_path, AVL_TREES_DIR_NAME);
strcpy(avl_dir_relative_path, INDEXER_DIR_NAME);
strcat(avl_dir_relative_path, "/");
strcat(avl_dir_relative_path, avl_name);
avl_dir_path = get_full_path(dms, avl_dir_relative_path);
@ -1367,7 +1367,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
// Create that AVL's directory if it doesn't already exist
if (check_dir < 0)
{
if (mkdirat(dms->avl_dir_fd, avl_dir_name, 00777) < 0)
if (mkdirat(dms->indexer_dir_fd, avl_dir_name, 00777) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError creating an AVL directory");
@ -1596,7 +1596,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
avl->dms = dms;
avl->data = avl_data;
avl->directory = dms->avl_directory;
avl->directory = dms->indexer_directory;
avl->dir_fd = avl_dir_fd;
avl->avl_fd = avl_file_descriptor;
@ -1612,8 +1612,8 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
bloom_init(&((avl->header)->bloom_filter), MAX_NODE_COUNT_PER_AVL);
// Add in the list of opened AVL trees
*(((dms->opened_avls)->avls)+((dms->opened_avls)->nb_opened_avls)) = avl;
((dms->opened_avls)->nb_opened_avls)++;
*(((dms->opened_indexers)->indexers)+((dms->opened_indexers)->nb_opened_indexers)) = avl;
((dms->opened_indexers)->nb_opened_indexers)++;
avl->counter = 1;
if (avl_idx >= 0)
@ -1658,14 +1658,14 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
}
// Check if the AVL tree is already in the list of opened AVL trees
for (i=0; i < ((dms->opened_avls)->nb_opened_avls); i++)
for (i=0; i < ((dms->opened_indexers)->nb_opened_indexers); i++)
{
if (!strcmp(((*(((dms->opened_avls)->avls)+i))->header)->avl_name, complete_avl_name))
if (!strcmp(((*(((dms->opened_indexers)->indexers)+i))->header)->avl_name, complete_avl_name))
{ // Found the AVL tree already opened
((*(((dms->opened_avls)->avls)+i))->counter)++;
((*(((dms->opened_indexers)->indexers)+i))->counter)++;
if (avl_idx >= 0)
free(complete_avl_name);
return *(((dms->opened_avls)->avls)+i);
return *(((dms->opened_indexers)->indexers)+i);
}
}
@ -1873,13 +1873,13 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name, int avl_idx)
avl->dms = dms;
avl->data = avl_data;
avl->directory = dms->avl_directory;
avl->directory = dms->indexer_directory;
avl->dir_fd = avl_dir_file_descriptor;
avl->avl_fd = avl_file_descriptor;
// Add in the list of opened AVL trees
*(((dms->opened_avls)->avls)+((dms->opened_avls)->nb_opened_avls)) = avl;
((dms->opened_avls)->nb_opened_avls)++;
*(((dms->opened_indexers)->indexers)+((dms->opened_indexers)->nb_opened_indexers)) = avl;
((dms->opened_indexers)->nb_opened_indexers)++;
avl->counter = 1;
if (avl_idx >= 0)
@ -1983,26 +1983,26 @@ 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;
size_t i;
Opened_avls_list_p avls_list;
OBIDMS_p dms;
int ret_val = 0;
size_t i;
Opened_indexers_list_p indexers_list;
OBIDMS_p dms;
dms = avl->dms;
avls_list = dms->opened_avls;
indexers_list = dms->opened_indexers;
(avl->counter)--;
if (avl->counter == 0)
{
// Delete from the list of opened avls
for (i=0; i < (avls_list->nb_opened_avls); i++)
for (i=0; i < (indexers_list->nb_opened_indexers); i++)
{
if (!strcmp(((*((avls_list->avls)+i))->header)->avl_name, (avl->header)->avl_name))
if (!strcmp(((*((indexers_list->indexers)+i))->header)->avl_name, (avl->header)->avl_name))
{ // Found the avl. Rearrange list
(avls_list->nb_opened_avls)--;
(avls_list->avls)[i] = (avls_list->avls)[avls_list->nb_opened_avls];
(indexers_list->nb_opened_indexers)--;
(indexers_list->indexers)[i] = (indexers_list->indexers)[indexers_list->nb_opened_indexers];
}
}

View File

@ -127,6 +127,7 @@ typedef struct OBIDMS_avl_header {
/**
* @brief OBIDMS AVL tree structure.
* TODO doc
*/
typedef struct OBIDMS_avl {
OBIDMS_p dms; /**< A pointer to the OBIDMS structure to which the AVL tree belongs.

37
src/obiblob_indexer.c Normal file
View File

@ -0,0 +1,37 @@
/****************************************************************************
* Obiblob functions *
****************************************************************************/
/**
* @file obiblob_indexer.c
* @author Celine Mercier
* @date April 12th 2016
* @brief Functions handling the indexing and retrieval of blob structures.
*/
#include <stdlib.h>
#include <stdio.h>
#include "obiblob_indexer.h"
#include "obidms.h"
#include "obiavl.h"
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
inline int obi_indexer_exists(OBIDMS_p dms, const char* name);
inline Obi_indexer_p obi_indexer(OBIDMS_p dms, const char* name);
inline Obi_indexer_p obi_create_indexer(OBIDMS_p dms, const char* name);
inline Obi_indexer_p obi_open_indexer(OBIDMS_p dms, const char* name);
inline int obi_close_indexer(Obi_indexer_p indexer);
inline index_t obi_indexer_add(Obi_indexer_p indexer, Obi_blob_p value);
inline Obi_blob_p obi_indexer_get(Obi_indexer_p indexer, index_t idx);

78
src/obiblob_indexer.h Normal file
View File

@ -0,0 +1,78 @@
/****************************************************************************
* Blob indexer header file *
****************************************************************************/
/**
* @file obiblob_indexer.h
* @author Celine Mercier
* @date April 12th 2016
* @brief Header file for the functions handling the indexing of values.
*/
#ifndef OBIBLOB_INDEXER_H_
#define OBIBLOB_INDEXER_H_
#include <stdlib.h>
#include <stdio.h>
#include "obidms.h"
#include "obiavl.h"
#include "obitypes.h"
#include "obiblob.h"
#define INDEXER_MAX_NAME AVL_MAX_NAME /**< Macro to refer to the maximum size of the name of an indexer structure.
*/
typedef OBIDMS_avl_group_p Obi_indexer_p; /**< Typedef to refer to the used indexer structure.
*/
// TODO doc
inline int obi_indexer_exists(OBIDMS_p dms, const char* name)
{
return obi_avl_exists(dms, name);
}
inline Obi_indexer_p obi_indexer(OBIDMS_p dms, const char* name)
{
return obi_avl_group(dms, name);
}
inline Obi_indexer_p obi_create_indexer(OBIDMS_p dms, const char* name)
{
return obi_create_avl_group(dms, name);
}
inline Obi_indexer_p obi_open_indexer(OBIDMS_p dms, const char* name)
{
return obi_open_avl_group(dms, name);
}
inline int obi_close_indexer(Obi_indexer_p indexer)
{
return obi_close_avl_group(indexer);
}
inline index_t obi_indexer_add(Obi_indexer_p indexer, Obi_blob_p value)
{
return obi_avl_group_add(indexer, value);
}
inline Obi_blob_p obi_indexer_get(Obi_indexer_p indexer, index_t idx)
{
return obi_avl_group_get(indexer, idx);
}
#endif /* OBIBLOB_INDEXER_H_ */

View File

@ -249,7 +249,7 @@ OBIDMS_p obi_create_dms(const char* dms_name)
return NULL;
}
// Get file descriptor of DMS directory to create the AVL trees directory
// Get file descriptor of DMS directory to create the indexer directory
dms_dir = opendir(directory_name);
if (dms_dir == NULL)
{
@ -269,11 +269,11 @@ OBIDMS_p obi_create_dms(const char* dms_name)
return NULL;
}
// Create the AVL trees directory
if (mkdirat(dms_file_descriptor, AVL_TREES_DIR_NAME, 00777) < 0)
// Create the indexer directory
if (mkdirat(dms_file_descriptor, INDEXER_DIR_NAME, 00777) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nProblem creating an AVL trees directory");
obi_set_errno(OBI_INDEXER_ERROR);
obidebug(1, "\nProblem creating an indexer directory");
return NULL;
}
@ -392,24 +392,24 @@ OBIDMS_p obi_open_dms(const char* dms_name)
dms->little_endian = little_endian_dms;
// Open the AVL trees directory
dms->avl_directory = opendir_in_dms(dms, AVL_TREES_DIR_NAME);
if (dms->avl_directory == NULL)
// Open the indexer directory
dms->indexer_directory = opendir_in_dms(dms, INDEXER_DIR_NAME);
if (dms->indexer_directory == NULL)
{
obi_set_errno(OBIDMS_UNKNOWN_ERROR);
obidebug(1, "\nError opening the AVL trees directory");
obidebug(1, "\nError opening the indexer directory");
closedir(dms->directory);
free(dms);
return NULL;
}
// Store the AVL trees directory's file descriptor
dms->avl_dir_fd = dirfd(dms->avl_directory);
if (dms->avl_dir_fd < 0)
// Store the indexer directory's file descriptor
dms->indexer_dir_fd = dirfd(dms->indexer_directory);
if (dms->indexer_dir_fd < 0)
{
obi_set_errno(OBIDMS_UNKNOWN_ERROR);
obidebug(1, "\nError getting the file descriptor of the AVL trees directory");
closedir(dms->avl_directory);
obidebug(1, "\nError getting the file descriptor of the indexer directory");
closedir(dms->indexer_directory);
closedir(dms->directory);
free(dms);
return NULL;
@ -420,10 +420,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)->nb_opened_columns = 0;
// Initialize the list of opened AVL trees
dms->opened_avls = (Opened_avls_list_p) malloc(sizeof(Opened_avls_list_t));
(dms->opened_avls)->avls = (OBIDMS_avl_p*) malloc(MAX_NB_OPENED_AVL_TREES*sizeof(OBIDMS_avl_p));
(dms->opened_avls)->nb_opened_avls = 0;
// Initialize the list of opened indexers // TODO should be handled somewhere else?
dms->opened_indexers = (Opened_indexers_list_p) malloc(sizeof(Opened_indexers_list_t));
(dms->opened_indexers)->indexers = (OBIDMS_avl_p*) malloc(MAX_NB_OPENED_INDEXERS*sizeof(OBIDMS_avl_p)); // TODO idk how to handle this
(dms->opened_indexers)->nb_opened_indexers = 0;
return dms;
}
@ -456,7 +456,7 @@ int obi_close_dms(OBIDMS_p dms)
while ((dms->opened_columns)->nb_opened_columns > 0)
obi_close_column(*((dms->opened_columns)->columns));
// Close dms and AVL trees directories
// Close dms and indexer directories
if (closedir(dms->directory) < 0)
{
obi_set_errno(OBIDMS_MEMORY_ERROR);
@ -464,10 +464,10 @@ int obi_close_dms(OBIDMS_p dms)
free(dms);
return -1;
}
if (closedir(dms->avl_directory) < 0)
if (closedir(dms->indexer_directory) < 0) // TODO should be handled somewhere else?
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError closing an AVL trees directory");
obi_set_errno(OBI_INDEXER_ERROR);
obidebug(1, "\nError closing an indexer directory");
free(dms);
return -1;
}

View File

@ -25,16 +25,16 @@
#include "obierrno.h"
#define OBIDMS_MAX_NAME (2048) /**< The maximum length of an OBIDMS name.
*/
#define AVL_TREES_DIR_NAME "AVL_trees" /**< The name of the AVL trees directory.
*/
#define TAXONOMY_DIR_NAME "TAXONOMY" /**< The name of the taxonomy directory.
*/
#define MAX_NB_OPENED_COLUMNS (100) /**< The maximum number of columns open at the same time.
*/
#define MAX_NB_OPENED_AVL_TREES (1000) /**< The maximum number of AVL trees open at the same time.
*/
#define OBIDMS_MAX_NAME (2048) /**< The maximum length of an OBIDMS name.
*/
#define INDEXER_DIR_NAME "OBIBLOB_INDEXERS" /**< The name of the Obiblob indexer directory.
*/
#define TAXONOMY_DIR_NAME "TAXONOMY" /**< The name of the taxonomy directory.
*/
#define MAX_NB_OPENED_COLUMNS (100) /**< The maximum number of columns open at the same time.
*/
#define MAX_NB_OPENED_INDEXERS (1000) /**< The maximum number of indexers open at the same time.
*/
struct OBIDMS_column; // TODO
@ -47,10 +47,10 @@ typedef struct Opened_columns_list {
struct OBIDMS_avl; // TODO
typedef struct Opened_avls_list {
size_t nb_opened_avls;
struct OBIDMS_avl** avls;
} Opened_avls_list_t, *Opened_avls_list_p;
typedef struct Opened_indexers_list {
size_t nb_opened_indexers;
struct OBIDMS_avl** indexers; // TODO indexer but not AVL_group
} Opened_indexers_list_t, *Opened_indexers_list_p;
/**
@ -69,17 +69,17 @@ typedef struct OBIDMS {
int dir_fd; /**< The file descriptor of the directory entry
* usable to refer and scan the database directory.
*/
DIR* avl_directory; /**< A directory entry usable to
* refer and scan the AVL trees directory.
DIR* indexer_directory; /**< A directory entry usable to
* refer and scan the indexer directory.
*/
int avl_dir_fd; /**< The file descriptor of the directory entry
* usable to refer and scan the AVL trees directory.
int indexer_dir_fd; /**< The file descriptor of the directory entry
* usable to refer and scan the indexer directory.
*/
bool little_endian; /**< Endianness of the database.
*/
Opened_columns_list_p opened_columns; /**< List of opened columns.
*/
Opened_avls_list_p opened_avls; /**< List of opened AVL trees.
Opened_indexers_list_p opened_indexers; /**< List of opened indexers.
*/
} OBIDMS_t, *OBIDMS_p;
@ -107,7 +107,7 @@ int obi_dms_exists(const char* dms_name);
* if a directory with this name does not already exist
* before creating the new database.
*
* A directory to store AVL trees is also created.
* A directory to store Obiblob indexers is also created.
*
* @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

View File

@ -29,7 +29,7 @@
#include "obierrno.h"
#include "obidebug.h"
#include "obilittlebigman.h"
#include "obiavl.h"
#include "obiblob_indexer.h"
#include "utils.h"
@ -519,7 +519,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
index_t nb_lines,
index_t nb_elements_per_line,
const char* elements_names,
const char* avl_name,
const char* indexer_name,
const char* comments
)
{
@ -554,9 +554,9 @@ 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)) && (avl_name == NULL))
if (((data_type == OBI_STR) || (data_type == OBI_SEQ)) && (indexer_name == NULL))
{
obidebug(1, "\nCan't create column because of empty avl name");
obidebug(1, "\nCan't create column because of empty indexer name");
return NULL;
}
@ -724,19 +724,19 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
if (comments != NULL)
strncpy(header->comments, comments, COMMENTS_MAX_LENGTH);
// If the data type is OBI_STR or OBI_SEQ, the associated obi_avl is opened or created
// 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->avl = obi_avl_group(dms, avl_name);
if (new_column->avl == NULL)
new_column->indexer = obi_indexer(dms, indexer_name);
if (new_column->indexer == NULL)
{
obidebug(1, "\nError opening or creating the AVL group associated with a column");
obidebug(1, "\nError opening or creating the indexer associated with a column");
munmap(new_column->header, header_size);
close(column_file_descriptor);
free(new_column);
return NULL;
}
strncpy(header->avl_name, avl_name, AVL_MAX_NAME);
strncpy(header->indexer_name, indexer_name, INDEXER_MAX_NAME);
}
// Fill the data with NA values
@ -876,13 +876,13 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
column->writable = false;
// If the data type is OBI_STR or OBI_SEQ, the associated AVL tree is opened
// If the data type is OBI_STR or OBI_SEQ, the associated indexer is opened
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
{
column->avl = obi_open_avl_group(dms, (column->header)->avl_name);
if (column->avl == NULL)
column->indexer = obi_open_indexer(dms, (column->header)->indexer_name);
if (column->indexer == NULL)
{
obidebug(1, "\nError opening the AVL tree associated with a column");
obidebug(1, "\nError opening the indexer associated with a column");
munmap(column->header, header_size);
close(column_file_descriptor);
free(column);
@ -940,7 +940,7 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms,
nb_lines,
nb_elements_per_line,
(column_to_clone->header)->elements_names,
(column_to_clone->header)->avl_name,
(column_to_clone->header)->indexer_name,
(column_to_clone->header)->comments
);
@ -1016,10 +1016,10 @@ int obi_close_column(OBIDMS_column_p column)
}
}
// If the data type is OBI_STR or OBI_SEQ, the associated AVL group is closed
// If the data type is OBI_STR or OBI_SEQ, the associated indexer is closed
if (((column->header)->returned_data_type == OBI_STR) || ((column->header)->returned_data_type == OBI_SEQ))
{
if (obi_close_avl_group(column->avl) < 0)
if (obi_close_indexer(column->indexer) < 0)
return -1;
}

View File

@ -25,7 +25,7 @@
#include "obierrno.h"
#include "obilittlebigman.h"
#include "obidmscolumndir.h"
#include "obiavl.h"
#include "obiblob_indexer.h"
#define ELEMENTS_NAMES_MAX (2048) /**< The maximum length of the list of elements names.
@ -76,7 +76,7 @@ typedef struct OBIDMS_column_header {
*/
char name[OBIDMS_COLUMN_MAX_NAME+1]; /**< The column 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 indexer_name[INDEXER_MAX_NAME+1]; /**< If there is one, the indexer name as a NULL terminated string.
*/
char comments[COMMENTS_MAX_LENGTH+1]; /**< Comments stored as a classical zero end C string.
*/
@ -96,7 +96,7 @@ typedef struct OBIDMS_column {
*/
OBIDMS_column_header_p header; /**< A pointer to the header of the column.
*/
OBIDMS_avl_group_p avl; /**< TODO A pointer to the group of AVL trees associated with the column if there is one.
Obi_indexer_p indexer; /**< A pointer to the blob indexer associated with the column if there is one.
*/
void* data; /**< A `void` pointer to the beginning of the data.
*
@ -162,7 +162,7 @@ size_t obi_get_platform_header_size();
* @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.
* If there is an AVL tree associated with the column, it is opened or created if it does not already exist.
* If there is an indexer 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?
*
@ -172,7 +172,7 @@ size_t obi_get_platform_header_size();
* @param nb_lines The number of lines to be stored.
* @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 avl_name The name of the AVL tree if there is one associated with the column.
* @param indexer_name The name of the indexer if there is one associated with the column.
* @param comments Optional comments associated with the column.
*
* @returns A pointer on the newly created column structure.
@ -187,7 +187,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
index_t nb_lines,
index_t nb_elements_per_line,
const char* elements_names,
const char* avl_name,
const char* indexer_name,
const char* comments
);

View File

@ -18,7 +18,7 @@
#include "obitypes.h"
#include "obierrno.h"
#include "obidebug.h"
#include "obiavl.h"
#include "obiblob_indexer.h"
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
@ -61,8 +61,8 @@ int obi_column_set_obiseq_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
if (value_b == NULL)
return -1;
// Add in the AVL tree
idx = obi_avl_group_add(column->avl, value_b);
// Add in the indexer
idx = obi_indexer_add(column->indexer, value_b);
if (idx == -1)
return -1;
@ -130,7 +130,7 @@ const char* obi_column_get_obiseq_with_elt_idx(OBIDMS_column_p column, index_t l
if (idx == OBIIdx_NA)
return OBISeq_NA;
value_b = obi_avl_group_get(column->avl, idx);
value_b = obi_indexer_get(column->indexer, idx);
return obi_blob_to_seq(value_b);
}

View File

@ -24,7 +24,7 @@
/**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to DNA sequences in an AVL tree, using the index of the element in the line.
* to DNA sequences handled by an indexer, and using the index of the element in the column's line.
*
* @warning Pointers returned by obi_open_column() don't allow writing.
*
@ -45,7 +45,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
* to DNA sequences in an AVL tree, using the index of the element in the line.
* to DNA sequences handled by an indexer, and using the index of the element in the column's line.
*
* @param column A pointer as returned by obi_create_column().
* @param line_nb The number of the line where the value should be recovered.
@ -62,7 +62,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
* to DNA sequences in an AVL tree, using the name of the element in the line.
* to DNA sequences handled by an indexer, using the name of the element in the line.
*
* @warning Pointers returned by obi_open_column() don't allow writing.
*
@ -83,7 +83,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
* to DNA sequences in an AVL tree, using the name of the element in the line.
* to DNA sequences handled by an indexer, using the name of the element in the line.
*
* @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.
@ -100,7 +100,7 @@ const char* obi_column_get_obiseq_with_elt_name(OBIDMS_column_p column, index_t
/**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to DNA sequences in an AVL tree, using the index of the element in the line.
* to DNA sequences handled by an indexer, using the index of the element in the line.
*
* @warning Pointers returned by obi_open_column() don't allow writing.
*
@ -121,7 +121,7 @@ int obi_column_set_obiseq_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p c
/**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to DNA sequences in an AVL tree, using the index of the element in the line.
* to DNA sequences handled by an indexer, using the index of the element in the line.
*
* @param column A pointer as returned by obi_create_column().
* @param line_nb The number of the line where the value should be recovered.
@ -138,7 +138,7 @@ const char* obi_column_get_obiseq_with_elt_idx_in_view(Obiview_p view, OBIDMS_co
/**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to DNA sequences in an AVL tree, using the name of the element in the line.
* to DNA sequences handled by an indexer, using the name of the element in the line.
*
* @warning Pointers returned by obi_open_column() don't allow writing.
*
@ -159,7 +159,7 @@ int obi_column_set_obiseq_with_elt_name_in_view(Obiview_p view, OBIDMS_column_p
/**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to DNA sequences in an AVL tree, using the name of the element in the line.
* to DNA sequences handled by an indexer, using the name of the element in the line.
*
* @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.

View File

@ -18,7 +18,7 @@
#include "obitypes.h"
#include "obierrno.h"
#include "obidebug.h"
#include "obiavl.h"
#include "obiblob_indexer.h"
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
@ -32,8 +32,8 @@
int obi_column_set_obistr_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx, char* value)
{
Obi_blob_p value_b;
index_t idx;
Obi_blob_p value_b;
index_t idx;
// Check that the line number is not greater than the maximum allowed
if (line_nb >= MAXIMUM_LINE_COUNT)
@ -60,8 +60,8 @@ int obi_column_set_obistr_with_elt_idx(OBIDMS_column_p column, index_t line_nb,
if (value_b == NULL)
return -1;
// Add in the AVL tree
idx = obi_avl_group_add(column->avl, value_b);
// Add in the indexer
idx = obi_indexer_add(column->indexer, value_b);
if (idx == -1)
return -1;
@ -129,7 +129,7 @@ const char* obi_column_get_obistr_with_elt_idx(OBIDMS_column_p column, index_t l
if (idx == OBIIdx_NA)
return OBIStr_NA;
value_b = obi_avl_group_get(column->avl, idx);
value_b = obi_indexer_get(column->indexer, idx);
return obi_blob_to_str(value_b);
}

View File

@ -24,7 +24,7 @@
/**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to character strings in an AVL tree, using the index of the element in the line.
* to character strings handled by an indexer, using the index of the element in the line.
*
* @warning Pointers returned by obi_open_column() don't allow writing.
*
@ -45,7 +45,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
* to character strings in an AVL tree, using the index of the element in the line.
* to character strings handled by an indexer, using the index of the element in the line.
*
* @param column A pointer as returned by obi_create_column().
* @param line_nb The number of the line where the value should be recovered.
@ -62,7 +62,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
* to character strings in an AVL tree, using the name of the element in the line.
* to character strings handled by an indexer, using the name of the element in the line.
*
* @warning Pointers returned by obi_open_column() don't allow writing.
*
@ -83,7 +83,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
* to character strings in an AVL tree, using the name of the element in the line.
* to character strings handled by an indexer, using the name of the element in the line.
*
* @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.
@ -100,7 +100,7 @@ const char* obi_column_get_obistr_with_elt_name(OBIDMS_column_p column, index_t
/**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to character strings in an AVL tree, using the index of the element in the line.
* to character strings handled by an indexer, using the index of the element in the line.
*
* @warning Pointers returned by obi_open_column() don't allow writing.
*
@ -121,7 +121,7 @@ int obi_column_set_obistr_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p c
/**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to character strings in an AVL tree, using the index of the element in the line.
* to character strings handled by an indexer, using the index of the element in the line.
*
* @param column A pointer as returned by obi_create_column().
* @param line_nb The number of the line where the value should be recovered.
@ -138,7 +138,7 @@ const char* obi_column_get_obistr_with_elt_idx_in_view(Obiview_p view, OBIDMS_co
/**
* @brief Sets a value in an OBIDMS column containing data in the form of indices referring
* to character strings in an AVL tree, using the name of the element in the line.
* to character strings handled by an indexer, using the name of the element in the line.
*
* @warning Pointers returned by obi_open_column() don't allow writing.
*
@ -159,7 +159,7 @@ int obi_column_set_obistr_with_elt_name_in_view(Obiview_p view, OBIDMS_column_p
/**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to character strings in an AVL tree, using the name of the element in the line.
* to character strings handled by an indexer, using the name of the element in the line.
*
* @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.

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 OBI_AVL_ERROR (20) /** Error while handling an AVL tree
#define OBI_AVL_ERROR (20) /** Error while handling an AVL tree // TODO delete and just keep OBI_INDEXER_ERROR?
*/
#define OBIVIEW_ERROR (21) /** Error while handling an OBIView
*/
@ -112,6 +112,8 @@ extern int obi_errno;
*/
#define OBI_UTILS_ERROR (26) /** Error in a utils function
*/
#define OBI_INDEXER_ERROR (27) /** Error handling a blob indexer
*/
/**@}*/
#endif /* OBIERRNO_H_ */

View File

@ -59,8 +59,7 @@ typedef char obichar_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.
typedef char byte_t; /**< Defining byte type.
*/

View File

@ -233,19 +233,19 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
if (view_to_clone == NULL)
{
// Adding sequence column
if (obi_view_add_column(view, NUC_SEQUENCE_COLUMN, -1, OBI_SEQ, 0, 1, NUC_SEQUENCE_COLUMN, NUC_SEQUENCE_AVL, "Nucleotide sequences", true) < 0)
if (obi_view_add_column(view, NUC_SEQUENCE_COLUMN, -1, OBI_SEQ, 0, 1, NUC_SEQUENCE_COLUMN, NUC_SEQUENCE_INDEXER, "Nucleotide sequences", true) < 0)
{
obidebug(1, "Error adding an obligatory column in a nucleotide sequences view");
return NULL;
}
// Adding id column
if (obi_view_add_column(view, ID_COLUMN, -1, OBI_STR, 0, 1, ID_COLUMN, ID_AVL, "Ids", true) < 0)
if (obi_view_add_column(view, ID_COLUMN, -1, OBI_STR, 0, 1, ID_COLUMN, ID_INDEXER, "Ids", true) < 0)
{
obidebug(1, "Error adding an obligatory column in a nucleotide sequences view");
return NULL;
}
// Adding description column
if (obi_view_add_column(view, DESCRIPTION_COLUMN, -1, OBI_STR, 0, 1, DESCRIPTION_COLUMN, DESCRIPTION_AVL, "Descriptions", true) < 0)
if (obi_view_add_column(view, DESCRIPTION_COLUMN, -1, OBI_STR, 0, 1, DESCRIPTION_COLUMN, DESCRIPTION_INDEXER, "Descriptions", true) < 0)
{
obidebug(1, "Error adding an obligatory column in a nucleotide sequences view");
return NULL;
@ -696,7 +696,7 @@ int obi_view_add_column(Obiview_p view,
index_t nb_lines,
index_t nb_elements_per_line,
const char* elements_names,
const char* avl_name,
const char* indexer_name,
const char* comments,
bool create) // all infos for creation or open
{
@ -718,7 +718,7 @@ int obi_view_add_column(Obiview_p view,
// Open or create the column
if (create)
{ // Create column
column = obi_create_column(view->dms, column_name, data_type, nb_lines, nb_elements_per_line, elements_names, avl_name, comments);
column = obi_create_column(view->dms, column_name, data_type, nb_lines, nb_elements_per_line, elements_names, indexer_name, comments);
}
else
{ // Open column

View File

@ -37,13 +37,13 @@
#define VIEW_TYPE_NUC_SEQS "NUC_SEQS_VIEW"
#define NUC_SEQUENCE_COLUMN "NUC_SEQ"
#define NUC_SEQUENCE_AVL "NUC_SEQ_AVL"
#define NUC_SEQUENCE_INDEXER "NUC_SEQ_INDEXER"
#define ID_COLUMN "ID"
#define ID_AVL "ID_AVL"
#define ID_INDEXER "ID_INDEXER"
#define DESCRIPTION_COLUMN "DESCRIPTION"
#define DESCRIPTION_AVL "DESCRIPTION_AVL"
#define DESCRIPTION_INDEXER "DESCRIPTION_INDEXER"
#define LINES_COLUMN_NAME "LINES"
@ -162,7 +162,7 @@ int obi_view_add_column(Obiview_p view,
index_t nb_lines,
index_t nb_elements_per_line,
const char* elements_names,
const char* avl_name,
const char* indexer_name,
const char* comments,
bool create);