Commit 3ac402b1 authored by Philip Pronin's avatar Philip Pronin Committed by Sara Golemon

CHECK EliasFanoCompressedList::encode input is sorted

Test Plan: fbconfig -r folly/experimental/test && fbmake runtests_opt

Reviewed By: chaoyc@fb.com

FB internal diff: D1141124
parent 20697de2
/* /*
* Copyright 2013 Facebook, Inc. * Copyright 2014 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -103,10 +103,13 @@ struct EliasFanoCompressedList { ...@@ -103,10 +103,13 @@ struct EliasFanoCompressedList {
encode(list, list + size, result); encode(list, list + size, result);
} }
// Range (begin, end) should be sorted.
template <class RandomAccessIterator> template <class RandomAccessIterator>
static void encode(RandomAccessIterator begin, static void encode(RandomAccessIterator begin,
RandomAccessIterator end, RandomAccessIterator end,
EliasFanoCompressedList& result) { EliasFanoCompressedList& result) {
CHECK(std::is_sorted(begin, end));
auto list = begin; auto list = begin;
const size_t size = end - begin; const size_t size = end - begin;
...@@ -115,8 +118,6 @@ struct EliasFanoCompressedList { ...@@ -115,8 +118,6 @@ struct EliasFanoCompressedList {
return; return;
} }
DCHECK(std::is_sorted(list, list + size));
const ValueType upperBound = list[size - 1]; const ValueType upperBound = list[size - 1];
uint8_t numLowerBits = defaultNumLowerBits(upperBound, size); uint8_t numLowerBits = defaultNumLowerBits(upperBound, 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