Commit 2b7d6e1d authored by Giuseppe Ottaviano's avatar Giuseppe Ottaviano Committed by Facebook GitHub Bot

Fix skip pointer population in EliasFanoCoding

Summary: Universe upper bound is inclusive, so we need to make sure that we have a pointer for `upperBitsUniverse / skipQuantum`. The bug has currently no effect as we use a tighter upper bound by reading the end of the list on construction, but it is necessary to fix this if we want to avoid doing that.

Reviewed By: yfeldblum, philippv, luciang

Differential Revision: D28886633

fbshipit-source-id: ba53fcc3f2ae1d52fe8e39576ad930754282ddd9
parent 0adab1a9
......@@ -191,16 +191,16 @@ struct EliasFanoEncoderV2 {
CHECK_EQ(size_, result_.size);
const ValueType upperBitsUniverse =
(8 * result_.upperSizeBytes - result_.size);
if (upperBitsUniverse > 0) {
// Populate skip pointers up to the universe upper bound.
fillSkipPointersUpTo(upperBitsUniverse - 1);
}
// Populate skip pointers up to the universe upper bound (inclusive).
fillSkipPointersUpTo(upperBitsUniverse);
return result_;
}
private:
void fillSkipPointersUpTo(ValueType fillBoundary) {
if constexpr (skipQuantum != 0) {
// The first skip pointer is omitted (it would always be 0), so the
// calculation is shifted by 1.
while ((skipPointersSize_ + 1) * skipQuantum <= fillBoundary) {
// Store the number of preceding 1-bits.
skipPointers_[skipPointersSize_++] = static_cast<SkipValueType>(size_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment