proxygen
folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout Struct Reference

#include <EliasFanoCoding.h>

Public Member Functions

size_t bytes () const
 
template<class Range >
EliasFanoCompressedListBase< typename Range::iteratoropenList (Range &buf) const
 
MutableCompressedList allocList () const
 

Static Public Member Functions

static Layout fromUpperBoundAndSize (size_t upperBound, size_t size)
 
static Layout fromInternalSizes (uint8_t numLowerBits, size_t upper, size_t size)
 

Public Attributes

size_t size = 0
 
uint8_t numLowerBits = 0
 
size_t lower = 0
 
size_t upper = 0
 
size_t skipPointers = 0
 
size_t forwardPointers = 0
 

Detailed Description

template<class Value, class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
struct folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout

Definition at line 228 of file EliasFanoCoding.h.

Member Function Documentation

template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
MutableCompressedList folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::allocList ( ) const
inline

Definition at line 310 of file EliasFanoCoding.h.

References folly::compression::EliasFanoCompressedListBase< Pointer >::size, and uint8_t.

310  {
311  uint8_t* buf = nullptr;
312  // WARNING: Current read/write logic assumes that the 7 bytes
313  // following the last byte of lower and upper sequences are
314  // readable (stored value doesn't matter and won't be changed), so
315  // we allocate additional 7 bytes, but do not include them in size
316  // of returned value.
317  if (size > 0) {
318  buf = static_cast<uint8_t*>(malloc(bytes() + 7));
319  }
320  folly::MutableByteRange bufRange(buf, bytes());
321  return openList(bufRange);
322  }
EliasFanoCompressedListBase< typename Range::iterator > openList(Range &buf) const
template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
static Layout folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::fromInternalSizes ( uint8_t  numLowerBits,
size_t  upper,
size_t  size 
)
inlinestatic

Definition at line 253 of file EliasFanoCoding.h.

References folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::forwardPointers, folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::lower, folly::compression::EliasFanoCompressedListBase< Pointer >::numLowerBits, folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::numLowerBits, folly::compression::EliasFanoCompressedListBase< Pointer >::size, folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::size, folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::skipPointers, folly::compression::EliasFanoCompressedListBase< Pointer >::upper, and folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::upper.

253  {
254  Layout layout;
255  layout.size = size;
256  layout.numLowerBits = numLowerBits;
257 
258  layout.lower = (numLowerBits * size + 7) / 8;
259  layout.upper = upper;
260 
261  // *** Skip pointers.
262  // Store (1-indexed) position of every skipQuantum-th
263  // 0-bit in upper bits sequence.
264  if /* constexpr */ (skipQuantum != 0) {
265  // 8 * upper is used here instead of upperSizeBits, as that is
266  // more serialization-friendly way (upperSizeBits doesn't need
267  // to be known by this function, unlike upper).
268 
269  size_t numSkipPointers = (8 * upper - size) / skipQuantum;
270  layout.skipPointers = numSkipPointers * sizeof(SkipValueType);
271  }
272 
273  // *** Forward pointers.
274  // Store (1-indexed) position of every forwardQuantum-th
275  // 1-bit in upper bits sequence.
276  if /* constexpr */ (forwardQuantum != 0) {
277  size_t numForwardPointers = size / forwardQuantum;
278  layout.forwardPointers = numForwardPointers * sizeof(SkipValueType);
279  }
280 
281  return layout;
282  }
static constexpr size_t forwardQuantum
template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
static Layout folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::fromUpperBoundAndSize ( size_t  upperBound,
size_t  size 
)
inlinestatic

Definition at line 230 of file EliasFanoCoding.h.

References max, min, folly::compression::EliasFanoCompressedListBase< Pointer >::numLowerBits, uint8_t, folly::compression::EliasFanoCompressedListBase< Pointer >::upper, and testing::Value().

230  {
231  // numLowerBits can be at most 56 because of detail::writeBits56.
232  const uint8_t numLowerBits =
233  std::min(defaultNumLowerBits(upperBound, size), uint8_t(56));
234  // *** Upper bits.
235  // Upper bits are stored using unary delta encoding.
236  // For example, (3 5 5 9) will be encoded as 1000011001000_2.
237  const size_t upperSizeBits =
238  (upperBound >> numLowerBits) + // Number of 0-bits to be stored.
239  size; // 1-bits.
240  const size_t upper = (upperSizeBits + 7) / 8;
241 
242  // *** Validity checks.
243  // Shift by numLowerBits must be valid.
244  CHECK_LT(numLowerBits, 8 * sizeof(Value));
246  CHECK_LT(
247  upperBound >> numLowerBits, std::numeric_limits<SkipValueType>::max());
248 
249  return fromInternalSizes(numLowerBits, upper, size);
250  }
LogLevel max
Definition: LogLevel.cpp:31
static Layout fromInternalSizes(uint8_t numLowerBits, size_t upper, size_t size)
LogLevel min
Definition: LogLevel.cpp:30
bool Value(const T &value, M matcher)
static uint8_t defaultNumLowerBits(size_t upperBound, size_t size)
template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
template<class Range >
EliasFanoCompressedListBase<typename Range::iterator> folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::openList ( Range buf) const
inline

Definition at line 289 of file EliasFanoCoding.h.

References folly::detail::advance, folly::Range< Iter >::advance(), folly::test::begin(), folly::compression::EliasFanoCompressedListBase< Pointer >::data, folly::Range< Iter >::data(), folly::compression::EliasFanoCompressedListBase< Pointer >::forwardPointers, folly::compression::EliasFanoCompressedListBase< Pointer >::lower, folly::compression::EliasFanoCompressedListBase< Pointer >::numLowerBits, folly::compression::EliasFanoCompressedListBase< Pointer >::size, folly::compression::EliasFanoCompressedListBase< Pointer >::skipPointers, folly::Range< Iter >::subpiece(), and folly::compression::EliasFanoCompressedListBase< Pointer >::upper.

290  {
291  EliasFanoCompressedListBase<typename Range::iterator> result;
292  result.size = size;
293  result.numLowerBits = numLowerBits;
294  result.data = buf.subpiece(0, bytes());
295 
296  auto advance = [&](size_t n) {
297  auto begin = buf.data();
298  buf.advance(n);
299  return begin;
300  };
301 
302  result.skipPointers = advance(skipPointers);
303  result.forwardPointers = advance(forwardPointers);
304  result.lower = advance(lower);
305  result.upper = advance(upper);
306 
307  return result;
308  }
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56

Member Data Documentation

template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
size_t folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::forwardPointers = 0
template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
size_t folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::lower = 0
template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
uint8_t folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::numLowerBits = 0
template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
size_t folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::size = 0
template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
size_t folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::skipPointers = 0
template<class Value , class SkipValue = size_t, size_t kSkipQuantum = 0, size_t kForwardQuantum = 0>
size_t folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::upper = 0

The documentation for this struct was generated from the following file: