CHECK EliasFanoCompressedList::encode input is sorted
authorPhilip Pronin <philipp@fb.com>
Thu, 23 Jan 2014 23:20:09 +0000 (15:20 -0800)
committerSara Golemon <sgolemon@fb.com>
Thu, 6 Feb 2014 19:50:13 +0000 (11:50 -0800)
Test Plan: fbconfig -r folly/experimental/test && fbmake runtests_opt

Reviewed By: chaoyc@fb.com

FB internal diff: D1141124

folly/experimental/EliasFanoCoding.h

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