proxygen
folly::compression Namespace Reference

Namespaces

 detail
 
 instructions
 

Classes

struct  BitVectorCompressedListBase
 
struct  BitVectorEncoder
 
class  BitVectorReader
 
struct  EliasFanoCompressedListBase
 
struct  EliasFanoEncoderV2
 
class  EliasFanoReader
 

Typedefs

typedef BitVectorCompressedListBase< const uint8_t * > BitVectorCompressedList
 
typedef BitVectorCompressedListBase< uint8_t * > MutableBitVectorCompressedList
 
typedef EliasFanoCompressedListBase< const uint8_t * > EliasFanoCompressedList
 
typedef EliasFanoCompressedListBase< uint8_t * > MutableEliasFanoCompressedList
 

Functions

folly::Optional< instructions::TypeinstructionsOverride ()
 
template<class URNG >
std::vector< uint32_tgenerateRandomList (size_t n, uint32_t maxId, URNG &&g)
 
std::vector< uint32_tgenerateRandomList (size_t n, uint32_t maxId)
 
std::vector< uint32_tgenerateSeqList (uint32_t minId, uint32_t maxId, uint32_t step=1)
 
std::vector< uint32_tloadList (const std::string &filename)
 
template<class... Args>
void maybeTestPreviousValue (Args &&...)
 
template<class Vector , class Reader , class Index >
auto maybeTestPreviousValue (const Vector &data, Reader &reader, Index i) -> decltype(reader.previousValue(), void())
 
template<class... Args>
void maybeTestPrevious (Args &&...)
 
template<class Vector , class Reader , class Index >
auto maybeTestPrevious (const Vector &data, Reader &reader, Index i) -> decltype(reader.previous(), void())
 
template<class Reader , class List >
void testNext (const std::vector< uint32_t > &data, const List &list)
 
template<class Reader , class List >
void testSkip (const std::vector< uint32_t > &data, const List &list, size_t skipStep)
 
template<class Reader , class List >
void testSkip (const std::vector< uint32_t > &data, const List &list)
 
template<class Reader , class List >
void testSkipTo (const std::vector< uint32_t > &data, const List &list, size_t skipToStep)
 
template<class Reader , class List >
void testSkipTo (const std::vector< uint32_t > &data, const List &list)
 
template<class Reader , class List >
void testJump (const std::vector< uint32_t > &data, const List &list)
 
template<class Reader , class List >
void testJumpTo (const std::vector< uint32_t > &data, const List &list)
 
template<class Reader , class Encoder >
void testEmpty ()
 
template<class Reader , class Encoder >
void testAll (const std::vector< uint32_t > &data)
 
template<class Reader , class List >
void bmNext (const List &list, const std::vector< uint32_t > &data, size_t iters)
 
template<class Reader , class List >
void bmSkip (const List &list, const std::vector< uint32_t > &, size_t logAvgSkip, size_t iters)
 
template<class Reader , class List >
void bmSkipTo (const List &list, const std::vector< uint32_t > &data, size_t logAvgSkip, size_t iters)
 
template<class Reader , class List >
void bmJump (const List &list, const std::vector< uint32_t > &data, const std::vector< size_t > &order, size_t iters)
 
template<class Reader , class List >
void bmJumpTo (const List &list, const std::vector< uint32_t > &data, const std::vector< size_t > &order, size_t iters)
 
template<class F >
auto dispatchInstructions (F &&f) -> decltype(f(std::declval< instructions::Default >()))
 

Variables

constexpr size_t kCacheLineSize = 64
 

Typedef Documentation

Function Documentation

template<class Reader , class List >
void folly::compression::bmJump ( const List list,
const std::vector< uint32_t > &  data,
const std::vector< size_t > &  order,
size_t  iters 
)

Definition at line 385 of file CodingTestUtils.h.

References folly::doNotOptimizeAway(), and i.

