Functions to directly retrieve Obiblobs from indexers

This commit is contained in:
Celine Mercier
2016-11-10 14:45:28 +01:00
parent 8f724f4f8e
commit a0ebc2d871
2 changed files with 113 additions and 0 deletions

53
src/obidmscolumn_blob.c Normal file
View File

@ -0,0 +1,53 @@
/****************************************************************************
* OBIDMS_column_blob functions *
****************************************************************************/
/**
* @file obidsmcolumn_blob.c
* @author Celine Mercier
* @date November 9th 2015
* @brief Functions handling OBIColumns containing data in the form of indices referring to Obiblobs, to get blobs directly without decoding.
*/
#include <stdlib.h>
#include <stdio.h>
#include "obidmscolumn.h"
#include "obitypes.h"
#include "obiblob.h"
/**********************************************************************
*
* D E F I N I T I O N O F T H E P U B L I C F U N C T I O N S
*
**********************************************************************/
Obi_blob_p obi_column_get_obiblob_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx)
{
index_t idx;
if (obi_column_prepare_to_get_value(column, line_nb) < 0)
return OBIBlob_NA;
idx = *(((index_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx);
// Check NA
if (idx == OBIIdx_NA)
return OBIBlob_NA;
return obi_indexer_get(column->indexer, idx);
}
Obi_blob_p obi_column_get_obiblob_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name)
{
index_t element_idx = obi_column_get_element_index_from_name(column, element_name);
if (element_idx == OBIIdx_NA)
return OBIBlob_NA;
return obi_column_get_obiblob_with_elt_idx(column, line_nb, element_idx);
}

60
src/obidmscolumn_blob.h Normal file
View File

@ -0,0 +1,60 @@
/****************************************************************************
* OBIDMS_column_blob header file *
****************************************************************************/
/**
* @file obidsmcolumn_blob.h
* @author Celine Mercier
* @date November 9th 2016
* @brief Header file for the functions handling OBIColumns containing data in the form of indices referring to Obiblobs.
*/
#ifndef OBIDMSCOLUMN_BLOB_H_
#define OBIDMSCOLUMN_BLOB_H_
#include <stdlib.h>
#include <stdio.h>
#include "obidmscolumn.h"
#include "obiblob.h"
#include "obitypes.h"
/**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to Obiblobs 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.
* @param element_idx The index of the element that should be recovered in the line.
*
* @returns The recovered value.
* @retval OBIBlob_NA the NA value of the type if an error occurred and obi_errno is set.
*
* @since November 2016
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
Obi_blob_p obi_column_get_obiblob_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx);
/**
* @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
* to Obiblobs 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.
* @param element_name The name of the element that should be recovered in the line.
*
* @returns The recovered value.
* @retval OBIBlob_NA the NA value of the type if an error occurred and obi_errno is set.
*
* @since November 2016
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
Obi_blob_p obi_column_get_obiblob_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name);
#endif /* OBIDMSCOLUMN_BLOB_H_ */