Load database files from persistent storage. This function has been deprecated in version 7.1. See mco_db_load().
MCO_RET mco_disk_load_file(/*IN*/ char const *file_path,
/*IN*/ void *stream_handle,
/*IN*/ mco_stream_read input_stream_reader,
/*IN*/ mco_dictionary_h dict);
file_path
stream_handle
input_stream_reader
dict
This function loads eXtremeDB database files from persistent storage. It must be called before
mco_db_open_dev(), but once the database is loaded, it is necessary for the application to then callmco_db_open_dev()to open it.The argument
file_pathspecifies the file to load from for "single-file" databases. However if the database is "multifile" or "raid" the file path identifies a "database description file" which must have extension ".mfd". (A single-file database may also be described as single segment multifile through the database description file.)Whereas
mco_disk_load()gets the necessary file information from themco_device_tstructures passed to it,mco_disk_load_file()reads the same information from the database description file (*.mfd). The format for a database description file is as follows:
number_of_segments type_of_storage
size_of_segment path_to_database_file
(this line repeats for each segment)
Where:
number_of_segments
mco_device_t elements passed to mco_db_open_dev()
with assignment = MCO_MEMORY_ASSIGN_PERSISTENT.type_of_storage
type of structure mco_device_t passed
to mco_db_open_dev().size_of_segments
segment_size of structure mco_device_t passed
to mco_db_open_dev(). The actual file size in Megabytes for multifile type, zero for raids.path_to_database_file
MCO_S_OK
MCO_E_NOINSTANCE
const char *db_name = "backupdb";
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;
mco_db_h db;
mco_device_t dev[4];
mco_db_params_t db_params;
...
char *mdf_file = "Multifile.mdf";
...
rc = mco_disk_load_file(mdf_file, file_reader, backupdb_get_dictionary());
sample_rc_check("\t Load database file", rc);
rc = mco_db_open_dev(dbname, backupdb_get_dictionary(), dev, sizeof(dev) / sizeof(dev[0]), &db_params);
if (MCO_S_OK == rc)
{
/* Connect to database */
rc = mco_db_connect(dbname, &db);
sample_rc_check("\t Connect to database", rc);
}
}
The example database description file "Multifile.mdf" could be one of the following:
Example 1: (describes a 3-segment raid1 database):
3 raid1
0 dbtest.dbs0
0 dbtest.dbs1
0 dbtest.dbs2
Example 2: (describes a 3-segment multifile database):
3 multifile
2048 dbtest.dbs0
1024 dbtest.dbs1
2048 dbtest.dbs2
Example 3: (describes a single-file database):
1 multifile
2048 dbtest.dbs0