本文整理汇总了C++中DocumentPtr::objectId方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentPtr::objectId方法的具体用法?C++ DocumentPtr::objectId怎么用?C++ DocumentPtr::objectId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentPtr
的用法示例。
在下文中一共展示了DocumentPtr::objectId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: similarTo
// ** Films::similarTo
SimilarFilmsArray Films::similarTo( const std::string& oid, int count ) const
{
SimilarFilmsArray result;
OID objectId = OID( oid );
CollectionPtr similars = m_target->collection( "similar" );
CursorPtr cursor = similars->find( QUERY( "$or" << ARRAY( DOCUMENT( "first" << oid ) << DOCUMENT( "second" << objectId ) ) ) );
DocumentPtr document;
while( (document = cursor->next()) ) {
// ** Read data from document
OID first = document->objectId( "first" );
OID second = document->objectId( "second" );
int value = document->integer( "value" );
// ** Decode similarity & accuracy
float similarity, accuracy;
decodeSimilarity( value, similarity, accuracy );
// ** Push similar film
Film film = filmById( first == objectId ? second : first );
Quality quality = qualityFromRange( similarity, m_similarityQuartiles );
result.push_back( SimilarFilm( film, similarity, accuracy, quality ) );
}
std::sort( result.begin(), result.end(), SimilarFilm::sortBySimilarity );
if( count ) {
result.resize( std::min( count, ( int )result.size() ) );
}
return result;
}