本文整理汇总了C++中Hit::context方法的典型用法代码示例。如果您正苦于以下问题:C++ Hit::context方法的具体用法?C++ Hit::context怎么用?C++ Hit::context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hit
的用法示例。
在下文中一共展示了Hit::context方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exhausted
const HitList &
PhraseQueryNode::evaluateHits(HitList & hl) const
{
hl.clear();
_fieldInfo.clear();
if ( ! AndQueryNode::evaluate()) return hl;
HitList tmpHL;
unsigned int fullPhraseLen = size();
unsigned int currPhraseLen = 0;
std::vector<unsigned int> indexVector(fullPhraseLen, 0);
auto curr = static_cast<const QueryTerm *> ((*this)[currPhraseLen].get());
bool exhausted( curr->evaluateHits(tmpHL).empty());
for (; !exhausted; ) {
auto next = static_cast<const QueryTerm *>((*this)[currPhraseLen+1].get());
unsigned int & currIndex = indexVector[currPhraseLen];
unsigned int & nextIndex = indexVector[currPhraseLen+1];
const auto & currHit = curr->evaluateHits(tmpHL)[currIndex];
size_t firstPosition = currHit.pos();
uint32_t currElemId = currHit.elemId();
uint32_t currContext = currHit.context();
const HitList & nextHL = next->evaluateHits(tmpHL);
int diff(0);
size_t nextIndexMax = nextHL.size();
while ((nextIndex < nextIndexMax) &&
((nextHL[nextIndex].context() < currContext) ||
((nextHL[nextIndex].context() == currContext) && (nextHL[nextIndex].elemId() <= currElemId))) &&
((diff = nextHL[nextIndex].pos()-firstPosition) < 1))
{
nextIndex++;
}
if ((diff == 1) && (nextHL[nextIndex].context() == currContext) && (nextHL[nextIndex].elemId() == currElemId)) {
currPhraseLen++;
if ((currPhraseLen+1) == fullPhraseLen) {
Hit h = nextHL[indexVector[currPhraseLen]];
hl.push_back(h);
const QueryTerm::FieldInfo & fi = next->getFieldInfo(h.context());
updateFieldInfo(h.context(), hl.size() - 1, fi.getFieldLength());
currPhraseLen = 0;
indexVector[0]++;
}
} else {
currPhraseLen = 0;
indexVector[currPhraseLen]++;
}
curr = static_cast<const QueryTerm *>((*this)[currPhraseLen].get());
exhausted = (nextIndex >= nextIndexMax) || (indexVector[currPhraseLen] >= curr->evaluateHits(tmpHL).size());
}
return hl;
}