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


C++ leveldb::DB类代码示例

本文整理汇总了C++中leveldb::DB的典型用法代码示例。如果您正苦于以下问题:C++ DB类的具体用法?C++ DB怎么用?C++ DB使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: None

Try<Option<Entry> > LevelDBStorageProcess::read(const string& name)
{
  CHECK_NONE(error);

  leveldb::ReadOptions options;

  string value;

  leveldb::Status status = db->Get(options, name, &value);

  if (status.IsNotFound()) {
    return None();
  } else if (!status.ok()) {
    return Error(status.ToString());
  }

  google::protobuf::io::ArrayInputStream stream(value.data(), value.size());

  Entry entry;

  if (!entry.ParseFromZeroCopyStream(&stream)) {
    return Error("Failed to deserialize Entry");
  }

  return Some(entry);
}
开发者ID:ankurcha,项目名称:mesos,代码行数:26,代码来源:leveldb.cpp

示例2: GetVIPCData

inline BOOL ConfDB::GetVIPCData(u32 nId, VSCVIPCData &pData)
{
    VSCConfVIPCKey sChKey(nId);

    leveldb::Slice key((char *)&sChKey, sizeof(sChKey));


    leveldb::Iterator* it = m_pDb->NewIterator(leveldb::ReadOptions());

    it->Seek(key);
    leveldb::Slice sysValue;

    if (it->Valid())
    {
        sysValue = it->value();
    }

    if (sysValue.size() != sizeof(VSCVIPCData))
    {
        VDC_DEBUG( "Device Can not find !!!\n");

        delete it;
        return FALSE;
    }

    memcpy(&pData, sysValue.data(), sizeof(VSCVIPCData));

    // Check for any errors found during the scan
    assert(it->status().ok());
    delete it;

    return TRUE;
}
开发者ID:geolffrey,项目名称:ve,代码行数:33,代码来源:confdb.hpp

示例3: key

inline   BOOL ConfDB::GetLicense(astring &strLicense)
{
	VSCConfLicenseKey sLicKey;
	

	leveldb::Slice key((char *)&sLicKey, sizeof(sLicKey));


	leveldb::Iterator* it = m_pDb->NewIterator(leveldb::ReadOptions());

	it->Seek(key);
	leveldb::Slice sysValue;

	if (it->Valid())
	{
		sysValue = it->value();
		strLicense = sysValue.ToString();
	}
	
	// Check for any errors found during the scan
	assert(it->status().ok());
	delete it;

	return TRUE;

}
开发者ID:geolffrey,项目名称:ve,代码行数:26,代码来源:confdb.hpp

示例4: licKey

inline   BOOL ConfDB::SetLicense(astring &strLicense)
{
	VSCConfLicenseKey sLic;
	leveldb::WriteOptions writeOptions;

	leveldb::Slice licKey((char *)&sLic, sizeof(sLic));
	leveldb::Slice licValue(strLicense);
	m_pDb->Put(writeOptions, licKey, licValue);
	return true;
    
}
开发者ID:geolffrey,项目名称:ve,代码行数:11,代码来源:confdb.hpp

示例5: UpdateVIPCData

inline BOOL ConfDB::UpdateVIPCData(u32 nId, VSCVIPCData &pData)
{
    VSCConfVIPCKey sChKey(nId);
    leveldb::WriteOptions writeOptions;

    leveldb::Slice chKey((char *)&sChKey, sizeof(sChKey));
    leveldb::Slice chValue((char *)&pData, sizeof(VSCDeviceData));
    m_pDb->Put(writeOptions, chKey, chValue);

    return TRUE;
}
开发者ID:geolffrey,项目名称:ve,代码行数:11,代码来源:confdb.hpp

示例6: sysKey

/* HDFS record  */
inline s32 ConfDB::UpdateHdfsRecordData(VSCHdfsRecordData &pData)
{
    VSCConfHdfsRecordKey sKey;

    leveldb::WriteOptions writeOptions;

    leveldb::Slice sysKey((char *)&sKey, sizeof(sKey));
    leveldb::Slice sysValue((char *)&pData, sizeof(VSCHdfsRecordData));

    m_pDb->Put(writeOptions, sysKey, sysValue);

    return TRUE;
}
开发者ID:geolffrey,项目名称:ve,代码行数:14,代码来源:confdb.hpp

示例7: initialize

void LevelDBStorageProcess::initialize()
{
  leveldb::Options options;
  options.create_if_missing = true;

  leveldb::Status status = leveldb::DB::Open(options, path, &db);

  if (!status.ok()) {
    // TODO(benh): Consider trying to repair the DB.
    error = status.ToString();
  } else {
    // TODO(benh): Conditionally compact to avoid long recovery times?
    db->CompactRange(NULL, NULL);
  }
}
开发者ID:ankurcha,项目名称:mesos,代码行数:15,代码来源:leveldb.cpp

示例8: Failure

Future<std::set<string> > LevelDBStorageProcess::names()
{
  if (error.isSome()) {
    return Failure(error.get());
  }

  std::set<string> results;

  leveldb::Iterator* iterator = db->NewIterator(leveldb::ReadOptions());

  iterator->SeekToFirst();

  while (iterator->Valid()) {
    results.insert(iterator->key().ToString());
    iterator->Next();
  }

  delete iterator;

  return results;
}
开发者ID:ankurcha,项目名称:mesos,代码行数:21,代码来源:leveldb.cpp

示例9: Error

