nlib
nn::nlib::GroupVarInt32 Class Reference

Class for encoding and decoding four 32-bit integer values as a unit. More...

#include "nn/nlib/GroupVarInt.h"

Static Public Member Functions

static size_t GetEncodedSize (uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3) noexcept
 Returns the size of the encoded four integer values. More...
 
static size_t GetEncodedSize (const uint32_t *p) noexcept
 Returns the size of the encoded four integer values. More...
 
static size_t GetNextGroupSize (const uint8_t *p) noexcept
 Returns the number of bytes to be used for decoding to the following four integer values. More...
 
static uint8_t * Encode (uint8_t *p, uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3) noexcept
 Encodes four 32-bit integer values. More...
 
static uint8_t * Encode (uint8_t *p, const uint32_t *src) noexcept
 Encodes four 32-bit integer values. More...
 
static const uint8_t * Decode (uint32_t *v0, uint32_t *v1, uint32_t *v2, uint32_t *v3, const uint8_t *p) noexcept
 Decodes four 32-bit integer values. More...
 
static const uint8_t * Decode (uint32_t *dest, const uint8_t *p) noexcept
 Decodes four 32-bit integer values. More...
 
static size_t GetMaxSize (size_t n) noexcept
 Returns the maximum size of encoded n integer values.
 
static size_t GetTotalSize (const uint32_t *p, size_t n) noexcept
 Returns the number of bytes required to store encoding results. More...
 

Detailed Description

Class for encoding and decoding four 32-bit integer values as a unit.

Description
Encodes four 32-bit integer values to 5-17 bytes. Describing information on the length of each integer value in the first byte can provide good performance through reduced shifts, masks, and conditional branches during decoding.
See also
https://static.googleusercontent.com/media/research.google.com/ja//people/jeff/WSDM09-keynote.pdf
https://web.stanford.edu/class/cs276/Jeff-Dean-compression-slides.pdf
http://www.stepanovpapers.com/CIKM_2011.pdf

Definition at line 26 of file GroupVarInt.h.

Member Function Documentation

◆ Decode() [1/2]

nn::nlib::GroupVarInt32::Decode ( uint32_t *  v0,
uint32_t *  v1,
uint32_t *  v2,
uint32_t *  v3,
const uint8_t *  p 
)
inlinestaticnoexcept

Decodes four 32-bit integer values.

Parameters
[out]v0Pointer for storing the decoded 32-bit integer value.
[out]v1Pointer for storing the decoded 32-bit integer value.
[out]v2Pointer for storing the decoded 32-bit integer value.
[out]v3Pointer for storing the decoded 32-bit integer value.
[in]pPointer to the encoded data.
Returns
Pointer to the location immediately after the data used for decoding.

Definition at line 219 of file GroupVarInt.h.

◆ Decode() [2/2]

nn::nlib::GroupVarInt32::Decode ( uint32_t *  dest,
const uint8_t *  p 
)
inlinestaticnoexcept

Decodes four 32-bit integer values.

Parameters
[out]destPointer for storing the four 32-bit integer values.
[in]pPointer to the encoded data.
Returns
Pointer to the location immediately after the data used for decoding.

Definition at line 210 of file GroupVarInt.h.

◆ Encode() [1/2]

nn::nlib::GroupVarInt32::Encode ( uint8_t *  p,
uint32_t  v0,
uint32_t  v1,
uint32_t  v2,
uint32_t  v3 
)
inlinestaticnoexcept

Encodes four 32-bit integer values.

Parameters
[out]pPointer to the location to which encoded data is written.
[in]v0The 32-bit integer value.
[in]v1The 32-bit integer value.
[in]v2The 32-bit integer value.
[in]v3The 32-bit integer value.
Returns
Pointer to the location immediately after the written data.

Definition at line 99 of file GroupVarInt.h.

◆ Encode() [2/2]

nn::nlib::GroupVarInt32::Encode ( uint8_t *  p,
const uint32_t *  src 
)
inlinestaticnoexcept

Encodes four 32-bit integer values.

Parameters
[out]pPointer to the location to which encoded data is written.
[in]srcPointer to the four 32-bit integer values.
Returns
Pointer to the location immediately after the written data.

Definition at line 86 of file GroupVarInt.h.

◆ GetEncodedSize() [1/2]

nn::nlib::GroupVarInt32::GetEncodedSize ( uint32_t  v0,
uint32_t  v1,
uint32_t  v2,
uint32_t  v3 
)
inlinestaticnoexcept

Returns the size of the encoded four integer values.

Parameters
[in]v0The 32-bit integer value.
[in]v1The 32-bit integer value.
[in]v2The 32-bit integer value.
[in]v3The 32-bit integer value.
Returns
Encoded size.

Definition at line 28 of file GroupVarInt.h.

◆ GetEncodedSize() [2/2]

nn::nlib::GroupVarInt32::GetEncodedSize ( const uint32_t *  p)
inlinestaticnoexcept

Returns the size of the encoded four integer values.

Parameters
[in]pPointer to 32-bit integer values (p[0], p[1], p[2], and p[3] are used).
Returns
Encoded size.

Definition at line 61 of file GroupVarInt.h.

◆ GetNextGroupSize()

nn::nlib::GroupVarInt32::GetNextGroupSize ( const uint8_t *  p)
inlinestaticnoexcept

Returns the number of bytes to be used for decoding to the following four integer values.

Parameters
[in]pPointer to the encoded byte string.
Returns
The number of bytes to be used for decoding.

Definition at line 65 of file GroupVarInt.h.

◆ GetTotalSize()

nn::nlib::GroupVarInt32::GetTotalSize ( const uint32_t *  p,
size_t  n 
)
inlinestaticnoexcept

Returns the number of bytes required to store encoding results.

Parameters
[in]pPointer to the 32-bit integer value string.
[in]nThe number of 32-bit integer values.
Returns
The number of bytes after encoding.

Definition at line 74 of file GroupVarInt.h.


The documentation for this class was generated from the following files: