本文整理汇总了C++中Dbc::count方法的典型用法代码示例。如果您正苦于以下问题:C++ Dbc::count方法的具体用法?C++ Dbc::count怎么用?C++ Dbc::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dbc
的用法示例。
在下文中一共展示了Dbc::count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: out
Int
Freeze::IndexI::untypedCount(const Key& bytes) const
{
DeactivateController::Guard
deactivateGuard(_store->evictor()->deactivateController());
Dbt dbKey;
initializeInDbt(bytes, dbKey);
#if (DB_VERSION_MAJOR <= 4) || (DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR <= 1)
//
// When we have a custom-comparison function, Berkeley DB returns
// the key on-disk (when it finds one). We disable this behavior:
// (ref Oracle SR 5925672.992)
//
dbKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
#else
//
// In DB > 5.1 we can not set DB_DBT_PARTIAL in the key Dbt,
// when using DB_SET, we must resize the Dbt key param to hold enought
// space or Dbc::get fails with DB_BUFFER_SMALL.
//
dbKey.set_flags(DB_DBT_USERMEM);
dbKey.set_ulen(static_cast<u_int32_t>(bytes.size()));
#endif
Dbt dbValue;
dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
TransactionIPtr transaction = _store->evictor()->beforeQuery();
DbTxn* tx = transaction == 0 ? 0 : transaction->dbTxn();
Int result = 0;
try
{
for(;;)
{
Dbc* dbc = 0;
try
{
//
// Move to the first record
//
_db->cursor(tx, &dbc, 0);
bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
if(found)
{
db_recno_t count = 0;
dbc->count(&count, 0);
result = static_cast<Int>(count);
}
Dbc* toClose = dbc;
dbc = 0;
toClose->close();
break; // for (;;)
}
catch(const DbDeadlockException&)
{
if(dbc != 0)
{
try
{
dbc->close();
}
catch(const DbDeadlockException&)
{
if(tx != 0)
{
throw;
}
// Else ignored
}
}
if(_store->evictor()->deadlockWarning())
{
Warning out(_store->communicator()->getLogger());
out << "Deadlock in Freeze::IndexI::untypedCount while searching \""
<< _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
}
if(tx != 0)
{
throw;
}
// Else retry
}
catch(...)
{
if(dbc != 0)
{
try
{
dbc->close();
}
catch(const DbDeadlockException&)
//.........这里部分代码省略.........
示例2: out
Int
Freeze::IndexI::untypedCount(const Key& bytes) const
{
DeactivateController::Guard
deactivateGuard(_store->evictor()->deactivateController());
Dbt dbKey;
initializeInDbt(bytes, dbKey);
//
// When we have a custom-comparison function, Berkeley DB returns
// the key on-disk (when it finds one). We disable this behavior:
// (ref Oracle SR 5925672.992)
//
dbKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
Dbt dbValue;
dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
_store->evictor()->saveNow();
Int result = 0;
try
{
for(;;)
{
Dbc* dbc = 0;
try
{
//
// Move to the first record
//
_db->cursor(0, &dbc, 0);
bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
if(found)
{
db_recno_t count = 0;
dbc->count(&count, 0);
result = static_cast<Int>(count);
}
Dbc* toClose = dbc;
dbc = 0;
toClose->close();
break; // for (;;)
}
catch(const DbDeadlockException&)
{
if(dbc != 0)
{
try
{
dbc->close();
}
catch(const DbDeadlockException&)
{
//
// Ignored
//
}
}
if(_store->evictor()->deadlockWarning())
{
Warning out(_store->communicator()->getLogger());
out << "Deadlock in Freeze::IndexI::untypedCount while searching \""
<< _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
}
//
// Retry
//
}
catch(...)
{
if(dbc != 0)
{
try
{
dbc->close();
}
catch(const DbDeadlockException&)
{
//
// Ignored
//
}
}
throw;
}
}
}
catch(const DbException& dx)
{
DatabaseException ex(__FILE__, __LINE__);
ex.message = dx.what();
throw ex;
}
//.........这里部分代码省略.........
示例3: out
int
Freeze::MapIndexI::untypedCount(const Key& k, const ConnectionIPtr& connection) const
{
Dbt dbKey;
initializeInDbt(k, dbKey);
#if (DB_VERSION_MAJOR <= 4)
//
// When we have a custom-comparison function, Berkeley DB returns
// the key on-disk (when it finds one). We disable this behavior:
// (ref Oracle SR 5925672.992)
//
dbKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
#else
//
// In DB 5.x we can not set DB_DBT_PARTIAL in the key Dbt,
// when using DB_SET, we must resize the Dbt key param to hold enought
// space or Dbc::get fails with DB_BUFFER_SMALL.
//
dbKey.set_flags(DB_DBT_USERMEM);
dbKey.set_ulen(static_cast<u_int32_t>(k.size()));
#endif
Dbt dbValue;
dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
int result = 0;
DbTxn* txn = connection->dbTxn();
try
{
for(;;)
{
Dbc* dbc = 0;
try
{
//
// Move to the first record
//
_db->cursor(txn, &dbc, 0);
bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
if(found)
{
db_recno_t count = 0;
dbc->count(&count, 0);
result = static_cast<int>(count);
}
Dbc* toClose = dbc;
dbc = 0;
toClose->close();
break; // for (;;)
}
catch(const DbDeadlockException&)
{
if(dbc != 0)
{
try
{
dbc->close();
}
catch(const DbDeadlockException&)
{
if(txn != 0)
{
throw;
}
else
{
//
// Ignored
//
}
}
}
if(connection->deadlockWarning())
{
Warning out(connection->communicator()->getLogger());
out << "Deadlock in Freeze::MapIndexI::untypedCount while searching \""
<< _dbName << "\"";
}
if(txn != 0)
{
throw;
}
//
// Otherwise retry
//
}
catch(...)
{
if(dbc != 0)
{
try
{
dbc->close();
//.........这里部分代码省略.........