?? mco.h
字號:
/*******************************************************************
* *
* mco.h *
* *
* This file is a part of the eXtremeDB source code *
* Copyright (c) 2001-2007 McObject LLC *
* All Rights Reserved *
* *
* eXtremeDB runtime public definitions and static API *
* *
***************************************************************** */
#ifndef MCO_MCO_H__
#define MCO_MCO_H__
#ifdef __cplusplus
extern "C"
{
#endif
//#define MCO_CFG_CHECKLEVEL_1
#include "mcospec.h"
typedef enum MCO_RET_E_ /* return codes */
{
MCO_S_OK = 0, /* success */
MCO_S_BUSY = 1, /* the instance is busy */
MCO_S_NOTFOUND = 10, /* search operation failed */
MCO_S_CURSOR_END = 11, /* cursor cannot be moved */
MCO_S_CURSOR_EMPTY = 12, /* no objects in index */
MCO_S_DUPLICATE = 13, /* index restriction violated */
MCO_S_EVENT_RELEASED = 14, /* waiting thread was released */
MCO_E_INVALID_HANDLE = 51, /* normally invalid handle produces
fatal error. This code returned by special checks. */
MCO_E_NOMEM = 52, /* no memory */
MCO_E_ACCESS = 53, /* trying to use read only transaction for
write */
MCO_E_TRANSACT = 54, /* transaction is in error state */
MCO_E_INDEXLIMIT = 55, /* vector index out of bounds */
MCO_E_EMPTYVECTOREL = 56, /* vector element was not set (at given
index) */
MCO_E_UNSUPPORTED = 57, /* resize vector, blob update etc. */
MCO_E_EMPTYOPTIONAL = 58, /* optional was not set */
MCO_E_EMPTYBLOB = 59, /* trying to read blob, which was not
written */
MCO_E_CURSOR_INVALID = 60, /* cursor is not valid */
MCO_E_ILLEGAL_TYPE = 61, /* search by oid: type is not that was
expected */
MCO_E_ILLEGAL_PARAM = 62, /* e.g. illegal search operation code */
MCO_E_CURSOR_MISMATCH = 63, /* cursor type and object type are
incompatible */
MCO_E_DELETED = 65, /* trying to update object, deleted in current
transaction */
MCO_E_LONG_TRANSACTON = 66, /* transaction length is more then
MCO_TRN_MAXLENGTH */
MCO_E_INSTANCE_DUPLICATE = 67, /* attempt to create db instance
with duplicate name */
MCO_E_UPGRADE_FAILED = 68, /* simultaneous upgrades may not be not
possible */
MCO_E_NOINSTANCE = 69, /* db instance not found */
MCO_E_OPENED_SESSIONS = 70, /* failed to close db: have opened
sessions */
MCO_E_PAGESIZE = 71, /* page size is not acceptable */
MCO_E_WRITE_STREAM = 75, /* write stream failure */
MCO_E_READ_STREAM = 76, /* read stream failure */
MCO_E_LOAD_DICT = 77, /* db load: dictionary differs */
MCO_E_LOAD_DATA = 78, /* error data when loading db */
MCO_E_VERS_MISMATCH = 79, /* version mismatch */
MCO_E_VOLUNTARY_NOT_EXIST = 80, /* voluntary index is not created
*/
MCO_E_EXCLUSIVE_MODE = 81, /* db is in the exclusive mode; try
later */
MCO_E_MAXEXTENDS = 82, /* maximum number of extends reached */
MCO_E_HIST_OBJECT = 83, /* operation is illegal for old version of
the object */
MCO_E_SHM_ERROR = 84, /* failed to create/attach to shared memory
*/
MCO_E_NOTINIT = 85, /* runtime was not initialized */
MCO_E_SESLIMIT = 86, /* sessions number limit reached */
MCO_E_INSTANCES_LIMIT = 87, /* too many instances */
MCO_E_MAXTRANSSIZE_LOCKED = 88, /* the maximum size of transaction
cannot be changed */
MCO_E_2PHASECOMMIT = 89, /* 2-phase commit is in progress */
MCO_E_ALIGN_ERROR = 90, /* data alignment <> 8 */
MCO_E_NOUSERDEF_FUNCS = 91, /* DB has userdef indexes, but custom
functions not registered */
MCO_E_SHARED_COMMIT = 92, /* shared commit recovery error,
reconnection required */
MCO_E_UNLINK_ERROR = 93, /* unlink(sem_file) return some error, other then ENOENT */
MCO_E_EVAL = 100, /* evaluation version limitaion */
MCO_E_HA = 200, /* HA base error code */
MCO_E_HAFRAMEWORK = 250, /* HAFRAMEWORK base error code */
MCO_E_LOG = 500 /* LOG base error code */
} MCO_RET; /* return code */
#define mco_trans_size 20 /* max number of updated or deleted
objects in one transaction */
#ifdef MCO_PLATFORM_X64
#define mco_min_page_size 144 /* min size of a page */
#ifndef MCO_CFG_RTREE_SUPPORT
#define mco_cursor_size 144 /* cursor structure size */
#else
#define mco_cursor_size 176 /* cursor structure size */
#endif // MCO_CFG_RTREE_SUPPORT
// #define mco_cursor_size 144 /* cursor structure size */
#define mco_handle_size 48 /* object handle size */
#else //MCO_PLATFORM_X64
#define mco_min_page_size 64 /* min size of a page */
#ifndef MCO_CFG_RTREE_SUPPORT
#define mco_cursor_size 56 /* cursor structure size */
#else
#define mco_cursor_size 92 /* cursor structure size */
#endif // MCO_CFG_RTREE_SUPPORT
#define mco_handle_size 24 /* object handle size */
#endif //MCO_PLATFORM_X64
#define mco_handle_size_w ( mco_handle_size / sizeof(void *) )
#define mco_cursor_size_w ( mco_cursor_size / sizeof(void *) )
typedef void* MCO_Hf[mco_handle_size_w];
typedef struct mco_cursor_t_
{
void* c[mco_cursor_size_w];
} mco_cursor_t, /* cursor (structure) */
*mco_cursor_h; /* cursor handle (pointer) */
#ifdef MCO_NO_FORWARDS
typedef void* mco_trans_h;
typedef void* mco_db_h;
typedef void* mco_dictionary_h;
#else
struct mco_trans_t_;
typedef struct mco_trans_t_* mco_trans_h; /* transaction handle
(pointer) */
struct mco_db_t_;
typedef struct mco_db_t_* mco_db_h; /* database handle (pointer)
*/
struct mco_dictionary_t_;
typedef struct mco_dictionary_t_* mco_dictionary_h; /* dictionary
handle (pointer) */
#endif
/* transaction priority values */
typedef enum MCO_TRANS_PRIORITY_E_
{
MCO_TRANS_IDLE = 1, MCO_TRANS_BACKGROUND = 2, MCO_TRANS_FOREGROUND = 3, MCO_TRANS_HIGH = 4, MCO_TRANS_ISR =
77
} MCO_TRANS_PRIORITY;
/* transaction types values */
typedef enum MCO_TRANS_TYPE_E_
{
MCO_READ_ONLY = 0, MCO_READ_WRITE = 1
} MCO_TRANS_TYPE;
/* Database management */
/* sets the new maximum size of the transaction. MUST be called after
mco_runtime_start() and before mco_db_open (...) */
MCO_RET mco_set_maxtranssize(uint4);
MCO_RET mco_runtime_start(void);
MCO_RET mco_runtime_stop(void);
MCO_RET mco_close_all_instances(void); /* for multiprocessing only */
MCO_RET mco_db_databases(char* lpBuffer, int buffer_size, int skip_first);
/* depending on configuration,
database is created in process's memory (address is specified),
or in shared memory (in this case shared memory is acquired
by database, and address used as "hint"; db_name used to construct shared memory id)
*/
MCO_RET mco_db_open(const char* db_name, mco_dictionary_h dict, void* mem_ptr, mco_puint total_size, uint2
page_size);
/* extend cannot be called in shared memory mode */
MCO_RET mco_db_extend(const char* db_name, void* mem_ptr, mco_puint size);
/* remove all objects from database */
MCO_RET mco_db_clean(mco_db_h db);
MCO_RET mco_db_close(const char* db_name);
MCO_RET mco_db_kill(const char* db_name);
MCO_RET mco_db_connect(const char* dbname, /*OUT*/mco_db_h* pdb);
MCO_RET mco_db_disconnect(mco_db_h db);
MCO_RET mco_db_free_pages(mco_db_h db, /*OUT*/mco_puint* retvalue);
MCO_RET mco_db_total_pages(mco_db_h db, /*OUT*/mco_puint* retvalue);
MCO_RET mco_db_page_size(mco_db_h db, /*OUT*/uint2* retvalue);
MCO_RET mco_db_check_memory(mco_db_h db);
/* #define MCO_HASH_HUGE */
typedef int2(*mco_compare_userdef_f)(MCO_Hf* obj1, MCO_Hf* obj2);
typedef int2(*mco_compare_extkey_userdef_f)(MCO_Hf* obj1, void* key);
/* Vector-based version: */
typedef int2(*mco_compare_userdef_vb_f)(MCO_Hf* obj1, int index1, MCO_Hf* obj2, int index2);
typedef int2(*mco_compare_extkey_userdef_vb_f)(MCO_Hf* obj1, int index1, void* key);
#ifdef MCO_HASH_HUGE
typedef uint8(*mco_hash_userdef_f)(MCO_Hf* obj);
typedef uint8(*mco_hash_extkey_userdef_f)(void* key);
/* Vector-based version: */
typedef uint8(*mco_hash_userdef_vb_f)(MCO_Hf* obj, int index);
#else
typedef uint4(*mco_hash_userdef_f)(MCO_Hf* obj);
typedef uint4(*mco_hash_extkey_userdef_f)(void* key);
/* Vector-based version: */
typedef uint4(*mco_hash_userdef_vb_f)(MCO_Hf* obj, int index);
#endif
struct mco_userdef_funcs_t_
{
union
{
mco_compare_userdef_f nvb;
mco_compare_userdef_vb_f vb;
} fcomp;
union
{
mco_compare_extkey_userdef_f nvb;
mco_compare_extkey_userdef_vb_f vb;
} fcomp_ext;
union
{
mco_hash_userdef_f nvb;
mco_hash_userdef_vb_f vb;
} fhash;
mco_hash_extkey_userdef_f fhash_ext;
};
typedef struct mco_userdef_funcs_t_ mco_userdef_funcs_t;
typedef struct mco_userdef_funcs_t_* mco_userdef_funcs_h;
MCO_RET mco_db_register_udf(const char* db_name, mco_userdef_funcs_h udfs);
/* Transaction management */
MCO_RET mco_trans_start(mco_db_h db, MCO_TRANS_TYPE type, MCO_TRANS_PRIORITY pri, /*OUT*/mco_trans_h* p_trans);
MCO_RET mco_trans_upgrade(mco_trans_h t);
MCO_RET mco_trans_commit(mco_trans_h t);
MCO_RET mco_trans_rollback(mco_trans_h t);
MCO_RET mco_trans_type(mco_trans_h t, /*OUT*/MCO_TRANS_TYPE* type);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -