]> git.sesse.net Git - plocate/commitdiff
Implement support for larger basevals in TurboPFor.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 10 Oct 2020 20:24:27 +0000 (22:24 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 10 Oct 2020 20:24:27 +0000 (22:24 +0200)
turbopfor-encode.h
turbopfor.cpp

index e6e3cd5f13129767fef24bda95420b5cf1be9c35..9341efc0b7f4c23552f29dbd115bac508eb6cc1d 100644 (file)
@@ -52,6 +52,12 @@ unsigned char *write_baseval(Docid in, unsigned char *out)
                out[1] = in & 0xff;
                out[2] = (in >> 8) & 0xff;
                return out + 3;
+       } else if (in < 0x10000000) {
+               out[0] = (in >> 24) | 0xe0;
+               out[1] = (in >> 16) & 0xff;
+               out[2] = (in >> 8) & 0xff;
+               out[3] = in & 0xff;
+               return out + 4;
        } else {
                assert(false);  // Not implemented.
        }
index 8a91c33144d2843cf2d15d3277407bcb54066110..279a2f9cd9ec16a6920936f5f1081649a9964500 100644 (file)
@@ -74,6 +74,12 @@ const unsigned char *read_baseval(const unsigned char *in, Docid *out)
                        (uint32_t(in[2]) << 8) |
                        (uint32_t(in[1]))) & 0x1fffff;
                return in + 3;
+       } else if (*in < 240) {
+               *out = ((uint32_t(in[0]) << 24) |
+                       (uint32_t(in[1]) << 16) |
+                       (uint32_t(in[2]) << 8) |
+                       (uint32_t(in[3]))) & 0xfffffff;
+               return in + 4;
        } else {
                assert(false);  // Not implemented.
        }