本文整理汇总了C++中StringData::compare方法的典型用法代码示例。如果您正苦于以下问题:C++ StringData::compare方法的具体用法?C++ StringData::compare怎么用?C++ StringData::compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringData
的用法示例。
在下文中一共展示了StringData::compare方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: basicIsUpdatable
Status basicIsUpdatable(const FieldRef& field) {
StringData firstPart = field.getPart(0);
if (firstPart.compare("_id") == 0) {
return Status(ErrorCodes::BadValue, "updated cannot affect the _id");
}
return Status::OK();
}
示例2: aboutToDelete
/* must call this on a delete so we clean up the cursors. */
void ClientCursor::aboutToDelete(const StringData& ns,
const NamespaceDetails* nsd,
const DiskLoc& dl) {
// Begin cursor-only
NoPageFaultsAllowed npfa;
// End cursor-only
recursive_scoped_lock lock(ccmutex);
Database *db = cc().database();
verify(db);
aboutToDeleteForSharding( ns, db, nsd, dl );
// Check our non-cached active runner list.
for (set<Runner*>::iterator it = nonCachedRunners.begin(); it != nonCachedRunners.end();
++it) {
Runner* runner = *it;
if (0 == ns.compare(runner->ns())) {
runner->invalidate(dl);
}
}
// TODO: This requires optimization. We walk through *all* CCs and send the delete to every
// CC open on the db we're deleting from. We could:
// 1. Map from ns to open runners,
// 2. Map from ns -> (a map of DiskLoc -> runners who care about that DL)
//
// We could also queue invalidations somehow and have them processed later in the runner's
// read locks.
for (CCById::const_iterator it = clientCursorsById.begin(); it != clientCursorsById.end();
++it) {
ClientCursor* cc = it->second;
// We're only interested in cursors over one db.
if (cc->_db != db) { continue; }
if (NULL == cc->_runner.get()) { continue; }
cc->_runner->invalidate(dl);
}
}
示例3: compare
int SimpleStringDataComparator::compare(StringData left, StringData right) const {
return left.compare(right);
}
示例4: aboutToDelete
/* must call this on a delete so we clean up the cursors. */
void ClientCursor::aboutToDelete(const StringData& ns,
const NamespaceDetails* nsd,
const DiskLoc& dl) {
// Begin cursor-only
NoPageFaultsAllowed npfa;
// End cursor-only
recursive_scoped_lock lock(ccmutex);
Database *db = cc().database();
verify(db);
aboutToDeleteForSharding( ns, db, nsd, dl );
// Check our non-cached active runner list.
for (set<Runner*>::iterator it = nonCachedRunners.begin(); it != nonCachedRunners.end();
++it) {
Runner* runner = *it;
if (0 == ns.compare(runner->ns())) {
runner->invalidate(dl);
}
}
// TODO: This requires optimization. We walk through *all* CCs and send the delete to every
// CC open on the db we're deleting from. We could:
// 1. Map from ns to open runners,
// 2. Map from ns -> (a map of DiskLoc -> runners who care about that DL)
//
// We could also queue invalidations somehow and have them processed later in the runner's
// read locks.
for (CCById::const_iterator it = clientCursorsById.begin(); it != clientCursorsById.end();
++it) {
ClientCursor* cc = it->second;
// We're only interested in cursors over one db.
if (cc->_db != db) { continue; }
if (NULL == cc->_runner.get()) { continue; }
cc->_runner->invalidate(dl);
}
// Begin cursor-only. Only cursors that are in ccByLoc are processed here.
CCByLoc& bl = db->ccByLoc();
CCByLoc::iterator j = bl.lower_bound(ByLocKey::min(dl));
CCByLoc::iterator stop = bl.upper_bound(ByLocKey::max(dl));
if ( j == stop )
return;
vector<ClientCursor*> toAdvance;
while ( 1 ) {
toAdvance.push_back(j->second);
DEV verify( j->first.loc == dl );
++j;
if ( j == stop )
break;
}
if( toAdvance.size() >= 3000 ) {
log() << "perf warning MPW101: " << toAdvance.size() << " cursors for one diskloc "
<< dl.toString()
<< ' ' << toAdvance[1000]->_ns
<< ' ' << toAdvance[2000]->_ns
<< ' ' << toAdvance[1000]->_pinValue
<< ' ' << toAdvance[2000]->_pinValue
<< ' ' << toAdvance[1000]->_pos
<< ' ' << toAdvance[2000]->_pos
<< ' ' << toAdvance[1000]->_idleAgeMillis
<< ' ' << toAdvance[2000]->_idleAgeMillis
<< ' ' << toAdvance[1000]->_doingDeletes
<< ' ' << toAdvance[2000]->_doingDeletes
<< endl;
//wassert( toAdvance.size() < 5000 );
}
for ( vector<ClientCursor*>::iterator i = toAdvance.begin(); i != toAdvance.end(); ++i ) {
ClientCursor* cc = *i;
wassert(cc->_db == db);
if ( cc->_doingDeletes ) continue;
Cursor *c = cc->_c.get();
if ( c->capped() ) {
/* note we cannot advance here. if this condition occurs, writes to the oplog
have "caught" the reader. skipping ahead, the reader would miss postentially
important data.
*/
delete cc;
continue;
}
c->recoverFromYield();
DiskLoc tmp1 = c->refLoc();
if ( tmp1 != dl ) {
// This might indicate a failure to call ClientCursor::prepareToYield() but it can
// also happen during correct operation, see SERVER-2009.
problem() << "warning: cursor loc " << tmp1 << " does not match byLoc position " << dl << " !" << endl;
}
else {
//.........这里部分代码省略.........
示例5: equals
bool IdWrapper::equals(StringData sd) const {
return sd.compare(toString()) == 0;
}