本文整理汇总了C++中MatchDetails::hasLoadedRecord方法的典型用法代码示例。如果您正苦于以下问题:C++ MatchDetails::hasLoadedRecord方法的具体用法?C++ MatchDetails::hasLoadedRecord怎么用?C++ MatchDetails::hasLoadedRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatchDetails
的用法示例。
在下文中一共展示了MatchDetails::hasLoadedRecord方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: currentMatches
bool QueryResponseBuilder::currentMatches() {
MatchDetails details;
if ( _cursor->currentMatches( &details ) ) {
return true;
}
_explain->noteIterate( false, false, details.hasLoadedRecord(), false );
return false;
}
示例2: _process
/*
* Takes a cursor and updates the partial score for said cursor in _scores map
* @param cursor, btree cursor pointing to the current document to be scored
*/
void FTSSearch::_process( BtreeCursor* cursor ) {
_keysLookedAt++;
BSONObj key = cursor->currKey();
BSONObjIterator i( key );
for ( unsigned j = 0; j < _ftsSpec.numExtraBefore(); j++)
i.next();
i.next(); // move past indexToken
BSONElement scoreElement = i.next();
double score = scoreElement.number();
double& cur = _scores[(cursor->currLoc()).rec()];
if ( cur < 0 ) {
// already been rejected
return;
}
if ( cur == 0 && _matcher.get() ) {
// we haven't seen this before and we have a matcher
MatchDetails d;
if ( !_matcher->matchesCurrent( cursor, &d ) ) {
cur = -1;
}
if ( d.hasLoadedRecord() )
_objectsLookedAt++;
if ( cur == -1 )
return;
}
if ( cur )
cur += score * (1 + 1 / score);
else
cur += score;
}
示例3: run
bool run(const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl ) {
Timer t;
string ns = dbname + '.' + cmdObj.firstElement().valuestr();
string key = cmdObj["key"].valuestrsafe();
BSONObj keyPattern = BSON( key << 1 );
BSONObj query = getQuery( cmdObj );
int bufSize = BSONObjMaxUserSize - 4096;
BufBuilder bb( bufSize );
char * start = bb.buf();
BSONArrayBuilder arr( bb );
BSONElementSet values;
long long nscanned = 0; // locations looked at
long long nscannedObjects = 0; // full objects looked at
long long n = 0; // matches
MatchDetails md;
Collection *cl = getCollection( ns );
if ( ! cl ) {
result.appendArray( "values" , BSONObj() );
result.append( "stats" , BSON( "n" << 0 << "nscanned" << 0 << "nscannedObjects" << 0 ) );
return true;
}
shared_ptr<Cursor> cursor;
if ( ! query.isEmpty() ) {
cursor = getOptimizedCursor(ns.c_str() , query , BSONObj() );
}
else {
// query is empty, so lets see if we can find an index
// with the key so we don't have to hit the raw data
for (int i = 0; i < cl->nIndexes(); i++) {
IndexDetails &idx = cl->idx(i);
if (cl->isMultikey(i)) {
continue;
}
if ( idx.inKeyPattern( key ) ) {
cursor = getBestGuessCursor( ns.c_str() ,
BSONObj() ,
idx.keyPattern() );
if( cursor.get() ) break;
}
}
if ( ! cursor.get() ) {
cursor = getOptimizedCursor(ns.c_str() , query , BSONObj() );
}
}
verify( cursor );
string cursorName = cursor->toString();
auto_ptr<ClientCursor> cc (new ClientCursor(QueryOption_NoCursorTimeout, cursor, ns));
for ( ; cursor->ok(); cursor->advance() ) {
nscanned++;
bool loadedRecord = false;
if ( cursor->currentMatches( &md ) && !cursor->getsetdup( cursor->currPK() ) ) {
n++;
BSONObj holder;
BSONElementSet temp;
loadedRecord = ! cc->getFieldsDotted( key , temp, holder );
for ( BSONElementSet::iterator i=temp.begin(); i!=temp.end(); ++i ) {
BSONElement e = *i;
if ( values.count( e ) )
continue;
int now = bb.len();
uassert(10044, "distinct too big, 16mb cap", ( now + e.size() + 1024 ) < bufSize );
arr.append( e );
BSONElement x( start + now );
values.insert( x );
}
}
if ( loadedRecord || md.hasLoadedRecord() )
nscannedObjects++;
RARELY killCurrentOp.checkForInterrupt();
}
verify( start == bb.buf() );
result.appendArray( "values" , arr.done() );
//.........这里部分代码省略.........
示例4: run
//.........这里部分代码省略.........
NamespaceDetails::IndexIterator ii = d->ii();
while ( ii.more() ) {
IndexDetails& idx = ii.next();
if ( d->isMultikey( ii.pos() - 1 ) )
continue;
if ( idx.inKeyPattern( key ) ) {
cursor = getBestGuessCursor( ns.c_str(), BSONObj(), idx.keyPattern() );
if( cursor.get() ) break;
}
}
if ( ! cursor.get() )
cursor = getOptimizedCursor(ns.c_str() , query , BSONObj() );
}
verify( cursor );
string cursorName = cursor->toString();
auto_ptr<ClientCursor> cc (new ClientCursor(QueryOption_NoCursorTimeout, cursor, ns));
// map from indexed field to offset in key object
map<string, int> indexedFields;
if (!cursor->modifiedKeys()) {
// store index information so we can decide if we can
// get something out of the index key rather than full object
int x = 0;
BSONObjIterator i( cursor->indexKeyPattern() );
while ( i.more() ) {
BSONElement e = i.next();
if ( e.isNumber() ) {
// only want basic index fields, not "2d" etc
indexedFields[e.fieldName()] = x;
}
x++;
}
}
while ( cursor->ok() ) {
nscanned++;
bool loadedRecord = false;
if ( cursor->currentMatches( &md ) && !cursor->getsetdup( cursor->currLoc() ) ) {
n++;
BSONObj holder;
BSONElementSet temp;
// Try to get the record from the key fields.
loadedRecord = !getFieldsDotted(indexedFields, cursor, key, temp, holder);
for ( BSONElementSet::iterator i=temp.begin(); i!=temp.end(); ++i ) {
BSONElement e = *i;
if ( values.count( e ) )
continue;
int now = bb.len();
uassert(10044, "distinct too big, 16mb cap", ( now + e.size() + 1024 ) < bufSize );
arr.append( e );
BSONElement x( start + now );
values.insert( x );
}
}
if ( loadedRecord || md.hasLoadedRecord() )
nscannedObjects++;
cursor->advance();
if (!cc->yieldSometimes( ClientCursor::MaybeCovered )) {
cc.release();
break;
}
RARELY killCurrentOp.checkForInterrupt();
}
verify( start == bb.buf() );
result.appendArray( "values" , arr.done() );
{
BSONObjBuilder b;
b.appendNumber( "n" , n );
b.appendNumber( "nscanned" , nscanned );
b.appendNumber( "nscannedObjects" , nscannedObjects );
b.appendNumber( "timems" , t.millis() );
b.append( "cursor" , cursorName );
result.append( "stats" , b.obj() );
}
return true;
}