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


C++ Dbt::get_size方法代码示例

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


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

示例1: initializeOutDbt

void
Freeze::handleDbException(const DbException& dx, 
                          Key& key, Dbt& dbKey, 
                          const char* file, int line)
{
    bool bufferSmallException =
#if (DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR == 2)
        (dx.get_errno() == ENOMEM);
#else
        (dx.get_errno() == DB_BUFFER_SMALL || dx.get_errno() == ENOMEM);
#endif  
        
    if(bufferSmallException && (dbKey.get_size() > dbKey.get_ulen()))
    {
        //
        // Keep the old key size in case it's used as input
        //
        size_t oldKeySize = key.size();

        key.resize(dbKey.get_size());
        initializeOutDbt(key, dbKey);
        dbKey.set_size(static_cast<u_int32_t>(oldKeySize));
    }
    else
    {
        handleDbException(dx, file, line);
    }
}
开发者ID:2008hatake,项目名称:zeroc-ice,代码行数:28,代码来源:Util.cpp

示例2: Get

bool Table::Get(Transaction* tx,
				const ByteString &key,
				ByteString &value)
{
	Dbt dbtKey;
	Dbt dbtValue;
	DbTxn* txn = NULL;
	int ret;
	
	if (tx)
		txn = tx->txn;

	dbtKey.set_flags(DB_DBT_USERMEM);
	dbtKey.set_data(key.buffer);
	dbtKey.set_ulen(key.length);
	dbtKey.set_size(key.length);
	
	dbtValue.set_flags(DB_DBT_USERMEM);
	dbtValue.set_data(value.buffer);
	dbtValue.set_ulen(value.size);
	
	ret = db->get(txn, &dbtKey, &dbtValue, 0);

	// DB_PAGE_NOTFOUND can occur with parallel PRUNE and GET operations
	// probably because we have DB_READ_UNCOMMITED turned on
	if (ret == DB_KEYEMPTY || ret == DB_NOTFOUND || ret == DB_PAGE_NOTFOUND)
		return false;
	
	if (dbtValue.get_size() > (size_t) value.size)
		return false;

	value.length = dbtValue.get_size();
	
	return true;
}
开发者ID:agazso,项目名称:keyspace,代码行数:35,代码来源:Table.cpp

示例3: memcmp

bool operator==(const Dbt&d1, const Dbt&d2)  
{
	if (d1.get_size() != d2.get_size())
		return false;

	return memcmp(d1.get_data(), d2.get_data(), 
	    d2.get_size()) == 0;
}
开发者ID:CompassHXM,项目名称:h-store,代码行数:8,代码来源:dbstl_container.cpp

示例4: guard

void berkeleydb_store<Object>::get_range(const timestamp& from,
                                         const timestamp& to,
                                         const long lp_id,
                                         std::vector<obj_ptr>& ret_obj) {
  boost::lock_guard<boost::mutex> guard(get_mutex_);
  if (from > to) return;

  /* generate key */
  std::vector<char> from_char;
  key_lpid_to_char(from, lp_id, from_char);
  Dbt db_key = Dbt(&from_char[0], from_char.size());

  /* prepare data */
  char* binary;
  Dbt data;
  data.set_data(binary);
  data.set_flags(DB_DBT_MALLOC);

  /* seek to from */
  Dbc* cursorp;
  db->cursor(NULL, &cursorp, 0);
  int ret = cursorp->get(&db_key, &data, DB_SET_RANGE);
  if (ret) {
    if (cursorp != NULL) cursorp->close();
    return;
  }
  std::string get_data_binary
      = std::string((char*) data.get_data(), data.get_size());
  std::stringstream from_ss;
  from_ss << get_data_binary;
  boost::archive::binary_iarchive iar(from_ss);
  Object obj;
  iar >> obj;
  ret_obj.push_back(boost::make_shared<Object>(obj));

  /* get until end */
  while ((ret = cursorp->get(&db_key, &data, DB_NEXT)) == 0) {
    timestamp tmstmp;
    long id;
    char_to_key_lpid((char*) db_key.get_data(), tmstmp, id);
    if (tmstmp > to || id != lp_id) break;

    get_data_binary = std::string((char*) data.get_data(), data.get_size());
    std::stringstream ss;
    ss << get_data_binary;
    boost::archive::binary_iarchive iar(ss);
    Object deserialized_obj;
    iar >> deserialized_obj;
    ret_obj.push_back(boost::make_shared<Object>(deserialized_obj));
  }

  if (cursorp != NULL) cursorp->close();
};
开发者ID:masatoshihanai,项目名称:ScaleSim,代码行数:53,代码来源:berkeleydb_store.hpp

示例5: db_key

