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


C++ Options::IncreaseParallelism方法代码示例

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


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

示例1: init

bool snpDeviceImpl::init(uint16 cellSize, uint32 cellsPerPU, uint32 numberOfPU)
{
    // setup device settings
    m_cellSize = cellSize;
    m_cellsPerPU = cellsPerPU;
    m_numberOfPU = numberOfPU;
    s_iCellIndex = kCellNotFound;

    // initialize database
    Options options;

    // Optimize RocksDB. This is the easiest way to get RocksDB to perform well
    options.IncreaseParallelism();
    options.OptimizeLevelStyleCompaction();

    // create the DB if it's not already present
    options.create_if_missing = true;

    // initialize database
    Status dbStatus = DB::Open(options, kDatabasePath + std::to_string(m_cellSize), &s_database);
    if (dbStatus.ok())
    {
        // fillup database with default values
        rocksdb::WriteBatch initBatch; Status dbStatus;

        std::vector<uint32> defaultVector;
        for(uint16 index = 0; index < m_cellSize; index++)
        {
            defaultVector.push_back(0);
        }

        std::string defaultValue = bitfield2string(defaultVector);
        for (uint32 index = 0; index < getCellsPerPU() * getNumberOfPU(); index++)
        {
            std::string key = std::to_string(index);
            std::string value;

            dbStatus = s_database->Get(rocksdb::ReadOptions(), key, &value);
            if (!dbStatus.ok() || string2bitfield(value).size() < m_cellSize)
            {
                initBatch.Put(key, defaultValue);
            }
        }

        dbStatus = s_database->Write(rocksdb::WriteOptions(), &initBatch);
    }
    return dbStatus.ok();
}
开发者ID:nverenik,项目名称:snp,代码行数:48,代码来源:snpDeviceRocksDB.cpp

示例2: main

int main(int argc, char** argv) {
    srand (time(NULL));

    if(argc != 3){
        cout<<"invalid parameter!!"<<endl;
        return 0;
    }
    string key, val;
    int type = atoi(argv[1]);
    int counter = 0;

    if(type == 3){
        key = argv[2];
    }
    else{
        counter = atoi(argv[2]);
    }

    cout<<"type:"<<type<<endl;
    cout<<"counter:"<<counter<<endl;


  DB* db;
  Options options;
  // Optimize RocksDB. This is the easiest way to get RocksDB to perform well
  options.IncreaseParallelism();
  options.OptimizeLevelStyleCompaction();
  // create the DB if it's not already present
  options.create_if_missing = true;

  // open DB
  Status s = DB::Open(options, kDBPath, &db);
  assert(s.ok());


  if(type == 3){
      s = db->Get(ReadOptions(), key, &val);
      cout<<"ret:"<<val<<endl;
  }
  else if(type == 1){
      time_t now = time(NULL);
      for(int i = 0; i < counter ; i++){
          key = "key_" + boost::lexical_cast<string>(i);
          val = "val_" + boost::lexical_cast<string>(i)+"_" +boost::lexical_cast<string>(now);

          s = db->Put(WriteOptions(), key, val);
      }
  }
  else if(type == 2){
      int k;
      for(int i = 0; i < counter ; i++){
          k = rand() % counter;

          key = "key_" + boost::lexical_cast<string>(k);

          s = db->Get(ReadOptions(), key, &val);
      }
      cout<<key<<":"<<val<<endl;
  }
    delete db;
    return 0;
}
开发者ID:zoozo,项目名称:test,代码行数:62,代码来源:test.cpp


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