Esempio n. 1
0
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;

}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
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;

}
Esempio n. 5
0
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;

}
Esempio n. 6
0
		void dump()
			{
			
			leveldb::Iterator* it=db->NewIterator(this->read_options);
			for (it->SeekToFirst(); it->Valid(); it->Next())
				{
				std::auto_ptr<vector<Hit> > hits = decode(it->value().ToString());
				size_t i0=0;
				
				while(i0 < hits->size())
					{
					size_t i1=i0+1;
					while(i1<hits->size())
						{
						if(hits->at(i0).bamIndex==hits->at(i1).bamIndex) {++i1; continue;}
		
						if(IS_FLAG_SET(hits->at(i0).flag,BAM_FREAD1)!=IS_FLAG_SET(hits->at(i1).flag,BAM_FREAD1))
							{
							++i1;
							continue;
							}
						if(IS_FLAG_SET(hits->at(i0).flag,BAM_FREAD2)!=IS_FLAG_SET(hits->at(i1).flag,BAM_FREAD2))
							{
							++i1;
							continue;
							}
						if(!hits->at(i0).mapped() && !hits->at(i1).mapped())
							{
							break;
							}

						if(hits->at(i0).tid==-1 && hits->at(i1).tid==-1)
							{
							break;
							}
						else if(sameChromosome(
							index2chromNames[hits->at(i0).bamIndex][hits->at(i0).tid].c_str(),
							index2chromNames[hits->at(i1).bamIndex][hits->at(i1).tid].c_str()
							))
							{
							if(hits->at(i0).pos==hits->at(i1).pos)
								{
								break;
								}
							}
						
						++i1;
						}
					if(i1!=	hits->size())
						{
						cout 	<< it->key().ToString()
							<< "\t";
						if(IS_FLAG_SET(hits->at(i0).flag,BAM_FREAD1)) { cout << "1\t"; }
						else if(IS_FLAG_SET(hits->at(i0).flag,BAM_FREAD2)) { cout << "2\t";}
						else cout << "?\t";
						print(hits->at(i0));
						cout << "\t";
						print(hits->at(i1));				
						cout << "\t=";
						cout << endl;
						hits->erase(hits->begin()+i1);//that one before
						hits->erase(hits->begin()+i0);
						}
					else
						{
						++i0;
						}
					}
				
				for(i0=0;i0<hits->size();++i0)
					{
					cout 	<< it->key().ToString()
						<< "\t";
					if(IS_FLAG_SET(hits->at(i0).flag,BAM_FREAD1)) cout << "1\t";
					else if(IS_FLAG_SET(hits->at(i0).flag,BAM_FREAD2)) cout << "2\t";
					else cout << "?\t";
					if(hits->at(i0).bamIndex==1) cout << ".\t";	
					print(hits->at(i0));
					if(hits->at(i0).bamIndex==0) cout << "\t.";		
					cout << endl;
					}

				
				}
			delete it;
			}