obiblob_indexer.c 1.52 KB
Newer Older
Celine Mercier's avatar
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's avatar
Celine Mercier committed
20 21


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


Celine Mercier's avatar
Celine Mercier committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38
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);

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

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;
}