From: Steinar H. Gunderson Date: Wed, 30 Sep 2020 19:52:16 +0000 (+0200) Subject: Rerun clang-format. X-Git-Tag: 1.0.0~80 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=94cd9258309ac4316632b0376cb92b04397e789f;hp=15741411fbd21162f0ba06c55ddeadaf6efdd758;p=plocate Rerun clang-format. --- diff --git a/db.h b/db.h index d4baf53..dfdc0d5 100644 --- a/db.h +++ b/db.h @@ -4,13 +4,13 @@ #include struct Header { - char magic[8]; // "\0plocate"; + char magic[8]; // "\0plocate"; uint32_t version; // 0. uint32_t hashtable_size; uint32_t extra_ht_slots; uint64_t hash_table_offset_bytes; uint64_t filename_index_offset_bytes; -}; +}; struct Trigram { uint32_t trgm; diff --git a/io_uring_engine.cpp b/io_uring_engine.cpp index 7714cdb..fb0a4de 100644 --- a/io_uring_engine.cpp +++ b/io_uring_engine.cpp @@ -2,12 +2,12 @@ #ifndef WITHOUT_URING #include #endif +#include "io_uring_engine.h" + +#include +#include #include #include -#include -#include - -#include "io_uring_engine.h" using namespace std; @@ -163,5 +163,3 @@ void complete_pread(int fd, void *ptr, size_t len, off_t offset) offset -= ret; } } - - diff --git a/io_uring_engine.h b/io_uring_engine.h index 59a9d66..232b636 100644 --- a/io_uring_engine.h +++ b/io_uring_engine.h @@ -3,8 +3,8 @@ #include #include -#include #include +#include #ifndef WITHOUT_URING #include #endif diff --git a/plocate-build.cpp b/plocate-build.cpp index 40ce2ff..37a3271 100644 --- a/plocate-build.cpp +++ b/plocate-build.cpp @@ -1,3 +1,4 @@ +#include "db.h" #include "vp4.h" #include @@ -19,8 +20,6 @@ #include #include -#include "db.h" - #define P4NENC_BOUND(n) ((n + 127) / 128 + (n + 32) * sizeof(uint32_t)) #define dprintf(...) //#define dprintf(...) fprintf(stderr, __VA_ARGS__); @@ -304,7 +303,7 @@ unique_ptr create_hashtable(const Corpus &corpus, const vectorsecond.num_docids), 0}; + Trigram to_insert{ trgm, uint32_t(corpus.invindex.find(trgm)->second.num_docids), 0 }; uint32_t bucket = hash_trigram(trgm, ht_size); unsigned distance = 0; @@ -375,7 +374,7 @@ void do_build(const char *infile, const char *outfile, int block_size) unique_ptr hashtable; uint32_t ht_size = next_prime(all_trigrams.size()); constexpr unsigned num_overflow_slots = 16; - for ( ;; ) { + for (;;) { hashtable = create_hashtable(corpus, all_trigrams, ht_size, num_overflow_slots); if (hashtable == nullptr) { dprintf("Failed creating hash table of size %u, increasing by 5%% and trying again.\n", ht_size); diff --git a/plocate.cpp b/plocate.cpp index ea7a4e8..672ba52 100644 --- a/plocate.cpp +++ b/plocate.cpp @@ -1,6 +1,6 @@ #include "db.h" -#include "vp4.h" #include "io_uring_engine.h" +#include "vp4.h" #include #include @@ -103,7 +103,8 @@ public: void find_trigram(uint32_t trgm, function cb); void get_compressed_filename_block(uint32_t docid, function cb) const; size_t get_num_filename_blocks() const; - off_t offset_for_block(uint32_t docid) const { + off_t offset_for_block(uint32_t docid) const + { return hdr.filename_index_offset_bytes + docid * sizeof(uint64_t); } @@ -197,7 +198,7 @@ size_t scan_file_block(const string &needle, string_view compressed, block.resize(uncompressed_len + 1); size_t err = ZSTD_decompress(&block[0], block.size(), compressed.data(), - compressed.size()); + compressed.size()); if (ZSTD_isError(err)) { fprintf(stderr, "ZSTD_decompress(): %s\n", ZSTD_getErrorName(err)); exit(1); @@ -256,7 +257,7 @@ void scan_all_docids(const string &needle, int fd, const Corpus &corpus, IOUring for (uint32_t docid = io_docid; docid < last_docid; ++docid) { size_t relative_offset = offsets[docid] - offsets[io_docid]; size_t len = offsets[docid + 1] - offsets[docid]; - scan_file_block(needle, {&compressed[relative_offset], len}, &access_rx_cache); + scan_file_block(needle, { &compressed[relative_offset], len }, &access_rx_cache); } } } @@ -339,7 +340,8 @@ void do_search_file(const string &needle, const char *filename) break; } engine.submit_read(fd, len, trgmptr.offset, [trgmptr, len, &done, &in1, &in2, &out](string s) { - if (done) return; + if (done) + return; uint32_t trgm __attribute__((unused)) = trgmptr.trgm; size_t num = trgmptr.num_docids; unsigned char *pldata = reinterpret_cast(s.data());