#include "db.h"
#include "io_uring_engine.h"
-#include "vp4.h"
#include <algorithm>
#include <arpa/inet.h>
#include <fcntl.h>
#include <functional>
#include <getopt.h>
+#include <limits.h>
#include <memory>
#include <stdio.h>
#include <string.h>
#define dprintf(...)
//#define dprintf(...) fprintf(stderr, __VA_ARGS__);
+#include "turbopfor.h"
+
const char *dbpath = "/var/lib/mlocate/plocate.db";
bool print_nul = false;
void Corpus::find_trigram(uint32_t trgm, function<void(const Trigram *trgmptr, size_t len)> cb)
{
uint32_t bucket = hash_trigram(trgm, hdr.hashtable_size);
- engine->submit_read(fd, sizeof(Trigram) * (hdr.extra_ht_slots + 2), hdr.hash_table_offset_bytes + sizeof(Trigram) * bucket, [this, trgm, bucket, cb{ move(cb) }](string s) {
+ engine->submit_read(fd, sizeof(Trigram) * (hdr.extra_ht_slots + 2), hdr.hash_table_offset_bytes + sizeof(Trigram) * bucket, [this, trgm, cb{ move(cb) }](string s) {
const Trigram *trgmptr = reinterpret_cast<const Trigram *>(s.data());
for (unsigned i = 0; i < hdr.extra_ht_slots + 1; ++i) {
if (trgmptr[i].trgm == trgm) {
if (done)
break;
}
- engine.submit_read(fd, len, trgmptr.offset, [trgmptr, len, &done, &in1, &in2, &out](string s) {
+ engine.submit_read(fd, len, trgmptr.offset, [trgmptr{trgmptr}, len{len}, &done, &in1, &in2, &out](string s) {
if (done)
return;
uint32_t trgm __attribute__((unused)) = trgmptr.trgm;
unsigned char *pldata = reinterpret_cast<unsigned char *>(s.data());
if (in1.empty()) {
in1.resize(num + 128);
- p4nd1dec32(pldata, num, &in1[0]);
+ decode_pfor_delta1<128>(pldata, num, /*interleaved=*/true, &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);
if (in2.size() < num + 128) {
in2.resize(num + 128);
}
- p4nd1dec32(pldata, num, &in2[0]);
+ decode_pfor_delta1<128>(pldata, num, /*interleaved=*/true, &in2[0]);
out.clear();
set_intersection(in1.begin(), in1.end(), in2.begin(), in2.begin() + num,