예제 #1
9
파일: confdb.hpp 프로젝트: geolffrey/ve
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;
}
예제 #2
0
		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);
			
			}
예제 #3
0
파일: confdb.hpp 프로젝트: geolffrey/ve
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;
    
}
예제 #4
0
			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();

			}
예제 #5
0
파일: confdb.hpp 프로젝트: geolffrey/ve
/* 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;
}
예제 #6
0
파일: confdb.hpp 프로젝트: geolffrey/ve
/* Camera Group  */
inline s32 ConfDB::UpdateVGroupData(VSCVGroupData &pVGroupData)
{
    VSCConfVGroupKey sVGroupKey;

    leveldb::WriteOptions writeOptions;

    leveldb::Slice sysKey((char *)&sVGroupKey, sizeof(sVGroupKey));
    leveldb::Slice sysValue((char *)&pVGroupData, sizeof(VSCVGroupData));

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

    return TRUE;
}
예제 #7
0
파일: confdb.hpp 프로젝트: geolffrey/ve
inline s32 ConfDB::UpdateSysData(VSCConfData &pSysData)
{
    VSCConfSystemKey sSysKey;

    leveldb::WriteOptions writeOptions;

    leveldb::Slice sysKey((char *)&sSysKey, sizeof(sSysKey));
    leveldb::Slice sysValue((char *)&pSysData, sizeof(VSCConfData));

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

    return TRUE;
}
예제 #8
0
파일: leveldb.cpp 프로젝트: ankurcha/mesos
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;
}