示例#1
0
void test_mtree(){
    MTree* tree = mtree_create(4, 4, false, NULL);
    for (uintptr_t i = 1; i < 10; i++) {
        mtree_insert(tree, i, (void*)i);
    }
    mtree_dump(tree);
    Document* a[20];
    Cursor* c = mtree_cursor(tree);
    cursor_to_array(c, a, 20);
    char msg[30];
    for (uintptr_t i = 1; i < 10; i++) {
        sprintf(msg, "a[%lu] == %lu", i - 1, i);
        sput_fail_unless(a[i - 1] == (Document*)i, msg);
    }
}
示例#2
0
文件: wtable.c 项目: Maxlander/ipush
/* wtable app auth */
int wtable_app_auth(WTABLE *w, int wid, char *appkey, int len, int conn_id, int64_t last_time)
{
    int mid = 0, msgid = 0, appid = 0;
    int64_t time = 0;

    if(w && appkey && len > 0 && (appid = mmtrie_get(w->map, appkey, len)) > 0)     
    {
        mtree_insert(w->workers[wid].map, appid, conn_id, wid, NULL);
        //REALLOG(w->logger, "workers[%d] app[%.*s][%d][%d] qtotal:%p/%d", wid, len, appkey, appid, conn_id, w->workers[wid].map, mtree_total(w->workers[wid].map, appid));
        mid = mmtree64_max(w->appmap, appid, &time, &msgid);
        while(mid && time > last_time && msgid > 0)
        {
            //REALLOG(w->logger, "workers[%d] time:%lld last_time:%lld msgid:%d", wid, time, last_time, msgid)
            mqueue_push(w->workers[wid].queue,w->workers[wid].q[conn_id],msgid);
            time = 0; msgid = 0;
            mid = mmtree64_prev(w->appmap, appid, mid, &time, &msgid);
        }
    }
    return appid;
}