本文整理汇总了C++中ConnectionIPtr::dbEnv方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionIPtr::dbEnv方法的具体用法?C++ ConnectionIPtr::dbEnv怎么用?C++ ConnectionIPtr::dbEnv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionIPtr
的用法示例。
在下文中一共展示了ConnectionIPtr::dbEnv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
Freeze::MapHelperI::MapHelperI(const ConnectionIPtr& connection,
const string& dbName,
const string& key,
const string& value,
const KeyCompareBasePtr& keyCompare,
const vector<MapIndexBasePtr>& indices,
bool createDb) :
_connection(connection),
_db(connection->dbEnv()->getSharedMapDb(dbName, key, value, keyCompare, indices, createDb)),
_dbName(dbName),
_trace(connection->trace())
{
for(vector<MapIndexBasePtr>::const_iterator p = indices.begin();
p != indices.end(); ++p)
{
const MapIndexBasePtr& indexBase = *p;
assert(indexBase->_impl != 0);
assert(indexBase->_communicator == _connection->communicator());
assert(indexBase->_map == 0);
#ifdef NDEBUG
_indices.insert(IndexMap::value_type(indexBase->name(), indexBase));
#else
bool inserted = _indices.insert(IndexMap::value_type(indexBase->name(), indexBase)).second;
assert(inserted);
#endif
indexBase->_map = this;
}
_connection->registerMap(this);
}
示例2: out
Freeze::MapDb::MapDb(const ConnectionIPtr& connection,
const string& dbName,
const string& key,
const string& value,
const KeyCompareBasePtr& keyCompare,
const vector<MapIndexBasePtr>& indices,
bool createDb) :
Db(connection->dbEnv()->getEnv(), 0),
_communicator(connection->communicator()),
_dbName(dbName),
_trace(connection->trace()),
_keyCompare(keyCompare)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "opening Db \"" << _dbName << "\"";
}
Catalog catalog(connection, _catalogName);
TransactionPtr tx = connection->currentTransaction();
bool ownTx = (tx == 0);
for(;;)
{
try
{
if(ownTx)
{
tx = 0;
tx = connection->beginTransaction();
}
Catalog::iterator ci = catalog.find(_dbName);
if(ci != catalog.end())
{
if(ci->second.evictor)
{
throw DatabaseException(__FILE__, __LINE__, _dbName + " is an evictor database");
}
_key = ci->second.key;
_value = ci->second.value;
checkTypes(key, value);
}
else
{
_key = key;
_value = value;
}
set_app_private(this);
if(_keyCompare->compareEnabled())
{
set_bt_compare(&customCompare);
}
PropertiesPtr properties = _communicator->getProperties();
string propPrefix = "Freeze.Map." + _dbName + ".";
int btreeMinKey = properties->getPropertyAsInt(propPrefix + "BtreeMinKey");
if(btreeMinKey > 2)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "Setting \"" << _dbName << "\"'s btree minkey to " << btreeMinKey;
}
set_bt_minkey(btreeMinKey);
}
bool checksum = properties->getPropertyAsInt(propPrefix + "Checksum") > 0;
if(checksum)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "Turning checksum on for \"" << _dbName << "\"";
}
set_flags(DB_CHKSUM);
}
int pageSize = properties->getPropertyAsInt(propPrefix + "PageSize");
if(pageSize > 0)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "Setting \"" << _dbName << "\"'s pagesize to " << pageSize;
}
set_pagesize(pageSize);
}
DbTxn* txn = getTxn(tx);
u_int32_t flags = DB_THREAD;
//.........这里部分代码省略.........
示例3: out
Freeze::MapIndexI::MapIndexI(const ConnectionIPtr& connection, MapDb& db,
DbTxn* txn, bool createDb, const MapIndexBasePtr& index) :
_index(index)
{
assert(txn != 0);
_db.reset(new Db(connection->dbEnv()->getEnv(), 0));
_db->set_flags(DB_DUP | DB_DUPSORT);
u_int32_t flags = 0;
if(createDb)
{
flags = DB_CREATE;
}
_dbName = db.dbName() + "." + _index->name();
_db->set_app_private(this);
if(index->compareEnabled())
{
_db->set_bt_compare(&customIndexCompare);
}
Ice::PropertiesPtr properties = connection->communicator()->getProperties();
string propPrefix = "Freeze.Map." + _dbName + ".";
int btreeMinKey = properties->getPropertyAsInt(propPrefix + "BtreeMinKey");
if(btreeMinKey > 2)
{
if(connection->trace() >= 1)
{
Trace out(connection->communicator()->getLogger(), "Freeze.Map");
out << "Setting \"" << _dbName << "\"'s btree minkey to " << btreeMinKey;
}
_db->set_bt_minkey(btreeMinKey);
}
bool checksum = properties->getPropertyAsInt(propPrefix + "Checksum") > 0;
if(checksum)
{
if(connection->trace() >= 1)
{
Trace out(connection->communicator()->getLogger(), "Freeze.Map");
out << "Turning checksum on for \"" << _dbName << "\"";
}
_db->set_flags(DB_CHKSUM);
}
int pageSize = properties->getPropertyAsInt(propPrefix + "PageSize");
if(pageSize > 0)
{
if(connection->trace() >= 1)
{
Trace out(connection->communicator()->getLogger(), "Freeze.Map");
out << "Setting \"" << _dbName << "\"'s pagesize to " << pageSize;
}
_db->set_pagesize(pageSize);
}
if(connection->trace() >= 1)
{
Trace out(connection->communicator()->getLogger(), "Freeze.Map");
out << "Opening index \"" << _dbName << "\"";
}
//
// Berkeley DB expects file paths to be UTF8 encoded.
//
_db->open(txn, nativeToUTF8(_dbName, getProcessStringConverter()).c_str(), 0, DB_BTREE, flags,
FREEZE_DB_MODE);
//
// To populate empty indices
//
flags = DB_CREATE;
db.associate(txn, _db.get(), callback, flags);
//
// Note: caller catch and translates exceptions
//
}