本文整理汇总了C++中client::Context::db方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::db方法的具体用法?C++ Context::db怎么用?C++ Context::db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类client::Context
的用法示例。
在下文中一共展示了Context::db方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prefix
/* db - database name
path - db directory
*/
/*static*/ void Database::closeDatabase( const char *db, const string& path ) {
assertInWriteLock();
Client::Context * ctx = cc().getContext();
assert( ctx );
assert( ctx->inDB( db , path ) );
Database *database = ctx->db();
assert( database->name == db );
oplogCheckCloseDatabase( database ); // oplog caches some things, dirty its caches
if( BackgroundOperation::inProgForDb(db) ) {
log() << "warning: bg op in prog during close db? " << db << endl;
}
/* important: kill all open cursors on the database */
string prefix(db);
prefix += '.';
ClientCursor::invalidate(prefix.c_str());
NamespaceDetailsTransient::clearForPrefix( prefix.c_str() );
dbHolder.erase( db, path );
ctx->clear();
delete database; // closes files
}
示例2: Base
Base() : lk(ns()), _context( ns() ) {
_database = _context.db();
_collection = _database->getCollection( ns() );
if ( _collection ) {
_database->dropCollection( &_txn, ns() );
}
_collection = _database->createCollection( &_txn, ns() );
addIndex( fromjson( "{\"a\":1}" ) );
}
示例3: getDbContext
string getDbContext() {
stringstream ss;
Client * c = currentClient.get();
if ( c ) {
Client::Context * cx = c->getContext();
if ( cx ) {
Database *database = cx->db();
if ( database ) {
ss << database->name() << ' ';
ss << cx->ns() << ' ';
}
}
}
return ss.str();
}
示例4: build
Status IndexBuilder::build( Client::Context& context ) const {
string ns = _index["ns"].String();
Database* db = context.db();
Collection* c = db->getCollection( ns );
if ( !c ) {
c = db->getOrCreateCollection( ns );
verify(c);
}
Status status = c->getIndexCatalog()->createIndex( _index,
true,
IndexCatalog::SHUTDOWN_LEAVE_DIRTY );
if ( status.code() == ErrorCodes::IndexAlreadyExists )
return Status::OK();
return status;
}
示例5: build
Status IndexBuilder::build(TransactionExperiment* txn,
Client::Context& context ) const {
string ns = _index["ns"].String();
Database* db = context.db();
Collection* c = db->getCollection( ns );
if ( !c ) {
c = db->getOrCreateCollection( ns );
verify(c);
}
// Show which index we're building in the curop display.
context.getClient()->curop()->setQuery(_index);
Status status = c->getIndexCatalog()->createIndex( txn,
_index,
true,
IndexCatalog::SHUTDOWN_LEAVE_DIRTY );
if ( status.code() == ErrorCodes::IndexAlreadyExists )
return Status::OK();
return status;
}
示例6: db
Database* db() const {
return _context.db();
}
示例7: ns
virtual ~Base() {
DurTransaction txn;
if ( !nsd() )
return;
_context.db()->dropCollection( &txn, ns() );
}
示例8: ns
virtual ~Base() {
OperationContextImpl txn;
if ( !nsd() )
return;
_context.db()->dropCollection( &txn, ns() );
}