eccodes
 All Data Structures Namespaces Files Functions Groups Pages
Data Structures | Functions
The indexing feature

Data Structures

struct  codes_index
 

Functions

codes_indexcodes_index_new_from_file (codes_context *c, char *filename, const char *keys, int *err)
 Create a new index form a file. More...
 
codes_indexcodes_index_new (codes_context *c, const char *keys, int *err)
 Create a new index based on a set of keys. More...
 
int codes_index_add_file (grib_index *index, const char *filename)
 Indexes the file given in argument in the index given in argument. More...
 
int codes_index_get_size (codes_index *index, const char *key, size_t *size)
 Get the number of distinct values of the key in argument contained in the index. More...
 
int codes_index_get_long (codes_index *index, const char *key, long *values, size_t *size)
 Get the distinct values of the key in argument contained in the index. More...
 
int codes_index_get_double (codes_index *index, const char *key, double *values, size_t *size)
 Get the distinct values of the key in argument contained in the index. More...
 
int codes_index_get_string (codes_index *index, const char *key, char **values, size_t *size)
 Get the distinct values of the key in argument contained in the index. More...
 
int codes_index_select_long (codes_index *index, const char *key, long value)
 Select the message subset with key==value. More...
 
int codes_index_select_double (codes_index *index, const char *key, double value)
 Select the message subset with key==value. More...
 
int codes_index_select_string (codes_index *index, const char *key, char *value)
 Select the message subset with key==value. More...
 
codes_handlecodes_handle_new_from_index (codes_index *index, int *err)
 Create a new handle from an index after having selected the key values. More...
 
void codes_index_delete (codes_index *index)
 Delete the index. More...
 

Detailed Description

The codes_index is the structure giving indexed access to messages in a file.

Function Documentation

codes_handle* codes_handle_new_from_index ( codes_index index,
int *  err 
)

Create a new handle from an index after having selected the key values.

All the keys belonging to the index must be selected before calling this function. Successive calls to this function will return all the handles compatible with the constraints defined selecting the values of the index keys. When no more handles are available from the index a NULL pointer is returned and the err variable is set to CODES_END_OF_INDEX.

Parameters
index: an index created from a file.
err: 0 if OK, integer value on error. CODES_END_OF_INDEX when no more handles are contained in the index.
Returns
grib handle.
int codes_index_add_file ( grib_index *  index,
const char *  filename 
)

Indexes the file given in argument in the index given in argument.

Parameters
index: index
filename: name of the file of messages to be indexed
Returns
0 if OK, integer value on error
void codes_index_delete ( codes_index index)

Delete the index.

Parameters
index: index to be deleted.
int codes_index_get_double ( codes_index index,
const char *  key,
double *  values,
size_t *  size 
)

Get the distinct values of the key in argument contained in the index.

The key must belong to the index. This function is used when the type of the key was explicitly defined as double or when the native type of the key is double.

Parameters
index: an index created from a file. The index must have been created with the key in argument.
key: key for which the values are returned
values: array of values. The array must be allocated before entering this function and its size must be enough to contain all the values.
size: size of the values array
Returns
0 if OK, integer value on error
int codes_index_get_long ( codes_index index,
const char *  key,
long *  values,
size_t *  size 
)

Get the distinct values of the key in argument contained in the index.

The key must belong to the index. This function is used when the type of the key was explicitly defined as long or when the native type of the key is long.

Parameters
index: an index created from a file. The index must have been created with the key in argument.
key: key for which the values are returned
values: array of values. The array must be allocated before entering this function and its size must be enough to contain all the values.
size: size of the values array
Returns
0 if OK, integer value on error
int codes_index_get_size ( codes_index index,
const char *  key,
size_t *  size 
)

Get the number of distinct values of the key in argument contained in the index.

The key must belong to the index.

Parameters
index: an index created from a file. The index must have been created with the key in argument.
key: key for which the number of values is computed
size: number of distinct values of the key in the index
Returns
0 if OK, integer value on error
int codes_index_get_string ( codes_index index,
const char *  key,
char **  values,
size_t *  size 
)

Get the distinct values of the key in argument contained in the index.

The key must belong to the index. This function is used when the type of the key was explicitly defined as string or when the native type of the key is string.

Parameters
index: an index created from a file. The index must have been created with the key in argument.
key: key for which the values are returned
values: array of values. The array must be allocated before entering this function and its size must be enough to contain all the values.
size: size of the values array
Returns
0 if OK, integer value on error
codes_index* codes_index_new ( codes_context c,
const char *  keys,
int *  err 
)

Create a new index based on a set of keys.

Parameters
c: context (NULL for default context)
keys: comma separated list of keys for the index. The type of the key can be explicitly declared appending :l for long, (or alternatively :i) :d for double, :s for string to the key name. If the type is not declared explicitly, the native type is assumed.
err: 0 if OK, integer value on error
Returns
the newly created index
codes_index* codes_index_new_from_file ( codes_context c,
char *  filename,
const char *  keys,
int *  err 
)

Create a new index form a file.

The file is indexed with the keys in argument.

Parameters
c: context (NULL for default context)
filename: name of the file of messages to be indexed
keys: comma separated list of keys for the index. The type of the key can be explicitly declared appending :l for long, (or alternatively :i) :d for double, :s for string to the key name. If the type is not declared explicitly, the native type is assumed.
err: 0 if OK, integer value on error
Returns
the newly created index
int codes_index_select_double ( codes_index index,
const char *  key,
double  value 
)

Select the message subset with key==value.

The value is a double. The key must have been created with double type or have double as native type if the type was not explicitly defined in the index creation.

Parameters
index: an index created from a file. The index must have been created with the key in argument.
key: key to be selected
value: value of the key to select
Returns
0 if OK, integer value on error
int codes_index_select_long ( codes_index index,
const char *  key,
long  value 
)

Select the message subset with key==value.

The value is a long. The key must have been created with long type or have long as native type if the type was not explicitly defined in the index creation.

Parameters
index: an index created from a file. The index must have been created with the key in argument.
key: key to be selected
value: value of the key to select
Returns
0 if OK, integer value on error
int codes_index_select_string ( codes_index index,
const char *  key,
char *  value 
)

Select the message subset with key==value.

The value is a string. The key must have been created with string type or have string as native type if the type was not explicitly defined in the index creation.

Parameters
index: an index created from a file. The index must have been created with the key in argument.
key: key to be selected
value: value of the key to select
Returns
0 if OK, integer value on error