1 #ifndef __CMPH_SELECT_H__ 2 #define __CMPH_SELECT_H__ 3 4 #include "cmph_types.h" 5 6 struct _select_t 7 { 8 cmph_uint32 n,m; 9 cmph_uint32 * bits_vec; 10 cmph_uint32 * select_table; 11 }; 12 13 typedef struct _select_t select_t; 14 15 void select_init(select_t * sel); 16 17 void select_destroy(select_t * sel); 18 19 void select_generate(select_t * sel, cmph_uint32 * keys_vec, cmph_uint32 n, cmph_uint32 m); 20 21 cmph_uint32 select_query(select_t * sel, cmph_uint32 one_idx); 22 23 cmph_uint32 select_next_query(select_t * sel, cmph_uint32 vec_bit_idx); 24 25 cmph_uint32 select_get_space_usage(select_t * sel); 26 27 void select_dump(select_t *sel, char **buf, cmph_uint32 *buflen); 28 29 void select_load(select_t * sel, const char *buf, cmph_uint32 buflen); 30 31 32 /** \fn void select_pack(select_t *sel, void *sel_packed); 33 * \brief Support the ability to pack a select structure into a preallocated contiguous memory space pointed by sel_packed. 34 * \param sel points to the select structure 35 * \param sel_packed pointer to the contiguous memory area used to store the select structure. The size of sel_packed must be at least @see select_packed_size 36 */ 37 void select_pack(select_t *sel, void *sel_packed); 38 39 /** \fn cmph_uint32 select_packed_size(select_t *sel); 40 * \brief Return the amount of space needed to pack a select structure. 41 * \return the size of the packed select structure or zero for failures 42 */ 43 cmph_uint32 select_packed_size(select_t *sel); 44 45 46 /** \fn cmph_uint32 select_query_packed(void * sel_packed, cmph_uint32 one_idx); 47 * \param sel_packed is a pointer to a contiguous memory area 48 * \param one_idx is the rank for which we want to calculate the inverse function select 49 * \return an integer that represents the select value of rank idx. 50 */ 51 cmph_uint32 select_query_packed(void * sel_packed, cmph_uint32 one_idx); 52 53 54 /** \fn cmph_uint32 select_next_query_packed(void * sel_packed, cmph_uint32 vec_bit_idx); 55 * \param sel_packed is a pointer to a contiguous memory area 56 * \param vec_bit_idx is a value prior computed by @see select_query_packed 57 * \return an integer that represents the next select value greater than @see vec_bit_idx. 58 */ 59 cmph_uint32 select_next_query_packed(void * sel_packed, cmph_uint32 vec_bit_idx); 60 61 #endif 62