Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::detail::snappy Namespace Reference

Functions

size_t encode_varint32 (uint8_t *dst, uint32_t value)
 Encode a 32-bit unsigned integer as a Snappy varint (1-5 bytes).
 
bool decode_varint32 (const uint8_t *data, size_t size, size_t &pos, uint32_t &out)
 Decode a Snappy varint from the input stream.
 
uint32_t load_le32 (const uint8_t *p)
 Read a 32-bit little-endian value from a potentially unaligned pointer.
 
uint16_t load_le16 (const uint8_t *p)
 Read a 16-bit little-endian value from a potentially unaligned pointer.
 
void store_le16 (uint8_t *p, uint16_t v)
 Write a 16-bit little-endian value.
 
void store_le32 (uint8_t *p, uint32_t v)
 Write a 32-bit little-endian value.
 
uint32_t hash4 (const uint8_t *p)
 14-bit hash of 4 bytes read as a little-endian uint32.
 
void emit_literal (std::vector< uint8_t > &out, const uint8_t *data, size_t length)
 Emit a literal element.
 
void emit_copy (std::vector< uint8_t > &out, uint32_t offset, uint32_t length)
 Emit a copy element.
 
uint32_t match_length (const uint8_t *src, size_t s1, size_t s2, size_t src_end)
 Find the match length between src[s1..] and src[s2..], bounded by src_end.
 

Function Documentation

◆ decode_varint32()

bool signet::forge::detail::snappy::decode_varint32 ( const uint8_t *  data,
size_t  size,
size_t &  pos,
uint32_t &  out 
)
inline

Decode a Snappy varint from the input stream.

On success, advances pos past the varint and writes the value to out. Returns false if the varint is truncated or exceeds 32 bits.

Definition at line 59 of file snappy.hpp.

◆ emit_copy()

void signet::forge::detail::snappy::emit_copy ( std::vector< uint8_t > &  out,
uint32_t  offset,
uint32_t  length 
)
inline

Emit a copy element.

Chooses the most compact encoding for the given offset and length.

Definition at line 172 of file snappy.hpp.

◆ emit_literal()

void signet::forge::detail::snappy::emit_literal ( std::vector< uint8_t > &  out,
const uint8_t *  data,
size_t  length 
)
inline

Emit a literal element.

data points to the literal bytes, length is the number of bytes (must be >= 1).

Definition at line 133 of file snappy.hpp.

◆ encode_varint32()

size_t signet::forge::detail::snappy::encode_varint32 ( uint8_t *  dst,
uint32_t  value 
)
inline

Encode a 32-bit unsigned integer as a Snappy varint (1-5 bytes).

Returns the number of bytes written.

Definition at line 46 of file snappy.hpp.

◆ hash4()

uint32_t signet::forge::detail::snappy::hash4 ( const uint8_t *  p)
inline

14-bit hash of 4 bytes read as a little-endian uint32.

The constant and shift are chosen to distribute typical byte patterns across the 16384-entry hash table.

Definition at line 120 of file snappy.hpp.

◆ load_le16()

uint16_t signet::forge::detail::snappy::load_le16 ( const uint8_t *  p)
inline

Read a 16-bit little-endian value from a potentially unaligned pointer.

Definition at line 90 of file snappy.hpp.

◆ load_le32()

uint32_t signet::forge::detail::snappy::load_le32 ( const uint8_t *  p)
inline

Read a 32-bit little-endian value from a potentially unaligned pointer.

Definition at line 80 of file snappy.hpp.

◆ match_length()

uint32_t signet::forge::detail::snappy::match_length ( const uint8_t *  src,
size_t  s1,
size_t  s2,
size_t  src_end 
)
inline

Find the match length between src[s1..] and src[s2..], bounded by src_end.

Returns the number of matching bytes (0 if first byte differs). CWE-125: Out-of-bounds Read — bounds guard prevents reading past src_end.

Definition at line 211 of file snappy.hpp.

◆ store_le16()

void signet::forge::detail::snappy::store_le16 ( uint8_t *  p,
uint16_t  v 
)
inline

Write a 16-bit little-endian value.

Definition at line 100 of file snappy.hpp.

◆ store_le32()

void signet::forge::detail::snappy::store_le32 ( uint8_t *  p,
uint32_t  v 
)
inline

Write a 32-bit little-endian value.

Definition at line 108 of file snappy.hpp.