obiblob_indexer.c 1.73 KB
Newer Older
Celine Mercier committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/****************************************************************************
 * 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"
18 19
#include "obierrno.h"
#include "obidebug.h"
Celine Mercier committed
20 21


22 23 24
#define DEBUG_LEVEL 0	// TODO has to be defined somewhere else (cython compil flag?)


25
static inline int obi_indexer_exists(OBIDMS_p dms, const char* name);
Celine Mercier committed
26

27
static inline Obi_indexer_p obi_indexer(OBIDMS_p dms, const char* name);
Celine Mercier committed
28

29
static inline Obi_indexer_p obi_create_indexer(OBIDMS_p dms, const char* name);
Celine Mercier committed
30

31
static inline Obi_indexer_p obi_open_indexer(OBIDMS_p dms, const char* name);
Celine Mercier committed
32

33
static inline Obi_indexer_p obi_clone_indexer(Obi_indexer_p indexer, const char* name);
34

35
static inline int obi_close_indexer(Obi_indexer_p indexer);
Celine Mercier committed
36

37
static inline index_t obi_indexer_add(Obi_indexer_p indexer, Obi_blob_p value);
Celine Mercier committed
38

39
static inline Obi_blob_p obi_indexer_get(Obi_indexer_p indexer, index_t idx);
Celine Mercier committed
40

41
static inline const char* obi_indexer_get_name(Obi_indexer_p indexer);
42

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

char* obi_build_indexer_name(const char* column_name, obiversion_t column_version)
{
	char* indexer_name;

	indexer_name = (char*) malloc(INDEXER_MAX_NAME * sizeof(char));
	if (indexer_name == NULL)
	{
		obi_set_errno(OBI_MALLOC_ERROR);
		obidebug(1, "\nError allocating the memory for an indexer name");
		return NULL;
	}

	strcpy(indexer_name, column_name);
	sprintf(indexer_name+strlen(column_name), "_%d_indexer", column_version);

	return indexer_name;
}