void berkeleydb_store<Object>::get(const timestamp& time,
                                   const long lp_id,
                                   obj_ptr& ret) {
  boost::lock_guard<boost::mutex> guard(get_mutex_);
  /* generate key */
  std::vector<char> key;
  key_lpid_to_char(time, lp_id, key);
  Dbt db_key(&key[0], key.size());

  /* get data */
  char* event_binary;
  Dbt data;
  data.set_data(event_binary);
  data.set_flags(DB_DBT_MALLOC);

  db->get(NULL, &db_key, &data, 0);

  /* deserialize the data */
  std::string binary = std::string((char*) data.get_data(), data.get_size());
  std::stringstream from_ss;
  from_ss << binary;
  boost::archive::binary_iarchive iar(from_ss);
  Object obj;
  iar >> obj;

  ret = boost::make_shared<Object>(obj);
};
开发者ID:masatoshihanai,项目名称:ScaleSim,代码行数:27,代码来源:berkeleydb_store.hpp

示例6: readBlockBerkeleyDB

AntiCacheBlock AntiCacheDB::readBlockBerkeleyDB(std::string tableName, int16_t blockId) {
    
    Dbt key;
    key.set_data(&blockId);
    key.set_size(sizeof(int16_t));

    Dbt value;
    value.set_flags(DB_DBT_MALLOC);
    
    VOLT_DEBUG("Reading evicted block with id %d", blockId);
    
    int ret_value = m_db->get(NULL, &key, &value, 0);
    if (ret_value != 0) 
    {
        VOLT_ERROR("Invalid anti-cache blockId '%d' for table '%s'", blockId, tableName.c_str());
        throw UnknownBlockAccessException(tableName, blockId);
    }
    else 
    {
//        m_db->del(NULL, &key, 0);  // if we have this the benchmark won't end
        assert(value.get_data() != NULL);
    }
    
    AntiCacheBlock block(blockId, static_cast<char*>(value.get_data()), value.get_size());
    return (block);
}
开发者ID:huanchenz,项目名称:h-store-index,代码行数:26,代码来源:AntiCacheDB.cpp

示例7: get

RecordData Database::get(const RecordID& id) const
{
	Dbt key(id.data(), id.size());
	Dbt data;
	thread_local static std::vector<char> buffer(256);
		
	while (true)
	{
		try
		{
			data.set_flags(DB_DBT_USERMEM);
			data.set_data(buffer.data());
			data.set_ulen(buffer.size());
			const int err = dbMain_.get(/*txnid*/nullptr, &key, &data, /*flags*/0);
			assert (err == 0);
			break;
		}
		catch(DbException const& ex)
		{
			if (ex.get_errno() !=  DB_BUFFER_SMALL)
			{
				throw;
			}

			buffer.resize(data.get_size() * 1.5);
		}
	}
	
	return RecordData(data);
}
开发者ID:sgomin,项目名称:ddb_medialib,代码行数:30,代码来源:database.cpp

示例8: if

bool
Freeze::IteratorHelperI::lowerBound(const Key& key) const
{
    //
    // We retrieve the actual key for upperBound
    //
    Dbt dbKey;
    _key = key;
    initializeOutDbt(_key, dbKey);
    dbKey.set_size(static_cast<u_int32_t>(_key.size()));

    //
    // Keep 0 length since we're not interested in the data
    //
    Dbt dbValue;
    dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);

    for(;;)
    {
        try
        {
            int err = _dbc->get(&dbKey, &dbValue, DB_SET_RANGE);
            if(err == 0)
            {
                _key.resize(dbKey.get_size());
                return true;
            }
            else if(err == DB_NOTFOUND)
            {
                return false;
            }
            else
            {
                //
                // Bug in Freeze
                //
                assert(0);
                throw DatabaseException(__FILE__, __LINE__);
            }
        }
        catch(const ::DbDeadlockException& dx)
        {
            if(_tx != 0)
            {
                _tx->dead();
            }

            DeadlockException ex(__FILE__, __LINE__);
            ex.message = dx.what();
            throw ex;
        }
        catch(const ::DbException& dx)
        {
            handleDbException(dx, _key, dbKey, __FILE__, __LINE__);
        }
    }
}
开发者ID:ming-hai,项目名称:freeze,代码行数:57,代码来源:MapI.cpp

示例9: key

std::set<std::string> ClicDb::get(const std::string& usr) {
    Dbt key(const_cast<char*>(usr.c_str()), usr.size());
    Dbt value;
    if (db.get(NULL, &key, &value, 0) == DB_NOTFOUND)
        return std::set<std::string>();
    std::string str((char*)value.get_data(), value.get_size());
    std::set<std::string> result;
    boost::algorithm::split(result, str, boost::algorithm::is_any_of("\t"));
    return result;
}
开发者ID:Abioy,项目名称:clang_indexer,代码行数:10,代码来源:ClicDb.cpp

