MCPcopy Create free account
hub / github.com/comaps/comaps / Search

Method Search

libs/search/bookmarks/processor.cpp:204–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204void Processor::Search(Params const & params) const
205{
206 std::set<Id> ids;
207 auto insertId = [&ids](Id const & id, bool /* exactMatch */) { ids.insert(id); };
208
209 for (size_t i = 0; i < params.GetNumTokens(); ++i)
210 {
211 BailIfCancelled();
212
213 auto const & token = params.GetToken(i);
214 if (params.IsPrefixToken(i))
215 Retrieve<strings::PrefixDFAModifier<strings::LevenshteinDFA>>(token, insertId);
216 else
217 Retrieve<strings::LevenshteinDFA>(token, insertId);
218 }
219
220 IdfMap idfs(*this, 1.0 /* unknownIdf */);
221 auto qv = GetQueryVec(idfs, params);
222
223 std::vector<IdInfoPair> idInfos;
224 for (auto const & id : ids)
225 {
226 BailIfCancelled();
227
228 if (params.m_groupId != kInvalidGroupId)
229 {
230 auto const it = m_idToGroup.find(id);
231 if (it == m_idToGroup.end() || it->second != params.m_groupId)
232 continue;
233 }
234
235 auto it = m_docs.find(id);
236 CHECK(it != m_docs.end(), ("Can't find retrieved doc:", id));
237 auto const & doc = it->second;
238
239 RankingInfo info;
240 FillRankingInfo(qv, idfs, doc, info);
241
242 idInfos.emplace_back(id, info);
243 }
244
245 BailIfCancelled();
246 sort(idInfos.begin(), idInfos.end());
247
248 size_t numEmitted = 0;
249 for (auto const & idInfo : idInfos)
250 {
251 if (numEmitted >= params.m_maxNumResults)
252 break;
253 m_emitter.AddBookmarkResult(bookmarks::Result(idInfo.m_id));
254 ++numEmitted;
255 }
256}
257
258void Processor::Finish(bool cancelled)
259{

Callers

nothing calls this directly

Calls 11

BailIfCancelledFunction · 0.85
FillRankingInfoFunction · 0.85
IsPrefixTokenMethod · 0.80
ResultClass · 0.70
insertMethod · 0.45
GetNumTokensMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emplace_backMethod · 0.45
beginMethod · 0.45
AddBookmarkResultMethod · 0.45

Tested by

no test coverage detected