本文整理汇总了C++中QueryResult::setError方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult::setError方法的具体用法?C++ QueryResult::setError怎么用?C++ QueryResult::setError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult
的用法示例。
在下文中一共展示了QueryResult::setError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setError
void SearchShardsBase::setError(const string& sErrorMsg)
{
stringstream ss;
XMLResultFormatter formatter;
QueryResult qResult;
qResult.setError(sErrorMsg);
formatter.format(qResult, ss);
m_sResult = ss.str();
}
示例2: formatError
//static
void SearchServiceClient::formatError(string& sResult, const string& sErrorMsg)
{
stringstream ss;
XMLResultFormatter formatter;
QueryResult qResult;
qResult.setError(sErrorMsg);
formatter.format(qResult, ss);
sResult = ss.str();
}
示例3: sendErrorMessage
void HTTPSearchService::sendErrorMessage(const string& sErrorMsg,
EvHttpRequestContext* pCtx) const
{
stringstream ss;
QueryResult result;
result.setError(sErrorMsg);
XMLResultFormatter formatter;
formatter.format(result, ss);
sendResponse(ss.str(), pCtx);
}
示例4: formatErrorMessage
void RPCSearchService::formatErrorMessage(string& sMsgResult,
const string& sErrorMsg) const
{
stringstream ss;
QueryResult result;
result.setError(sErrorMsg);
XMLResultFormatter formatter;
formatter.format(result, ss);
sMsgResult = ss.str();
}
示例5: collectPhaseTwoResult
void SearchShardsBase::collectPhaseTwoResult()
{
FX_DEBUG("Collect phase two result");
SEARCH_LATENCY_BEGIN();
QueryResult phaseTwoResult;
const QueryResult& qResult = m_pResultCollector->getResult();
phaseTwoResult.setTracer(qResult.getTracer());
int64_t nMaxTimeCost = 0;
m_shardResults.clear();
for (size_t i = 0; i < m_requestedShards.size(); ++i)
{
SearchShardBase* pShard = m_requestedShards[i];
const string& sResult = pShard->getResponse();
if (pShard->getStatus() != SearchReplicaBase::EC_OK)
{
stringstream ss;
ss << "Has error on shard: [" << pShard->getName()
<< "]: " << parseError(sResult);
FX_LOG(ERROR, ss.str().c_str());
setError(ss.str());
SEARCH_LATENCY_END(m_nPhaseTwoCollectLatency);
return;
}
FX_TRACE("Phase2 result: [%s]", sResult.c_str());
XMLResultParser parser;
QueryResultPtr& pTmpQRes = m_shardResults[pShard->getShardId()].second;
parser.parse(sResult, *(pTmpQRes));
if (pTmpQRes->getTimeCost() > nMaxTimeCost)
{
nMaxTimeCost = pTmpQRes->getTimeCost();
}
// merge trace information
QueryTracerPtr& pTracer = pTmpQRes->getTracer();
if (pTracer.isNotNull())
{
if (phaseTwoResult.getTracer().isNull())
{
phaseTwoResult.setTracer(new QueryTracer("proxy", pTracer->getLevel()));
}
string str;
NumberFormatter::append(str, pShard->getShardId());
phaseTwoResult.getTracer()->addChildTracer(pTracer)->prependPath(str);
}
}
// Merge hit docs
phaseTwoResult.setTotalHits(qResult.getTotalHits());
phaseTwoResult.setTimeCost(nMaxTimeCost + qResult.getTimeCost());
QueryResult::Iterator it = qResult.iterator();
while (it.hasNext())
{
const ResultDocPtr& pDoc = it.next();
shardid_t shardId = pDoc->getShardId();
FIRTEX_ASSERT2((size_t)shardId <= m_shards.size());
ResultPair& resPair = m_shardResults[shardId];
QueryResultPtr& pQResult2 = resPair.second;
if (pQResult2->hasError())
{
FX_LOG(ERROR, "Has error on shard: [%d], msg: [%s]",
pQResult2->getErrorMsg().c_str());
phaseTwoResult.setError(pQResult2->getErrorMsg());
break;
}
ResultDocPtr& pDoc2 = (*pQResult2)[resPair.first++];
pDoc2->setScore(pDoc->getScore());
phaseTwoResult.addDoc(pDoc2);
}
SEARCH_LATENCY_END(m_nPhaseTwoCollectLatency);
// Add query trace information
QueryTracerPtr& pResTracer = phaseTwoResult.getTracer();
if (pResTracer.isNotNull())
{
FX_QUERY_TRACE(DEBUG, pResTracer, "Phase one search latency: [%d] ms",
m_nPhaseOneLatency);
FX_QUERY_TRACE(DEBUG, pResTracer, "Phase one collection latency: [%d] ms",
m_nPhaseOneCollectLatency);
FX_QUERY_TRACE(DEBUG, pResTracer, "Phase two search latency: [%d] ms",
m_nPhaseTwoLatency);
FX_QUERY_TRACE(DEBUG, pResTracer, "Phase two collection latency: [%d] ms",
m_nPhaseTwoCollectLatency);
}
FX_DEBUG("Begin format result");
stringstream ss;
XMLResultFormatter formatter;
formatter.format(phaseTwoResult, ss);
m_sResult = ss.str();
FX_DEBUG("End format result");
}