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

Method MakeSample

libs/search/search_quality/assessment_tool/context.cpp:36–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36search::Sample Context::MakeSample(search::FeatureLoader & loader) const
37{
38 search::Sample outSample = m_sample;
39
40 if (!m_initialized)
41 return outSample;
42
43 auto const & foundEntries = m_foundResultsEdits.GetEntries();
44 auto const & nonFoundEntries = m_nonFoundResultsEdits.GetEntries();
45
46 auto & outResults = outSample.m_results;
47 outResults.clear();
48
49 CHECK_EQUAL(m_goldenMatching.size(), m_sample.m_results.size(), ());
50 CHECK_EQUAL(m_actualMatching.size(), foundEntries.size(), ());
51 CHECK_EQUAL(m_actualMatching.size(), m_foundResults.GetCount(), ());
52
53 // Iterates over original (loaded from the file with search samples)
54 // results first.
55 size_t k = 0;
56 for (size_t i = 0; i < m_sample.m_results.size(); ++i)
57 {
58 auto const j = m_goldenMatching[i];
59
60 if (j == search::Matcher::kInvalidId)
61 {
62 auto const & entry = nonFoundEntries[k++];
63 auto const deleted = entry.m_deleted;
64 auto const & curr = entry.m_currRelevance;
65 if (!deleted && curr)
66 {
67 auto result = m_sample.m_results[i];
68 result.m_relevance = *curr;
69 outResults.push_back(result);
70 }
71 continue;
72 }
73
74 if (!foundEntries[j].m_currRelevance)
75 continue;
76
77 auto result = m_sample.m_results[i];
78 result.m_relevance = *foundEntries[j].m_currRelevance;
79 outResults.push_back(std::move(result));
80 }
81
82 // Iterates over results retrieved during assessment.
83 for (size_t i = 0; i < m_foundResults.GetCount(); ++i)
84 {
85 auto const j = m_actualMatching[i];
86 if (j != search::Matcher::kInvalidId)
87 {
88 // This result was processed by the loop above.
89 continue;
90 }
91
92 if (!foundEntries[i].m_currRelevance)
93 continue;

Callers 1

MakeSamplesMethod · 0.80

Calls 8

BuildFunction · 0.85
clearMethod · 0.45
sizeMethod · 0.45
GetCountMethod · 0.45
push_backMethod · 0.45
GetResultTypeMethod · 0.45
LoadMethod · 0.45
GetFeatureIDMethod · 0.45

Tested by

no test coverage detected