]> git.sesse.net Git - plocate/blobdiff - turbopfor.h
Switch to our own TurboPFor encoder.
[plocate] / turbopfor.h
index 179670845fd146a79462b9b8c52ce97f08642719..a21727a7375b0ab8df74772ae19110e6aa736c43 100644 (file)
@@ -25,6 +25,8 @@
 #include <immintrin.h>
 #endif
 
+#include "turbopfor-common.h"
+
 // Forward declarations to declare to the template code below that they exist.
 // (These must seemingly be non-templates for function multiversioning to work.)
 __attribute__((target("default")))
@@ -49,15 +51,6 @@ const unsigned char *
 decode_pfor_vb_interleaved_128_32(const unsigned char *in, uint32_t *out);
 #endif
 
-constexpr uint32_t mask_for_bits(unsigned bit_width)
-{
-       if (bit_width == 32) {
-               return 0xFFFFFFFF;
-       } else {
-               return (1U << bit_width) - 1;
-       }
-}
-
 template<class Docid>
 Docid read_le(const void *in)
 {
@@ -206,17 +199,6 @@ private:
 };
 #endif
 
-// Does not properly account for overflow.
-inline unsigned div_round_up(unsigned val, unsigned div)
-{
-       return (val + div - 1) / div;
-}
-
-inline unsigned bytes_for_packed_bits(unsigned num, unsigned bit_width)
-{
-       return div_round_up(num * bit_width, CHAR_BIT);
-}
-
 // Constant block. Layout:
 //
 //  - Bit width (6 bits) | type << 6
@@ -727,13 +709,6 @@ decode_pfor_vb_interleaved_128_32(const unsigned char *in, uint32_t *out)
        return in;
 }
 
-enum BlockType {
-       FOR = 0,
-       PFOR_VB = 1,
-       PFOR_BITMAP = 2,
-       CONSTANT = 3
-};
-
 template<unsigned BlockSize, class Docid>
 const unsigned char *decode_pfor_delta1(const unsigned char *in, unsigned num, bool interleaved, Docid *out)
 {