Try<bool> LevelDBStorageProcess::write(const Entry& entry)
{
  CHECK_NONE(error);

  leveldb::WriteOptions options;
  options.sync = true;

  string value;

  if (!entry.SerializeToString(&value)) {
    return Error("Failed to serialize Entry");
  }

  leveldb::Status status = db->Put(options, entry.name(), value);

  if (!status.ok()) {
    return Error(status.ToString());
  }

  return true;
}
开发者ID:ankurcha,项目名称:mesos,代码行数:21,代码来源:leveldb.cpp

示例10: GetSystemConf

inline BOOL ConfDB::GetSystemConf(VSCConfData &pSys)
{
    VSCConfSystemKey sSysKey;

    leveldb::Slice key((char *)&sSysKey, sizeof(sSysKey));


    leveldb::Iterator* it = m_pDb->NewIterator(leveldb::ReadOptions());

    it->Seek(key);
    leveldb::Slice sysValue;

    if (it->Valid())
    {
        sysValue = it->value();
    }

    if (sysValue.size() != sizeof(VSCConfData))
    {
        VDC_DEBUG( "System Config is not init\n");
        delete it;
        memset(&pSys, 0, sizeof(VSCConfData));
        SysConfDataDefault(pSys);
        UpdateSysData(pSys);
        astring strLicense = " ";
        SetLicense(strLicense);//set the default license
        /* Call get system again */
        return TRUE;
    }

    memcpy(&pSys, sysValue.data(), sizeof(VSCConfData));

    // Check for any errors found during the scan
    assert(it->status().ok());
    delete it;

    return TRUE;

}
开发者ID:geolffrey,项目名称:ve,代码行数:39,代码来源:confdb.hpp

示例11: GetHdfsRecordConf

inline BOOL ConfDB::GetHdfsRecordConf(VSCHdfsRecordData &pData)
{
    VSCConfHdfsRecordKey sKey;

    leveldb::Slice key((char *)&sKey, sizeof(sKey));


    leveldb::Iterator* it = m_pDb->NewIterator(leveldb::ReadOptions());

    it->Seek(key);
    leveldb::Slice sysValue;

    if (it->Valid())
    {
        sysValue = it->value();
    }

    if (sysValue.size() != sizeof(VSCHdfsRecordData))
    {
        VDC_DEBUG( "Hdfs Record Config is not init\n");
        delete it;
		memset(&pData, 0, sizeof(VSCHdfsRecordData));
		VSCHdfsRecordDataItemDefault(pData.data.conf);
		UpdateHdfsRecordData(pData);
        /* Call get system again */
        return TRUE;
    }

	memcpy(&pData, sysValue.data(), sizeof(VSCHdfsRecordData));

    // Check for any errors found during the scan
    assert(it->status().ok());
    delete it;

    return TRUE;

}
开发者ID:geolffrey,项目名称:ve,代码行数:37,代码来源:confdb.hpp

示例12: load

		void load(unsigned short bamIndex)
			{
			size_t n_reads=0;
			std::string value;
			bam1_t *b= bam_init1();
			
			index2chromNames.resize(bamIndex+1);
			WHERE(in->header);
			for(int32_t i=0;i< in->header->n_targets;++i)
				{
				string target_name(in->header->target_name[i]);
				
				index2chromNames.back().push_back(target_name);
				}
			while(samread(this->in, b) > 0) /* loop over the records */
				{
				std::auto_ptr<vector<Hit> > hits(0);
				Bam1Sequence seq(b);
				leveldb::Slice key1(seq.name());
				value.clear();
				WHERE(n_reads);
				leveldb::Status status = db->Get(this->read_options, key1, &value);
				
				if(!status.ok())
					{
					hits.reset(new vector<Hit>());
					n_reads++;
					if(n_reads%1000000UL==0)
						{
						clog <<  n_reads << endl;
						//break;//TODO
						}
					}
				else
					{
					hits=decode(value);
					}
				
				Hit hit;
				hit.bamIndex=bamIndex;
				hit.tid = seq.tid();
				hit.pos = seq.pos();
				hit.flag = seq.flag();
				hits->push_back(hit);
				
				std::auto_ptr<string> encoded = this->encode(hits.get());
				leveldb::Slice value1(encoded->data(),encoded->size());
				status = db->Put(this->write_options, key1, value1);
				if(!status.ok())
					{
					cerr << "Cannot insert into db" << endl;
					break;
					}
				}
			bam_destroy1(b);
			
			}
开发者ID:BioWu,项目名称:variationtoolkit,代码行数:57,代码来源:comparebam.cpp

示例13: Get

			Status Get(const std::string& key, std::string* value)
			{
				leveldb::Status s = db->Get(leveldb::ReadOptions(), key, value);
				if (s.ok())
				{
					return Status::OK();
				}

				return Status::NotFound();
			}
开发者ID:AndryLeon,项目名称:zsearch,代码行数:10,代码来源:KVStoreLevelDb.hpp

示例14: Delete

			Status Delete(const std::string& key)
			{
				leveldb::Status s = db->Delete(leveldb::WriteOptions(), key);

				if (s.ok())
				{
					return Status::OK();
				}

				return Status::NotFound();
			}
开发者ID:AndryLeon,项目名称:zsearch,代码行数:11,代码来源:KVStoreLevelDb.hpp

示例15: Put

			Status Put(const std::string& key, const std::string& value)
			{
				leveldb::Status s = db->Put(leveldb::WriteOptions(), key, value);

				if (s.ok())
				{
					return Status::OK();
				}
                std::cerr << s.ToString() << std::endl;
				return Status::NotFound();

			}
开发者ID:AndryLeon,项目名称:zsearch,代码行数:12,代码来源:KVStoreLevelDb.hpp


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