]> git.sesse.net Git - plocate/blobdiff - plocate-build.cpp
Implement support for larger basevals in TurboPFor.
[plocate] / plocate-build.cpp
index be8a818a868e9f796dd836361349c6031c684467..023aedb53339da12b0e5487f662d5193fca6943f 100644 (file)
@@ -2,20 +2,19 @@
 #include "turbopfor-encode.h"
 
 #include <algorithm>
-#include <arpa/inet.h>
 #include <assert.h>
 #include <chrono>
-#include <endian.h>
-#include <fcntl.h>
+#include <iosfwd>
 #include <math.h>
 #include <memory>
+#include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <string>
+#include <string_view>
 #include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <unordered_map>
+#include <utility>
 #include <vector>
 #include <zstd.h>
 
@@ -144,9 +143,17 @@ void PostingListBuilder::write_header(uint32_t docid)
 class Corpus {
 public:
        Corpus(FILE *outfp, size_t block_size)
-               : invindex(new PostingListBuilder *[NUM_TRIGRAMS]), outfp(outfp), block_size(block_size) {
+               : invindex(new PostingListBuilder *[NUM_TRIGRAMS]), outfp(outfp), block_size(block_size)
+       {
                fill(invindex.get(), invindex.get() + NUM_TRIGRAMS, nullptr);
        }
+       ~Corpus()
+       {
+               for (unsigned i = 0; i < NUM_TRIGRAMS; ++i) {
+                       delete invindex[i];
+               }
+       }
+
        void add_file(string filename);
        void flush_block();