Load transient (in-memory) classes from an external file. This function has been deprecated in version 7.1. See mco_db_load().
MCO_RET mco_inmem_load( /*IN*/ void *stream_handle,
/*IN*/ mco_stream_read input_stream_reader,
/*IN*/ const char * dbname,
/*IN*/ mco_dictionary_h dict,
/*IN*/ mco_device_t *devices,
/*IN*/ uint2 n_devices,
/*IN*/ mco_db_params_t * db_params );
While
mco_db_load()loads all database objects (both persistent and transient), this function reads the content of only the transient classes. For all-in-memory databases this function is equivalent tomco_db_load(), but for “hybrid” databases this allows the application to load only the transient objects in the database from a previously saved snapshot (seemco_inmem_save()). After loading the transient classes this function opens the database by callingmco_db_open_dev()with the passed parameters.The calling application must provide a stream pointer (a pointer to a file, socket, pipe, etc.) and the address of a function that will perform the reading of the stream of bytes representing the database image. The eXtremeDBruntime will call the given function, passing it the stream pointer, a buffer and the size of the buffer to be read. See the control structure stream_reader for further details. (Also see
mco_inmem_save()).
| MCO_S_OK | The database was closed successfully |
| MCO_E_NOINSTANCE | The specified database is not opened |
Application snippet:
mco_size_sig_t file_reader( void *stream_handle /* FILE * */, /* OUT */void *to, mco_size_t max_nbytes )
{
FILE *f = (FILE *)stream_handle;
mco_size_sig_t nbs;
nbs = fread( to, 1, max_nbytes, f );
return nbs;
}
int main(int argc, char** argv)
{
MCO_RET rc;
sample_memory_t dbmem;
mco_db_h db;
mco_db_params_t db_params;
…
FILE * fbak;
…
rc = mco_inmem_load( (void *)fbak, file_reader, dbname, backupdb_get_dictionary(), dbmem.dev, dbmem.n_dev, &db_params );
fclose( fbak );
sample_rc_check( "\t Load database", rc );
if ( MCO_S_OK == rc )
{
/* Connect to database */
rc = mco_db_connect( dbname, &db );
sample_rc_check( "\t Connect to database", rc );
}
}