MemCom Reference Manual > MemCom C API Manual Pages > Database Manager Functions > mcDBgetSetslice

Name

mcDBgetSetslice, mcDBgetSetsliceArray — Read a slice of a dataset

Synopsis

#include <memcom.h>

void* mcDBgetSetslice(int handle, const char* name, int nsdim,
                      const mcSlice* sl, int ndim, const mcOff* dim);

int mcDBgetSetsliceArray(int handle, const char* name, int nsdim,
                         const mcSlice* sl, int ndim,
                         const mcOff* dim, void* buffer);

Description

mcDBgetSetslice retrieves a slice of a dataset from a database. If completed successfully, the function returns a pointer to a new array containing the requested data. Otherwise, NULL is returned and the error code can be retrieved by the function mcErrStatus. mcDBgetSetsliceArray retrieves a slice of a dataset from a database to a pre-allocated array in memory. If completed successfully, the function returns 0. Otherwise, a negative value indicating the MemCom error number is returned.

It is strongly advised to free data allocated with mcDBgetSet by means of the mcDBfree. Note that relational tables must be freed by means of mcTBfree.

A slice has a number of dimensions which is between 1 and the number of dimensions of the dataset. For each dimension, the start and end position, as well as the position increment (step) define the slice.

Parameters

handle

Database handle (input).

name

Dataset name (input).

nsdim

Number of slice dimensions (input).

sl

Pointer to array of slices (input). The size of the array must be equal to nsdim. Each slice contains the start index, end index, and step for the dimension. The start index indicates the starting position (beginning from 1), the end index indicates the last position. The step is the increment of the index between start and end.

ndim

Number of dimensions of the dataset (input). If this parameter is set to 0, the actual dimensions of the dataset are taken, and the parameter dim is ignored. If ndim is non-zero, then the dataset dimensions are assumed to be as indicated by ndim and dim.

dim

Pointer to dimension array (input). If ndim is 0, this argument is ignored. Otherwise the size of the array must be equal to ndim and re-defines the dimensions of the dataset for this operation.

buffer

Pointer to memory region where the data should be copied to (output).

See also

mcDBgetSubset, mcDBgetSetpos, mcDBgetSetslice, mcDBfree, mcDBputSetslice