本文整理汇总了C++中QueryResult::hasError方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult::hasError方法的具体用法?C++ QueryResult::hasError怎么用?C++ QueryResult::hasError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult
的用法示例。
在下文中一共展示了QueryResult::hasError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collect
void ResultCollectorImpl::collect(const QueryResult& queryResults)
{
if (queryResults.hasError())
{
m_result.setError(m_result.getErrorMsg() + queryResults.getErrorMsg());
}
else
{
m_result.setTotalHits(m_result.getTotalHits() + queryResults.getTotalHits());
if (queryResults.getTimeCost() > m_result.getTimeCost())
{
m_result.setTimeCost(queryResults.getTimeCost());
}
shardid_t shardId = -1;
QueryResult::Iterator it = queryResults.iterator();
while (it.hasNext())
{
const ResultDocPtr& pDoc = it.next();
m_pResultQueue->insert(pDoc);
shardId = pDoc->getShardId();
}
const QueryTracerPtr& pTracer = queryResults.getTracer();
if (pTracer.isNotNull())
{
if (m_result.getTracer().isNull())
{
m_result.setTracer(new QueryTracer("proxy", pTracer->getLevel()));
}
QueryTracerPtr& pResTracer = m_result.getTracer();
string str;
NumberFormatter::append(str, shardId);
pResTracer->addChildTracer(pTracer)->prependPath(str);
}
}
}
示例2: format
void XMLResultFormatter::format(const QueryResult& result,
std::stringstream& ss)
{
m_xmlDoc.clear();
m_xmlDoc.addDeclarationNode(result.getEncoding());
XMLNodeWrapperPtr pRootNode = m_xmlDoc.appendNode(
XMLDocumentWrapper::NODE_ELEMENT, "result");
if (result.hasError())
{
formatError(pRootNode, result.getErrorMsg());
}
else
{
XMLNodeWrapperPtr resultNode = pRootNode->appendNode(
XMLDocumentWrapper::NODE_ELEMENT, "hits");
string str;
NumberFormatter::append(str, (int32_t)result.size());
resultNode->appendAttribute("number_hits", str);
str.clear();
NumberFormatter::append(str, result.getTotalHits());
resultNode->appendAttribute("total_hits", str);
str.clear();
NumberFormatter::append(str, result.getTimeCost());
resultNode->appendAttribute("cost", str);
QueryResult::Iterator it = result.iterator();
while (it.hasNext())
{
XMLNodeWrapperPtr pHitNode = resultNode->appendNode(
XMLDocumentWrapper::NODE_ELEMENT, "hit");
const ResultDocPtr& pResDoc = it.next();
if (result.hasShardId())
{
str.clear();
NumberFormatter::append(str, pResDoc->getShardId());
pHitNode->appendNode(XMLDocumentWrapper::NODE_ELEMENT,
"shardid", str);
}
if (result.hasDocId())
{
str.clear();
NumberFormatter::append(str, pResDoc->getDocId());
pHitNode->appendNode(XMLDocumentWrapper::NODE_ELEMENT,
"docid", str);
}
if (result.hasScore())
{
str.clear();
NumberFormatter::append(str, pResDoc->getScore(), 2);
pHitNode->appendNode(XMLDocumentWrapper::NODE_ELEMENT,
"score", str);
}
if (result.hasFields())
{
XMLNodeWrapperPtr pFieldsNode = pHitNode->appendNode(
XMLDocumentWrapper::NODE_ELEMENT, "fields");
ResultDoc::Iterator fieldIt = pResDoc->iterator();
while (fieldIt.hasNext())
{
const ResultDoc::Field& field = fieldIt.next();
XMLNodeWrapperPtr pCDataNode = pFieldsNode->appendNode(
XMLDocumentWrapper::NODE_ELEMENT, field.first);
pCDataNode->appendNode(XMLDocumentWrapper::NODE_CDATA,
"", field.second);
}
}
} // end while
const QueryTracerPtr& pTracer = result.getTracer();
if (pTracer)
{
formatTracer(pRootNode, pTracer);
}
}
m_xmlDoc.print(ss);
}