⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mco.h

📁 PB 熟悉的哥们希望大家可以互相学习一下
💻 H
📖 第 1 页 / 共 2 页
字号:
        MCO_RET mco_get_last_error(mco_trans_h t);
        MCO_RET mco_trans_commit_phase1(mco_trans_h t);
        MCO_RET mco_trans_commit_phase2(mco_trans_h t);

        /* Cursor-based */
        typedef enum MCO_OPCODE_E_
        {
            MCO_LT = 1, MCO_LE = 2, MCO_EQ = 3, MCO_GE = 4, MCO_GT = 5, MCO_EX = 6, MCO_BEST = 7, MCO_PREF = 8,
                MCO_OVERLAP = 9, MCO_CONTAIN = 10
        } MCO_OPCODE;


        /* cursor navigation */


        MCO_RET mco_cursor_check(mco_trans_h t, mco_cursor_h c);
        MCO_RET mco_cursor_first(mco_trans_h t,  /*INOUT*/mco_cursor_h c);
        MCO_RET mco_cursor_last(mco_trans_h t,  /*INOUT*/mco_cursor_h c);
        MCO_RET mco_cursor_next(mco_trans_h t,  /*INOUT*/mco_cursor_h c);
        MCO_RET mco_cursor_prev(mco_trans_h t,  /*INOUT*/mco_cursor_h c);

        /* cursor types */
        typedef enum MCO_CURSOR_TYPE_E_
        {
            MCO_LIST_CURSOR = 0, MCO_TREE_CURSOR = 1, MCO_HASH_CURSOR = 2, MCO_PATRICIA_CURSOR = 3, MCO_RTREE_CURSOR = 4
        } MCO_CURSOR_TYPE;


        MCO_RET mco_cursor_type(mco_cursor_h c,  /*OUT*/MCO_CURSOR_TYPE* type);
        MCO_RET mco_cursor_get_class_code(mco_cursor_h c,  /*OUT*/uint2* rescode);



        /* statistics */

        /* statistics for a class, index pages are not counted here */
        typedef struct mco_class_stat_t_
        {
            mco_puint objects_num;
            mco_puint core_space; /* in bytes, not counting blobs */
            uint4 core_pages; /* pages used for all data except blobs */
            uint4 blob_pages; /* pages used by blobs */
        } mco_class_stat_t, * mco_class_stat_h;


        MCO_RET mco_class_stat_get(mco_trans_h t, uint2 class_code,  /*OUT*/mco_class_stat_h stat);


        /* unrecoverable error handler */

        typedef void(*mco_error_handler_f)(int errcode);
        void mco_error_set_handler(mco_error_handler_f f);

        /* depending on configuration, extended information (file, line) may be available */
        /* if both handlers are defined, extended is called first */
        typedef void(*mco_error_handler_f_ex)(int errcode, const char* file, int line);
        void mco_error_set_handler_ex(mco_error_handler_f_ex f);

        /* Heap memory manager */

        #ifdef MCO_NO_FORWARDS
            typedef void* mco_heap_h;
        #else 
            struct mco_heap_head_t_; /* heap header */
            typedef struct mco_heap_head_t_* mco_heap_h;
        #endif 

        int mco_heap_head_size(void); /* size in bytes required by heap header
         */
        void mco_heap_init(void* memoryptr, uint4 heapsize /* 2 ** N */,  /*INOUT*/mco_heap_h h, 
        /* caller must allocate heap head */
        char* name);
        void mco_heap_destroy(mco_heap_h h); /* releasing semaphore  */
        uint4 mco_heap_freesize(mco_heap_h h); /* free bytes estimated */
        uint4 mco_heap_usedsize(mco_heap_h h); /* used bytes estimated */

        void* mco_malloc(mco_heap_h h, uint4 nbt);
        void* mco_calloc(mco_heap_h h, uint4 num, uint4 siz);
        void mco_free(mco_heap_h h, void* p);
        void* mco_realloc(mco_heap_h h, void* p, uint4 newsize);

        /* save/restore */

        /* abstract write and read streams interfaces; stream handle is a pointer to implementation-specific data */
        typedef int(*mco_stream_write)(void* stream_handle, const void* from, unsigned nbytes);
        typedef int(*mco_stream_read)(void* stream_handle,  /*OUT*/void* to, unsigned max_nbytes);

        /* save db content to output stream */
        MCO_RET mco_db_save(void* stream_handle, mco_stream_write output_stream_writer, mco_db_h db);

        /* create db instance and load content from input stream - instead of mco_db_open() */
        MCO_RET mco_db_load(void* stream_handle, mco_stream_read input_stream_reader, const char* db_name,
                            mco_dictionary_h dict, void* mem_ptr, mco_puint total_size);

        /* multi-segment memory variant of mco_db_load */
        MCO_RET mco_db_load_ms(void* stream_handle, mco_stream_read input_stream_reader, const char* db_name,
                               mco_dictionary_h dict, uint2 n_segments, void* const* mem_segments,  /*
                               vector[n_segments] of
        pointers to memory segments */
        const mco_puint* segment_sizes); /* vector[n_segments] of sizes of
        memory segments    */


        /* event handling */

        /* synchronous events: */

        typedef enum MCO_EVENT_TYPE_E_
        {
            MCO_EVENT_NEW, MCO_EVENT_UPDATE, MCO_EVENT_DELETE, MCO_EVENT_DELETE_ALL
        } MCO_EVENT_TYPE;


        typedef enum MCO_HANDLING_ORDER_E_
        {
            MCO_BEFORE_UPDATE, MCO_AFTER_UPDATE
        } MCO_HANDLING_ORDER;

        /* asynchronous events, handlers in different threads are signaled after commit: */

        MCO_RET mco_async_event_wait(mco_db_h dbh, int event_id);
        MCO_RET mco_async_event_release(mco_db_h dbh, int event_id);
        MCO_RET mco_async_event_release_all(mco_db_h dbh);

        /* boolean type */
        typedef int mco_bool;
        #define MCO_YES 1
        #define MCO_NO  0

        typedef struct mco_runtime_info_t_
        {
            uint1 mco_version_major;
            uint1 mco_version_minor;
            uint2 mco_build_number;
            /* Core configuration parameters: */
            uint1 mco_checklevel;
            uint1 mco_multithreaded;
            uint1 mco_shm_supported;
            uint1 mco_fixedrec_supported;
            uint1 mco_xml_supported;
            uint1 mco_stat_supported;
            uint1 mco_events_supported;
            uint1 mco_versioning_supported;
            uint1 mco_save_load_supported;
            uint1 mco_synch_native_supported;

            uint1 mco_evaluation_version;
            uint1 mco_recovery_supported;
            uint1 mco_rtree_supported;
            /* unicode */
            uint1 mco_unicode_supported;
            uint1 mco_wchar_supported;

            /* RTL*/
            uint1 mco_rtl_supported; // true is C runtime is linked-in
            /* LOG */
            uint1 mco_log_supported;
            /* SQL */
            uint1 mco_sql_supported;
            /* HA- related configuration */
            uint1 mco_ha_supported;
            uint1 mco_asynch_replication_supported;
            uint1 mco_hotsynch_supported;
            uint1 mco_2phasecommit_supported;
            uint1 mco_reserved1;
            uint2 mco_reserved2;
        } mco_runtime_info_t;


        /* obtain eXtremeDB runtime configuration info: */
        void mco_get_runtime_info( /*OUT*/mco_runtime_info_t* pinf);


        #define MCO_REPORT_OID          1
        #define MCO_REPORT_LIST         2
        #define MCO_REPORT_TREE         4
        #define MCO_REPORT_HASH         8
        #define MCO_REPORT_LIST_TOTAL  16
        #define MCO_REPORT_TREE_TOTAL  32
        #define MCO_REPORT_HASH_TOTAL  64
        #define MCO_REPORT_DB_TOTAL   128
        #define MCO_REPORT_AUTO_OID   256
        #define MCO_REPORT_DB_ALL     511


        typedef struct mco_report_item_t_
        {
            mco_puint objects_num;
            mco_puint used_pages;
            uint4 flag; /* one of MCO_REPORT_... */
            uint4 id;
            uint2 tree_height;
            const char* name; /* only in debug mode */
        } mco_report_item_t, * mco_report_item_h;

        MCO_RET mco_db_report(mco_db_h db, uint4 flags,  /* mask of
        MCO_REPORT_...       */
         /*OUT*/mco_report_item_h items, int max_items,  /*OUT*/int* num_items 
        /* returns num of filled items  */
        );


        typedef struct mco_dbconnection_param_t_
        {
            uint4 task_id;
            void* user_data;
            int(*check_task_is_alive)(uint4 task_id, void* user_data);
            int flags; /* MCO_CONN_F_...  */
        } mco_dbconnection_param_t;

        MCO_RET mco_db_connect_rs(const char* dbname, const mco_dbconnection_param_t* params,  /*OUT*/mco_db_h* pdb);

        MCO_RET mco_db_check_connections(mco_db_h db); /* explicit call to
        clean dead connections */

        /* checks database resources and recovers if needed.
        The function is called from the separate thread by the amount of time.
         */
        int mco_db_check_resources(const char* dbname,  // database name
        mco_db_h* pdb,  // datavase handler
        int loopcountm,  // watch loop counter (optional)
        unsigned* wdt_state  //  pointer to local watchdog state flags
        );

        /*
        Connects to the database, checks and recovers the database unconditionally
         */
        MCO_RET mco_db_connect_and_recover(const char* dbname, mco_db_h* pdb, const mco_dbconnection_param_t* params);

        /* changing global options, per process */
        void mco_runtime_setoption(int option, int value);
        int mco_runtime_getoption(int option);

        #define MCO_RT_OPTION_RESERVED    20
        #define MCO_RT_OPTION_MUTEX_N0    21
        #define MCO_RT_OPTION_MUTEX_N2    22
        #define MCO_RT_OPTION_MUTEX_T0    23
        #define MCO_RT_OPTION_ZMUTEX_T0   24
        #define MCO_RT_OPTION_ZMUTEX_NR1  25
        #define MCO_RT_OPTION_LAST        26

        typedef long timer_unit; // what is it, does not matter, just timers, 
        // timeouts, stream parameters are measured in the same units.

        #define MCO_TM_INFINITE ((timer_unit)-1)

        timer_unit mco_system_get_current_time();

        /* return returns MCO_YES if the handles point to the same object */
        mco_bool mco_objects_eq(void* p1, void* p2);

        /* direct structs helpers */
        #define  structsz(n)    ((unsigned int)sizeof(n))
        #define  fieldsz(s,f)   ((unsigned int)sizeof(((s*)0)->f))
        #define  fieldoffs(s,f) ((unsigned int)(&((s*)0)->f))

        #ifdef __cplusplus
        }
    #endif 


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -