Load an eXtremeDB database.
MCO_RET sample_load_database( /*IN*/ void* stream_handle,
/*IN*/ mco_stream_read input_stream_reader,
/*IN*/ const char * db_name,
/*IN*/ mco_dictionary_h dict,
/*IN*/ mco_size_t db_sz,
/*IN*/ mco_size_t cache_sz,
/*IN*/ uint2 mem_pg_sz,
/*IN*/ uint2 pstorage_pg_sz,
/*IN*/ uint2 max_conn_no,
/*IN*/ sample_memory_t * pdev)
stream_handle
input_stream_reader
db_name
dict
_get_dictionary()).db_sz
cache_sz
mem_pg_sz
pstorage_pg_sz
max_conn_no
pdev
The pointer to the sample_memory_t struct to be initialized:
typedef struct tag_sample_memory
{
unsigned int n_dev;
mco_device_t dev[4];
} sample_memory_t;
This function does the work of creating an in-memory or persistent database by
creating the memory devices, allocating dynamic memory and setting the database
parameters according to the specified arguments. If the stream_handle and
input_stream_reader arguments are non-zero, function
mco_db_load() is called to
load a previously saved image of a database. Otherwise function
mco_db_open_dev() is called
to open the database with the initialized sample_memory_t struct.
(Typically this function is called indirectly by sample applications which instead call
sample_open_database().)
MCO_S_OK
MCO_E_ILLEGAL_PARAM
#include <common.h> #include <simpledb.h> const char * db_name = "simpledb"; ... int main(int argc, char* argv[]) { MCO_RET rc; sample_memory_t dbmem; mco_runtime_start(); rc = sample_load_database( 0, 0, db_name, simpledb_get_dictionary(), DATABASE_SIZE, CACHE_SIZE, MEMORY_PAGE_SIZE, PSTORAGE_PAGE_SIZE, 1, &dbmem ); ... }