本文整理汇总了C++中ParsedQuery::getFields方法的典型用法代码示例。如果您正苦于以下问题:C++ ParsedQuery::getFields方法的具体用法?C++ ParsedQuery::getFields怎么用?C++ ParsedQuery::getFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParsedQuery
的用法示例。
在下文中一共展示了ParsedQuery::getFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tryQueryByPKHack
bool _tryQueryByPKHack(const char *ns, const BSONObj &query,
const ParsedQuery &pq, CurOp &curop, Message &result) {
BSONObj resObject;
bool found = false;
Collection *cl = getCollection(ns);
if (cl == NULL) {
return false; // ns doesn't exist, fall through to optimizer for legacy reasons
}
const BSONObj &pk = cl->getSimplePKFromQuery(query);
if (pk.isEmpty()) {
return false; // unable to query by PK - resort to using the optimizer
}
found = queryByPKHack(cl, pk, query, resObject);
if ( shardingState.needShardChunkManager( ns ) ) {
ShardChunkManagerPtr m = shardingState.getShardChunkManager( ns );
if ( m && ! m->belongsToMe( resObject ) ) {
// I have something for this _id
// but it doesn't belong to me
// so return nothing
resObject = BSONObj();
found = false;
}
}
BufBuilder bb(sizeof(QueryResult)+resObject.objsize()+32);
bb.skip(sizeof(QueryResult));
if ( found ) {
fillQueryResultFromObj( bb , pq.getFields() , resObject );
}
auto_ptr< QueryResult > qr( (QueryResult *) bb.buf() );
bb.decouple();
qr->setResultFlagsToOk();
qr->len = bb.len();
curop.debug().responseLength = bb.len();
qr->setOperation(opReply);
qr->cursorId = 0;
qr->startingFrom = 0;
qr->nReturned = found ? 1 : 0;
result.setData( qr.release(), true );
return true;
}