389  {
390  CHECK(!data.empty());
391  CHECK_EQ(data.size(), order.size());
392 
393  Reader reader(list);
394  for (size_t i = 0, j = 0; i < iters; ++i, ++j) {
395  if (j == order.size()) {
396  j = 0;
397  }
398  reader.jump(order[j]);
399  folly::doNotOptimizeAway(reader.value());
400  }
401 }
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
Definition: Benchmark.h:258
template<class Reader , class List >
void folly::compression::bmJumpTo ( const List list,
const std::vector< uint32_t > &  data,
const std::vector< size_t > &  order,
size_t  iters 
)

Definition at line 404 of file CodingTestUtils.h.

References folly::doNotOptimizeAway(), i, and instructionsOverride().

408  {
409  CHECK(!data.empty());
410  CHECK_EQ(data.size(), order.size());
411 
412  Reader reader(list);
413  for (size_t i = 0, j = 0; i < iters; ++i, ++j) {
414  if (j == order.size()) {
415  j = 0;
416  }
417  reader.jumpTo(data[order[j]]);
418  folly::doNotOptimizeAway(reader.value());
419  }
420 }
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
Definition: Benchmark.h:258
template<class Reader , class List >
void folly::compression::bmNext ( const List list,
const std::vector< uint32_t > &  data,
size_t  iters 
)

Definition at line 324 of file CodingTestUtils.h.

References folly::doNotOptimizeAway(), i, and LIKELY.

324  {
325  if (data.empty()) {
326  return;
327  }
328 
329  Reader reader(list);
330  for (size_t i = 0; i < iters; ++i) {
331  if (LIKELY(reader.next())) {
332  folly::doNotOptimizeAway(reader.value());
333  } else {
334  reader.reset();
335  }
336  }
337 }
#define LIKELY(x)
Definition: Likely.h:47
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
Definition: Benchmark.h:258
template<class Reader , class List >
void folly::compression::bmSkip ( const List list,
const std::vector< uint32_t > &  ,
size_t  logAvgSkip,
size_t  iters 
)

Definition at line 340 of file CodingTestUtils.h.

References folly::doNotOptimizeAway(), i, LIKELY, and folly::gen::skip().

344  {
345  size_t avg = (size_t(1) << logAvgSkip);
346  size_t base = avg - (avg >> 2);
347  size_t mask = (avg > 1) ? (avg >> 1) - 1 : 0;
348 
349  Reader reader(list);
350  for (size_t i = 0; i < iters; ++i) {
351  size_t skip = base + (i & mask);
352  if (LIKELY(reader.skip(skip))) {
353  folly::doNotOptimizeAway(reader.value());
354  } else {
355  reader.reset();
356  }
357  }
358 }
#define LIKELY(x)
Definition: Likely.h:47
detail::Skip skip(size_t count)
Definition: Base-inl.h:2598
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
Definition: Benchmark.h:258
template<class Reader , class List >
void folly::compression::bmSkipTo ( const List list,
const std::vector< uint32_t > &  data,
size_t  logAvgSkip,
size_t  iters 
)

Definition at line 361 of file CodingTestUtils.h.

References folly::doNotOptimizeAway(), i, and folly::gen::skip().

365  {
366  size_t avg = (size_t(1) << logAvgSkip);
367  size_t base = avg - (avg >> 2);
368  size_t mask = (avg > 1) ? (avg >> 1) - 1 : 0;
369 
370  Reader reader(list);
371  for (size_t i = 0, j = -1; i < iters; ++i) {
372  size_t skip = base + (i & mask);
373  j += skip;
374  if (j >= data.size()) {
375  reader.reset();
376  j = -1;
377  }
378 
379  reader.skipTo(data[j]);
380  folly::doNotOptimizeAway(reader.value());
381  }
382 }
detail::Skip skip(size_t count)
Definition: Base-inl.h:2598
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
Definition: Benchmark.h:258
template<class F >
auto folly::compression::dispatchInstructions ( F &&  f) -> decltype(f(std::declval<instructions::Default>()))

Definition at line 425 of file CodingTestUtils.h.

References folly::compression::instructions::dispatch(), f, instructionsOverride(), and type.

Referenced by BENCHMARK(), Skip_ForwardQ128(), and SkipTo_SkipQ128().