示例10: db

vector<string>
Freeze::EvictorIBase::allDbs() const
{
    vector<string> result;

    try
    {
        Db db(_dbEnv->getEnv(), 0);

        //
        // Berkeley DB expects file paths to be UTF8 encoded.
        //
        db.open(0, nativeToUTF8(_filename, getProcessStringConverter()).c_str(), 0, DB_UNKNOWN,
                DB_RDONLY, 0);

        Dbc* dbc = 0;
        db.cursor(0, &dbc, 0);

        Dbt dbKey;
        dbKey.set_flags(DB_DBT_MALLOC);

        Dbt dbValue;
        dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);

        bool more = true;
        while(more)
        {
            more = (dbc->get(&dbKey, &dbValue, DB_NEXT) == 0);
            if(more)
            {
                string dbName(static_cast<char*>(dbKey.get_data()), dbKey.get_size());

                if(dbName.find(indexPrefix) != 0)
                {
                    result.push_back(dbName);
                }
                free(dbKey.get_data());
            }
        }

        dbc->close();
        db.close(0);
    }
    catch(const DbException& dx)
    {
        if(dx.get_errno() != ENOENT)
        {
            DatabaseException ex(__FILE__, __LINE__);
            ex.message = dx.what();
            throw ex;
        }
    }

    return result;
}
开发者ID:ming-hai,项目名称:freeze,代码行数:55,代码来源:EvictorI.cpp

示例11: key

std::set<std::string> ClicDb::get(const std::string& usr) {
    Dbt key(const_cast<char*>(usr.c_str()), usr.size());
    Dbt value;

    if (db.get(NULL, &key, &value, 0) == DB_NOTFOUND)
        return std::set<std::string>();
    std::string str((char*)value.get_data(), value.get_size());

    std::set<std::string> res;
    for (const auto &i : split(str, '\t'))
        res.insert(i);
    return res;
}
开发者ID:AlexanderKlishin,项目名称:test,代码行数:13,代码来源:ClicDb.cpp

示例12: next

bool DbMultipleDataIterator::next(Dbt &data)
{
	if (*p_ == (u_int32_t)-1) {
		data.set_data(0);
		data.set_size(0);
		p_ = 0;
	} else {
		data.set_data(data_ + *p_--);
		data.set_size(*p_--);
		if (data.get_size() == 0 && data.get_data() == data_)
			data.set_data(0);
	}
	return (data.get_data() != 0);
}
开发者ID:SergeStinckwich,项目名称:openqwaq,代码行数:14,代码来源:cxx_multi.cpp

示例13: getWord

 void getWord(const std::string & word, unsigned int & good_count, unsigned int & bad_count) {
     Dbt key(const_cast<void *>(reinterpret_cast<const void *>(word.c_str())), word.size());
     Dbt data;
     BayesDBData bdata;
     good_count = 0;
     bad_count = 0;
     if(db.get(NULL, &key, &data, 0) != DB_NOTFOUND) {
         int s = data.get_size();
         if(s != sizeof(bdata)) throw std::runtime_error("Bayesian DB returned wrong record size");
         void * vdata = data.get_data();
         memcpy((void *)&bdata, vdata, s);
         good_count = bdata.good_edits;
         bad_count = bdata.bad_edits;
     }
 }
开发者ID:poo-through-your-willy,项目名称:cluebotng,代码行数:15,代码来源:bayesdb.hpp

示例14: test_dbt

void test_dbt(void) {
    u_int32_t size  = 3;
    u_int32_t flags = 5;
    u_int32_t ulen  = 7;
    void*     data  = &size;
    Dbt dbt;

    dbt.set_size(size);
    dbt.set_flags(flags);
    dbt.set_data(data);
    dbt.set_ulen(ulen);
    assert(dbt.get_size()  == size);
    assert(dbt.get_flags() == flags);
    assert(dbt.get_data()  == data);
    assert(dbt.get_ulen()  == ulen);
}
开发者ID:Alienfeel,项目名称:ft-index,代码行数:16,代码来源:test1.cpp

示例15: readFirstRec

void* BDBFile::readFirstRec(void* key_, unsigned int keySize_)    
{
  assert(dbHandle != NULL && dbCursor != NULL);
  Dbt key;
  Dbt data;
  int rtrnCode = dbCursor->get(&key, &data, DB_FIRST);
  if (rtrnCode > 0) {
    key_ = NULL;
    keySize_ = 0;
    return NULL;
  } else {
    key_ = key.get_data();
    keySize_ = key.get_size();
    return data.get_data();
  }
}
开发者ID:mesadb,项目名称:mesadb.github.io,代码行数:16,代码来源:BDBFile.cpp


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