]> git.sesse.net Git - plocate/commitdiff
Remove the double filtering of too large posting lists; we would not even start I...
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 10 Oct 2020 08:33:36 +0000 (10:33 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 10 Oct 2020 08:33:36 +0000 (10:33 +0200)
plocate.cpp

index b095bb68797846095ff4a40a1e0ebe9e37245574..a908d30e0f4d67521d0691cc74fb3d8a1db1d5c9 100644 (file)
@@ -370,13 +370,12 @@ void do_search_file(const vector<string> &needles, const char *filename)
        dprintf("Corpus init done after %.1f ms.\n", 1e3 * duration<float>(steady_clock::now() - start).count());
 
        vector<pair<Trigram, size_t>> trigrams;
-       uint64_t shortest_so_far = numeric_limits<uint32_t>::max();
        for (const string &needle : needles) {
                if (needle.size() < 3)
                        continue;
                for (size_t i = 0; i < needle.size() - 2; ++i) {
                        uint32_t trgm = read_trigram(needle, i);
-                       corpus.find_trigram(trgm, [trgm, &trigrams, &shortest_so_far](const Trigram *trgmptr, size_t len) {
+                       corpus.find_trigram(trgm, [trgm, &trigrams](const Trigram *trgmptr, size_t len) {
                                if (trgmptr == nullptr) {
                                        dprintf("trigram %s isn't found, we abort the search\n", print_trigram(trgm).c_str());
                                        if (only_count) {
@@ -384,13 +383,7 @@ void do_search_file(const vector<string> &needles, const char *filename)
                                        }
                                        exit(0);
                                }
-                               if (trgmptr->num_docids > shortest_so_far * 100) {
-                                       dprintf("not loading trigram %s with %u docids, it would be ignored later anyway\n",
-                                               print_trigram(trgm).c_str(), trgmptr->num_docids);
-                               } else {
-                                       trigrams.emplace_back(*trgmptr, len);
-                                       shortest_so_far = std::min<uint64_t>(shortest_so_far, trgmptr->num_docids);
-                               }
+                               trigrams.emplace_back(*trgmptr, len);
                        });
                }
        }