426  {
427  if (auto type = instructionsOverride()) {
428  return instructions::dispatch(*type, std::forward<F>(f));
429  } else {
430  return instructions::dispatch(std::forward<F>(f));
431  }
432 }
folly::Optional< instructions::Type > instructionsOverride()
auto f
PskType type
auto dispatch(Type type, F &&f) -> decltype(f(std::declval< Default >()))
Definition: Instructions.h:175
template<class URNG >
std::vector<uint32_t> folly::compression::generateRandomList ( size_t  n,
uint32_t  maxId,
URNG &&  g 
)

Definition at line 39 of file CodingTestUtils.h.

References g(), uint32_t, and folly::value().

Referenced by BitVectorCodingTest::doTestAll(), EliasFanoCodingTest::doTestAll(), generateRandomList(), and bm::init().

39  {
40  CHECK_LT(n, 2 * maxId);
41  std::uniform_int_distribution<> uid(1, maxId);
42  std::unordered_set<uint32_t> dataset;
43  while (dataset.size() < n) {
44  uint32_t value = uid(g);
45  if (dataset.count(value) == 0) {
46  dataset.insert(value);
47  }
48  }
49 
50  std::vector<uint32_t> ids(dataset.begin(), dataset.end());
51  std::sort(ids.begin(), ids.end());
52  return ids;
53 }
static const char *const value
Definition: Conv.cpp:50
g_t g(f_t)
std::vector<uint32_t> folly::compression::generateRandomList ( size_t  n,
uint32_t  maxId 
)
inline

Definition at line 55 of file CodingTestUtils.h.

References generateRandomList().

55  {
56  std::mt19937 gen;
57  return generateRandomList(n, maxId, gen);
58 }
std::vector< uint32_t > generateRandomList(size_t n, uint32_t maxId)
std::vector<uint32_t> folly::compression::generateSeqList ( uint32_t  minId,
uint32_t  maxId,
uint32_t  step = 1 
)
inline

Definition at line 61 of file CodingTestUtils.h.

References i, and uint32_t.

Referenced by BitVectorCodingTest::doTestAll(), and EliasFanoCodingTest::doTestAll().

61  {
62  CHECK_LE(minId, maxId);
63  CHECK_GT(step, 0);
64  std::vector<uint32_t> ids;
65  ids.reserve((maxId - minId) / step + 1);
66  for (uint32_t i = minId; i <= maxId; i += step) {
67  ids.push_back(i);
68  }
69  return ids;
70 }
folly::Optional< instructions::Type > folly::compression::instructionsOverride ( )

Definition at line 30 of file CodingTestUtils.cpp.

References folly::compression::instructions::DEFAULT, folly::compression::instructions::dispatch(), folly::FATAL, folly::compression::instructions::HASWELL, folly::compression::instructions::NEHALEM, folly::none, and type.

Referenced by bmJumpTo(), and dispatchInstructions().

30  {
31  if (FLAGS_coding_test_utils_instructions.empty()) {
32  return folly::none;
33  }
34 
36  if (FLAGS_coding_test_utils_instructions == "Default") {
37  type = instructions::Type::DEFAULT;
38  } else if (FLAGS_coding_test_utils_instructions == "Nehalem") {
39  type = instructions::Type::NEHALEM;
40  } else if (FLAGS_coding_test_utils_instructions == "Haswell") {
41  type = instructions::Type::HASWELL;
42  } else {
43  LOG(FATAL) << "Insupported instructions type "
44  << FLAGS_coding_test_utils_instructions;
45  }
46 
48  type, [](auto instructions) { CHECK(instructions.supported()); });
49 
50  return type;
51 }
PskType type
auto dispatch(Type type, F &&f) -> decltype(f(std::declval< Default >()))
Definition: Instructions.h:175
constexpr None none
Definition: Optional.h:87
std::vector<uint32_t> folly::compression::loadList ( const std::string filename)
inline

Definition at line 72 of file CodingTestUtils.h.

References testing::Args(), and uint32_t.

72  {
73  std::ifstream fin(filename);
74  std::vector<uint32_t> result;
75  uint32_t id;
76  while (fin >> id) {
77  result.push_back(id);
78  }
79  return result;
80 }
template<class... Args>
void folly::compression::maybeTestPrevious ( Args &&  ...)

