コード例 #1
0
ファイル: rcv_test_tr.cpp プロジェクト: sedna/sedna
static
void test_collection(const char *name, col_schema_node_cptr coll)
{
    bt_key key;
    key.setnew(" ");
    bt_cursor cursor = bt_find_gt(coll->metadata, key);

    if (cursor.is_null()) return;

    do
    {
        key = cursor.get_key();
        try
        {
            test_document((char*)key.data(), indirectionDereferenceCP(cursor.bt_next_obj()), true);
            fprintf(logfile, "Checked collection: %s, document: %s\n", name, (char*)key.data());
        }
        catch(SednaException &e)
        {
            elog(EL_ERROR, ("Recovery failed on collection: %s, document: %s, error: %s\n", name, (char*)key.data(), e.what()));
            fprintf(logfile, "Recovery failed on collection: %s, document: %s, error: %s\n", name, (char*)key.data(), e.what());
            isRcvOK = false;
        }
    }
    while(cursor.bt_next_key());

    test_indexes(coll->full_index_list->first);
}
コード例 #2
0
ファイル: t_res_database.cpp プロジェクト: Sasun/stardict-3
bool lookup_test(const index_vect_t &index_vect, rindex_file *pindex)
{
	const size_t ntest = 1000;
	std::vector<int> test_indexes(2+ntest);
	test_indexes[0] = 0;
	test_indexes[1] = index_vect.size() - 1;
	for(size_t i=2; i<test_indexes.size(); ++i)
		test_indexes[i] = rand()%index_vect.size();
	for(size_t i=0; i<test_indexes.size(); ++i) {
		if(!lookup_test_key(pindex, index_vect[test_indexes[i]].key,
			index_vect[test_indexes[i]].off, index_vect[test_indexes[i]].size))
			return false;
	}
	return true;
}
コード例 #3
0
ファイル: rcv_test_tr.cpp プロジェクト: sedna/sedna
void test_db_after_rcv()
{
    std::string rcv_fname = std::string(SEDNA_DATA) + std::string("/data/") + std::string(tr_globals::db_name) + std::string("_files/rcv_test_result.log");
    metadata_cell_cptr mdc = XNULL;

    logfile = fopen(rcv_fname.c_str(), "at");
    fprintf(logfile, "---------------------------------------------------------------------\n");

    bt_cursor cursor = bt_lm(catalog_get_names(catobj_metadata));
    if (!cursor.is_null()) do
    {
        mdc = cursor.bt_next_obj();

        if (!mdc->is_document())
            test_collection(mdc->get_name(), mdc->get_schema_node());
        else
        {
            xptr blk = mdc->get_schema_node()->bblk;
            CHECKP(blk);
            xptr doc_dsc = getFirstBlockNode(blk);
            test_document(mdc->get_name(), doc_dsc, false);
            test_indexes(doc_schema_node_cptr(mdc->get_schema_node())->full_index_list->first);
        }
    }
    while(cursor.bt_next_key());

    fclose(logfile);

#ifdef RCV_TEST_CRASH
    rcv_fname = std::string(SEDNA_DATA) + std::string("/data/") + std::string(tr_globals::db_name) + std::string("_files");

    if (isRcvOK)
        rcv_fname += std::string("/rcv_ok");
    else
        rcv_fname += std::string("/rcv_failed");

    r_fh = uCreateFile(rcv_fname.c_str(), U_SHARE_READ | U_SHARE_WRITE, U_READ_WRITE, U_NO_BUFFERING, NULL, NULL);
    if (r_fh == U_INVALID_FD)
        fprintf(stderr, "Cannot create rcv result file\n");
    uCloseFile(r_fh, NULL);
#endif
}