Example #1
0
File: clist.c Project: okayman/ebgn
void clist_free_with_modi(CLIST *clist, const UINT32 modi)
{
    clist_clean_with_modi(clist, modi, clist->data_free);

    CLIST_CLEAN_LOCK(clist, LOC_CLIST_0005);
    SAFE_CLIST_FREE(clist, LOC_CLIST_0006);
    return;
}
Example #2
0
void test_case_cscore_005(const UINT32 cscore_md_id)
{
    void *csdoc_words_1;
    void *csdoc_words_2;
    void *csdoc_words_3;
    void *csdoc_words_list;
    void *csword_list;
    void *csdoc_list;
    void *csdoc;

    csdoc_words_list = clist_new(MM_CSDOC_WORDS, 0);
    ASSERT(NULL_PTR != csdoc_words_list);

    /*make csdoc_words_1 = {doc={1001,1002,1003}, words={pepople, republic, of, china}}*/
    csdoc_words_1 = cscore_csdoc_words_new(cscore_md_id);
    ASSERT(NULL_PTR != csdoc_words_1);
    csdoc = (void *)cscore_csdoc_words_get_doc(cscore_md_id, csdoc_words_1);
    __test_case_cscore_csdoc_set_doc(cscore_md_id, csdoc, 1001, 1002, 1003);
    __test_case_cscore_csdoc_words_add_words(cscore_md_id, csdoc_words_1, 4, (UINT8 *)"pepole", (UINT8 *)"republic", (UINT8 *)"of", (UINT8 *)"china");
    clist_push_back(csdoc_words_list, (void *)csdoc_words_1);

    /*make csdoc_words_2 = {doc={1101,1002,1003}, words={pepople, working, hard}}*/
    csdoc_words_2 = cscore_csdoc_words_new(cscore_md_id);
    ASSERT(NULL_PTR != csdoc_words_2);    
    csdoc = (void *)cscore_csdoc_words_get_doc(cscore_md_id, csdoc_words_2);
    __test_case_cscore_csdoc_set_doc(cscore_md_id, csdoc, 1101, 1002, 1003);
    __test_case_cscore_csdoc_words_add_words(cscore_md_id, csdoc_words_2, 3, (UINT8 *)"pepole", (UINT8 *)"working", (UINT8 *)"hard");
    clist_push_back(csdoc_words_list, (void *)csdoc_words_2);

    /*make csdoc_words_3 = {doc={1101,1002,1003}, words={pepople, living, happ}}*/
    csdoc_words_3 = cscore_csdoc_words_new(cscore_md_id);
    ASSERT(NULL_PTR != csdoc_words_3);    
    csdoc = (void *)cscore_csdoc_words_get_doc(cscore_md_id, csdoc_words_3);
    __test_case_cscore_csdoc_set_doc(cscore_md_id, csdoc, 1011, 1002, 1003);
    __test_case_cscore_csdoc_words_add_words(cscore_md_id, csdoc_words_3, 3, (UINT8 *)"pepole", (UINT8 *)"living", (UINT8 *)"happy");
    clist_push_back(csdoc_words_list, (void *)csdoc_words_3);

    /*import csdoc_words_1 into bigtable*/
    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_005: import beg\n");
    ASSERT(EC_TRUE == cscore_csdoc_words_list_import(cscore_md_id, csdoc_words_list));
    clist_free_with_modi(csdoc_words_list, cscore_md_id);
    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_005: import end\n");

    /*make csword_list ready*/
    csword_list = clist_new(MM_CSWORD, 0);
    ASSERT(NULL_PTR != csword_list);
    __test_case_cscore_csword_list_add_word(cscore_md_id, csword_list, (UINT8 *)"pepole");
    __test_case_cscore_csword_list_add_word(cscore_md_id, csword_list, (UINT8 *)"china");

    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_005: csword_list is:\n");
    clist_print(LOGSTDOUT, csword_list, cscore_csword_print);

    /*make csdoc_list ready*/
    csdoc_list = clist_new(MM_CSDOC, 0);
    ASSERT(NULL_PTR != csdoc_list);    

    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_005: export beg\n");
    ASSERT(EC_TRUE == cscore_csword_docs_list_export_docs(cscore_md_id, CBGT_SELECT_FROM_ALL_TABLE, csword_list, csdoc_list));
    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_005: export end\n");
    dbg_log(SEC_0137_DEMO, 9)(LOGSTDOUT, "[DEBUG] test_case_cscore_005: export result:\n");
    clist_print(LOGSTDOUT, csdoc_list, (CLIST_DATA_DATA_PRINT)cscore_csdoc_print);

    clist_clean_with_modi(csword_list, cscore_md_id, (CLIST_DATA_MODI_HANDLER)cscore_csword_free);
    clist_clean_with_modi(csdoc_list, cscore_md_id, (CLIST_DATA_MODI_HANDLER)cscore_csdoc_free);

    clist_free(csword_list, 0);
    clist_free(csdoc_list, 0);    

    return;
}
Example #3
0
File: clist.c Project: okayman/ebgn
UINT32 clist_clean_0(const UINT32 modi, CLIST *clist)
{
    /*seems it is quite NOT necessary to clean codec setting! but if set, we may be in greate trouble*/
    clist_clean_with_modi(clist, modi, clist->data_free);
    return (0);
}