Definition at line 99 of file CodingTestUtils.h.

Referenced by testJump(), testNext(), testSkip(), and testSkipTo().

99 {}
template<class Vector , class Reader , class Index >
auto folly::compression::maybeTestPrevious ( const Vector &  data,
Reader &  reader,
Index  i 
) -> decltype(reader.previous(), void())

Definition at line 105 of file CodingTestUtils.h.

References folly::data(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, and i.

106  {
107  auto r = reader.previous();
108  if (i != 0) {
109  EXPECT_TRUE(r);
110  EXPECT_EQ(reader.value(), data[i - 1]);
111  } else {
112  EXPECT_FALSE(r);
113  }
114  reader.next();
115  EXPECT_EQ(reader.value(), data[i]);
116 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
template<class... Args>
void folly::compression::maybeTestPreviousValue ( Args &&  ...)

Definition at line 84 of file CodingTestUtils.h.

Referenced by testJump(), testNext(), testSkip(), and testSkipTo().

84 {}
template<class Vector , class Reader , class Index >
auto folly::compression::maybeTestPreviousValue ( const Vector &  data,
Reader &  reader,
Index  i 
) -> decltype(reader.previousValue(), void())

Definition at line 90 of file CodingTestUtils.h.

References testing::Args(), folly::data(), EXPECT_EQ, and i.

91  {
92  if (i != 0) {
93  EXPECT_EQ(reader.previousValue(), data[i - 1]);
94  }
95 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
template<class Reader , class Encoder >
void folly::compression::testAll ( const std::vector< uint32_t > &  data)

Definition at line 313 of file CodingTestUtils.h.

References folly::data(), encode(), and bm::list.

313  {
314  auto list = Encoder::encode(data.begin(), data.end());
315  testNext<Reader>(data, list);
316  testSkip<Reader>(data, list);
317  testSkipTo<Reader>(data, list);
318  testJump<Reader>(data, list);
319  testJumpTo<Reader>(data, list);
320  list.free();
321 }
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
Encoder::MutableCompressedList list
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
template<class Reader , class Encoder >
void folly::compression::testEmpty ( )

Definition at line 290 of file CodingTestUtils.h.

References folly::data(), encode(), EXPECT_EQ, EXPECT_FALSE, and bm::list.

290  {
291  const typename Encoder::ValueType* const data = nullptr;
292  auto list = Encoder::encode(data, data);
293  {
294  Reader reader(list);
295  EXPECT_FALSE(reader.next());
296  EXPECT_EQ(reader.size(), 0);
297  }
298  {
299  Reader reader(list);
300  EXPECT_FALSE(reader.skip(1));
301  EXPECT_FALSE(reader.skip(10));
302  EXPECT_FALSE(reader.jump(0));
303  EXPECT_FALSE(reader.jump(10));
304  }
305  {
306  Reader reader(list);
307  EXPECT_FALSE(reader.skipTo(1));
308  EXPECT_FALSE(reader.jumpTo(1));
309  }
310 }
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Encoder::MutableCompressedList list
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
template<class Reader , class List >
void folly::compression::testJump ( const std::vector< uint32_t > &  data,
const List list 
)

Definition at line 234 of file CodingTestUtils.h.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, i, maybeTestPrevious(), and maybeTestPreviousValue().

234  {
235  std::mt19937 gen;
236  std::vector<size_t> is(data.size());
237  for (size_t i = 0; i < data.size(); ++i) {
238  is[i] = i;
239  }
240  std::shuffle(is.begin(), is.end(), gen);
241  if (Reader::EncoderType::forwardQuantum == 0) {
242  is.resize(std::min<size_t>(is.size(), 100));
243  }
244 
245  Reader reader(list);
246  for (auto i : is) {
247  EXPECT_TRUE(reader.jump(i));
248  EXPECT_EQ(reader.value(), data[i]);
249  EXPECT_EQ(reader.position(), i);
250  maybeTestPreviousValue(data, reader, i);
251  maybeTestPrevious(data, reader, i);
252  }
253  EXPECT_FALSE(reader.jump(data.size()));
254  EXPECT_FALSE(reader.valid());
255  EXPECT_EQ(reader.position(), reader.size());
256 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
auto maybeTestPrevious(const Vector &data, Reader &reader, Index i) -> decltype(reader.previous(), void())
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
auto maybeTestPreviousValue(const Vector &data, Reader &reader, Index i) -> decltype(reader.previousValue(), void())
template<class Reader , class List >
void folly::compression::testJumpTo ( const std::vector< uint32_t > &  data,
const List list 
)

Definition at line 259 of file CodingTestUtils.h.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, i, uint32_t, folly::value(), and values().

259  {
260  CHECK(!data.empty());
261 
262  Reader reader(list);
263 
264  std::mt19937 gen;
265  std::uniform_int_distribution<> values(0, data.back());
266  const size_t iters = Reader::EncoderType::skipQuantum == 0 ? 100 : 10000;
267  for (size_t i = 0; i < iters; ++i) {
268  const uint32_t value = values(gen);
269  auto it = std::lower_bound(data.begin(), data.end(), value);
270  CHECK(it != data.end());
271  EXPECT_TRUE(reader.jumpTo(value));
272  EXPECT_EQ(reader.value(), *it);
273  EXPECT_EQ(reader.position(), std::distance(data.begin(), it));
274  }
275 
276  EXPECT_TRUE(reader.jumpTo(0));
277  EXPECT_EQ(reader.value(), data[0]);
278  EXPECT_EQ(reader.position(), 0);
279 
280  EXPECT_TRUE(reader.jumpTo(data.back()));
281  EXPECT_EQ(reader.value(), data.back());
282  EXPECT_EQ(reader.position(), reader.size() - 1);
283 
284  EXPECT_FALSE(reader.jumpTo(data.back() + 1));
285  EXPECT_FALSE(reader.valid());
286  EXPECT_EQ(reader.position(), reader.size());
287 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
std::vector< int > values(1'000)
template<class Reader , class List >
void folly::compression::testNext ( const std::vector< uint32_t > &  data,
const List list 
)

Definition at line 119 of file CodingTestUtils.h.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, i, maybeTestPrevious(), and maybeTestPreviousValue().

119  {
120  Reader reader(list);
121  EXPECT_FALSE(reader.valid());
122 
123  for (size_t i = 0; i < data.size(); ++i) {
124  EXPECT_TRUE(reader.next());
125  EXPECT_TRUE(reader.valid());
126  EXPECT_EQ(reader.value(), data[i]);
127  EXPECT_EQ(reader.position(), i);
128  maybeTestPreviousValue(data, reader, i);
129  maybeTestPrevious(data, reader, i);
130  }
131  EXPECT_FALSE(reader.next());
132  EXPECT_FALSE(reader.valid());
133  EXPECT_EQ(reader.position(), reader.size());
134 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
auto maybeTestPrevious(const Vector &data, Reader &reader, Index i) -> decltype(reader.previous(), void())
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
auto maybeTestPreviousValue(const Vector &data, Reader &reader, Index i) -> decltype(reader.previousValue(), void())
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
template<class Reader , class List >
void folly::compression::testSkip ( const std::vector< uint32_t > &  data,
const List list,
size_t  skipStep 
)

Definition at line 137 of file CodingTestUtils.h.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, i, maybeTestPrevious(), and maybeTestPreviousValue().

140  {
141  CHECK_GT(skipStep, 0);
142  Reader reader(list);
143 
144  for (size_t i = skipStep - 1; i < data.size(); i += skipStep) {
145  EXPECT_TRUE(reader.skip(skipStep));
146  EXPECT_TRUE(reader.valid());
147  EXPECT_EQ(reader.value(), data[i]);
148  EXPECT_EQ(reader.position(), i);
149  maybeTestPreviousValue(data, reader, i);
150  maybeTestPrevious(data, reader, i);
151  }
152  EXPECT_FALSE(reader.skip(skipStep));
153  EXPECT_FALSE(reader.valid());
154  EXPECT_EQ(reader.position(), reader.size());
155  EXPECT_FALSE(reader.next());
156 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
auto maybeTestPrevious(const Vector &data, Reader &reader, Index i) -> decltype(reader.previous(), void())
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
auto maybeTestPreviousValue(const Vector &data, Reader &reader, Index i) -> decltype(reader.previousValue(), void())
template<class Reader , class List >
void folly::compression::testSkip ( const std::vector< uint32_t > &  data,
const List list 
)

Definition at line 159 of file CodingTestUtils.h.

References folly::data(), and bm::list.

159  {
160  for (size_t skipStep = 1; skipStep < 25; ++skipStep) {
161  testSkip<Reader, List>(data, list, skipStep);
162  }
163  for (size_t skipStep = 25; skipStep <= 500; skipStep += 25) {
164  testSkip<Reader, List>(data, list, skipStep);
165  }
166 }
Encoder::MutableCompressedList list
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
template<class Reader , class List >
void folly::compression::testSkipTo ( const std::vector< uint32_t > &  data,
const List list,
size_t  skipToStep 
)

Definition at line 169 of file CodingTestUtils.h.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, maybeTestPrevious(), maybeTestPreviousValue(), uint32_t, and folly::value().

172  {
173  CHECK_GT(skipToStep, 0);
174  Reader reader(list);
175 
176  const uint32_t delta = std::max<uint32_t>(1, data.back() / skipToStep);
177  uint32_t value = delta;
178  auto it = data.begin();
179  while (true) {
180  it = std::lower_bound(it, data.end(), value);
181  if (it == data.end()) {
182  EXPECT_FALSE(reader.skipTo(value));
183  break;
184  }
185  EXPECT_TRUE(reader.skipTo(value));
186  EXPECT_TRUE(reader.valid());
187  EXPECT_EQ(reader.value(), *it);
188  EXPECT_EQ(reader.position(), std::distance(data.begin(), it));
189  value = reader.value() + delta;
190  maybeTestPreviousValue(data, reader, std::distance(data.begin(), it));
191  maybeTestPrevious(data, reader, std::distance(data.begin(), it));
192  }
193  EXPECT_FALSE(reader.valid());
194  EXPECT_EQ(reader.position(), reader.size());
195  EXPECT_FALSE(reader.next());
196 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
auto maybeTestPrevious(const Vector &data, Reader &reader, Index i) -> decltype(reader.previous(), void())
static const char *const value
Definition: Conv.cpp:50
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
auto maybeTestPreviousValue(const Vector &data, Reader &reader, Index i) -> decltype(reader.previousValue(), void())
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
template<class Reader , class List >
void folly::compression::testSkipTo ( const std::vector< uint32_t > &  data,
const List list 
)

Definition at line 199 of file CodingTestUtils.h.

References folly::data(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, bm::list, max, and shell_builder::steps.

199  {
200  for (size_t steps = 10; steps < 100; steps += 10) {
201  testSkipTo<Reader, List>(data, list, steps);
202  }
203  for (size_t steps = 100; steps <= 1000; steps += 100) {
204  testSkipTo<Reader, List>(data, list, steps);
205  }
206  testSkipTo<Reader, List>(data, list, std::numeric_limits<size_t>::max());
207  {
208  // Skip to the first element.
209  Reader reader(list);
210  EXPECT_TRUE(reader.skipTo(data[0]));
211  EXPECT_EQ(reader.value(), data[0]);
212  EXPECT_EQ(reader.position(), 0);
213  }
214  {
215  // Skip past the last element.
216  Reader reader(list);
217  EXPECT_FALSE(reader.skipTo(data.back() + 1));
218  EXPECT_FALSE(reader.valid());
219  EXPECT_EQ(reader.position(), reader.size());
220  EXPECT_FALSE(reader.next());
221  }
222  {
223  // Skip to maximum integer.
224  Reader reader(list);
225  using ValueType = typename Reader::ValueType;
227  EXPECT_FALSE(reader.valid());
228  EXPECT_EQ(reader.position(), reader.size());
229  EXPECT_FALSE(reader.next());
230  }
231 }
LogLevel max
Definition: LogLevel.cpp:31
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Encoder::MutableCompressedList list
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43

Variable Documentation

constexpr size_t folly::compression::kCacheLineSize = 64

Definition at line 50 of file EliasFanoCoding.h.