- // Only stay a certain amount ahead, so that we don't spend I/O
- // on reading the latter, large posting lists. We are unlikely
- // to need them anyway, even if they should come in first.
- if (engine.get_waiting_reads() >= 5) {
- engine.finish();
- if (done)
- break;
- }
- engine.submit_read(fd, len, trgmptr.offset, [trgmptr, len, &done, &in1, &in2, &out](string s) {
- if (done)
- return;
- uint32_t trgm __attribute__((unused)) = trgmptr.trgm;
- size_t num = trgmptr.num_docids;
- unsigned char *pldata = reinterpret_cast<unsigned char *>(s.data());
- if (in1.empty()) {
- in1.resize(num + 128);
- p4nd1dec128v32(pldata, num, &in1[0]);
- in1.resize(num);
- dprintf("trigram '%c%c%c' (%zu bytes) decoded to %zu entries\n", trgm & 0xff,
- (trgm >> 8) & 0xff, (trgm >> 16) & 0xff, len, num);
- } else {
- if (in2.size() < num + 128) {
- in2.resize(num + 128);
+ for (auto &[trgmptr, len] : td.read_trigrams) {
+ if (trigrams_submitted_read.count(trgmptr.trgm) != 0) {
+ continue;
+ }
+ trigrams_submitted_read.insert(trgmptr.trgm);
+ // Only stay a certain amount ahead, so that we don't spend I/O
+ // on reading the latter, large posting lists. We are unlikely
+ // to need them anyway, even if they should come in first.
+ if (engine.get_waiting_reads() >= 5) {
+ engine.finish();
+ if (done)
+ break;
+ }
+ engine.submit_read(fd, len, trgmptr.offset, [trgmptr{ trgmptr }, len{ len }, &done, &cur_candidates, &tmp, &decoded, &uses_trigram](string_view s) {
+ if (done)
+ return;
+
+ uint32_t trgm __attribute__((unused)) = trgmptr.trgm;
+ const unsigned char *pldata = reinterpret_cast<const unsigned char *>(s.data());
+ size_t num = trgmptr.num_docids;
+ decoded.resize(num);
+ decode_pfor_delta1_128(pldata, num, /*interleaved=*/true, &decoded[0]);
+
+ assert(uses_trigram.count(trgm) != 0);
+ bool was_empty = cur_candidates.empty();
+ if (ignore_case) {
+ dprintf("trigram %s (%zu bytes) decoded to %zu entries\n", print_trigram(trgm).c_str(), len, num);
+ }
+
+ for (TrigramDisjunction *td : uses_trigram[trgm]) {
+ done |= new_posting_list_read(td, decoded, &cur_candidates, &tmp);
+ if (done)
+ break;