当前位置: 首页>>代码示例>>C++>>正文


C++ DBC::c_getf_first方法代码示例

本文整理汇总了C++中DBC::c_getf_first方法的典型用法代码示例。如果您正苦于以下问题:C++ DBC::c_getf_first方法的具体用法?C++ DBC::c_getf_first怎么用?C++ DBC::c_getf_first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBC的用法示例。


在下文中一共展示了DBC::c_getf_first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Init

    int PerconaFTEngine::Init(const std::string& dir, const std::string& options)
    {
        Properties props;
        parse_conf_content(options, props);
        //parse config
        conf_get_int64(props, "cache_size", g_perconaft_config.cache_size);
        conf_get_uint32(props, "checkpoint_pool_threads", g_perconaft_config.checkpoint_pool_threads);
        conf_get_uint32(props, "checkpoint_period", g_perconaft_config.checkpoint_period);
        conf_get_uint32(props, "cleaner_period", g_perconaft_config.cleaner_period);
        conf_get_uint32(props, "cleaner_iterations", g_perconaft_config.cleaner_iterations);
        conf_get_bool(props, "evictor_enable_partial_eviction", g_perconaft_config.evictor_enable_partial_eviction);
        std::string compression;
        conf_get_string(props, "compression", compression);
        if (compression == "none")
        {
            g_perconaft_config.compression = TOKU_NO_COMPRESSION;
        }
        else if (compression == "snappy" || compression.empty())
        {
            g_perconaft_config.compression = TOKU_SNAPPY_METHOD;
        }
        else if (compression == "zlib")
        {
            g_perconaft_config.compression = TOKU_ZLIB_METHOD;
        }
        else
        {
            ERROR_LOG("Invalid compression config:%s for PercanoFT.", compression.c_str());
            return -1;
        }

        uint32 env_open_flags = DB_CREATE | DB_PRIVATE | DB_THREAD | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG | DB_RECOVER;
        int env_open_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
        db_env_create(&m_env, 0);
        m_env->set_default_bt_compare(m_env, ardb_perconaft_compare);
        m_env->set_errcall(m_env, _err_callback);

        /*
         * set env config
         */
        uint32 cache_gsize = g_perconaft_config.cache_size >> 30;
        uint32 cache_bytes = g_perconaft_config.cache_size % (1024 * 1024 * 1024);
        m_env->set_cachesize(m_env, cache_gsize, cache_bytes, 1);
        m_env->set_cachetable_pool_threads(m_env, g_perconaft_config.checkpoint_pool_threads);
        m_env->checkpointing_set_period(m_env, g_perconaft_config.checkpoint_period);
        m_env->cleaner_set_period(m_env, g_perconaft_config.cleaner_period);
        m_env->cleaner_set_iterations(m_env, g_perconaft_config.cleaner_iterations);

        m_env->evictor_set_enable_partial_eviction(m_env, g_perconaft_config.evictor_enable_partial_eviction);

        int r = m_env->open(m_env, dir.c_str(), env_open_flags, env_open_mode);
        CHECK_EXPR(r);
        DataArray nss;
        if (0 == r)
        {
            g_toku_env = m_env;
            DB* db = m_env->get_db_for_directory(m_env);
            if (NULL != db)
            {
                PerconaFTLocalContext& local_ctx = g_local_ctx.GetValue();
                DB_TXN* txn = local_ctx.transc.Get();
                DBC *c = NULL;
                CHECK_EXPR(r = db->cursor(db, txn, &c, 0));
                if (0 == r)
                {
                    r = c->c_getf_first(c, 0, nil_callback, NULL);
                }
                while (0 == r)
                {
                    DBT raw_key;
                    DBT raw_val;
                    memset(&raw_key, 0, sizeof(raw_key));
                    memset(&raw_val, 0, sizeof(raw_key));
                    if (0 == c->c_get(c, &raw_key, &raw_val, DB_CURRENT))
                    {
                        //std::string ns_str
                        Data ns;
                        ns.SetString((const char*) raw_key.data, false);
                        INFO_LOG("TokuFT directory db %s:%s", (const char* ) raw_key.data, (const char* ) raw_val.data);
                        nss.push_back(ns);
                    }
                    r = c->c_getf_next(c, 0, nil_callback, NULL);
                }
                if (NULL != c)
                {
                    c->c_close(c);
                }
                local_ctx.transc.Release(true);
                r = 0;
            }
        }
        for (size_t i = 0; i < nss.size(); i++)
        {
            Context tmp;
            GetFTDB(tmp, nss[i], true);
        }
        return ENGINE_ERR(r);
    }
开发者ID:yinqiwen,项目名称:ardb,代码行数:98,代码来源:perconaft_engine.cpp


注:本文中的DBC::c_getf_first方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。