Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::detail Namespace Reference

Classes

struct  BPlusTreeNode
 
struct  BTreeNode
 
struct  is_stream_insertable
 
struct  is_stream_insertable< T, std::void_t< decltype(std::declval< std::ostringstream & >()<< std::declval< T >())> >
 
struct  Ordered_Tree_Snapshot_Header
 
struct  Paged_Bounded_String_Codec
 
struct  Paged_Value_Codec
 
struct  Paged_Value_Codec< std::array< T, N > >
 
struct  Paged_Value_Codec< T >
 
class  Pid_File_Lock
 
struct  SPP_ITri
 
struct  SPP_Portal
 

Concepts

concept  Fixed_Paged_Value_Codec
 

Enumerations

enum class  Pid_File_Lock_Mode : std::uint8_t { Shared , Exclusive }
 

Functions

void build_msg_impl (std::ostringstream &)
 
template<typename T , typename... Args>
void build_msg_impl (std::ostringstream &stream, T &&value, Args &&... rest)
 
template<typename Container , typename Pred >
bool fallback_all_of (const Container &c, Pred &&pred)
 
template<typename Container , typename Pred >
bool fallback_any_of (const Container &c, Pred &&pred)
 
template<typename Container , typename Pred >
bool fallback_none_of (const Container &c, Pred &&pred)
 
template<typename Container , typename T , typename BinaryOp >
constexpr T ranges_fold_left (Container &&c, T init, BinaryOp &&op)
 Fallback fold_left using range-based for loop.
 
template<typename Container , typename Pred >
bool ranges_all_of (const Container &c, Pred &&pred)
 Fallback all_of using range-based for loop.
 
template<typename Container , typename Pred >
bool ranges_any_of (const Container &c, Pred &&pred)
 Fallback any_of using range-based for loop.
 
template<typename Container , typename Pred >
bool ranges_none_of (const Container &c, Pred &&pred)
 Fallback none_of using range-based for loop.
 
template<typename Container , typename Pred >
auto ranges_count_if (const Container &c, Pred &&pred)
 Fallback count_if using range-based for loop.
 
uint64_t pollard_rho_step (const uint64_t n, const uint64_t seed, const uint64_t c)
 Inner function for Pollard's rho algorithm.
 
uint64_t find_any_factor (const uint64_t n)
 Helper to repeatedly apply Pollard's rho until a factor is found.
 
void extract_prime_factors (const uint64_t n, Array< uint64_t > &factors)
 Recursive extraction of all prime factors.
 
bool check_composite (uint64_t n, uint64_t a, uint64_t d, int s) noexcept
 Helper function for Miller-Rabin test.
 
std::string tikz_palette_color (const size_t idx)
 
size_t spp_find_index (const Array< Point > &pts, const Point &p)
 
Array< SPP_ITrispp_build_tris (const Array< Point > &pts, const DynList< Triangle > &tl)
 
bool spp_point_in_triangle (const Array< Point > &pts, const SPP_ITri &t, const Point &p)
 
size_t spp_find_tri (const Array< Point > &pts, const Array< SPP_ITri > &tris, const Point &p)
 
Array< size_t > spp_find_sleeve (const Array< SPP_ITri > &tris, const size_t src, const size_t dst)
 
Geom_Number spp_cross (const Point &a, const Point &b, const Point &c)
 
Array< SPP_Portalshortest_path_portals (const Polygon &polygon, const Point &source, const Point &target)
 
template<typename Compare , typename Key >
bool equiv (const Compare &cmp, const Key &lhs, const Key &rhs)
 
template<typename Compare , typename Key >
bool bplus_equiv (const Compare &cmp, const Key &lhs, const Key &rhs)
 
void sync_parent_directory (const std::string &path, const char *kind)
 
void sync_file_by_path (const std::string &path, const char *kind)
 
void sync_file_descriptor (const int fd, const std::string &path, const char *kind)
 
void remove_file_if_exists (const std::string &path, const char *kind)
 
void rename_file_atomic (const std::string &src, const std::string &dst, const char *kind)
 
void copy_file_contents (const std::string &src, const std::string &dst, const char *kind)
 
std::uint32_t crc32_begin () noexcept
 
std::uint32_t crc32_add_bytes (std::uint32_t crc, const void *data, const size_t size) noexcept
 
template<typename T >
std::uint32_t crc32_add (std::uint32_t crc, const T &value) noexcept
 
std::uint32_t crc32_finish (const std::uint32_t crc) noexcept
 
long long current_process_id () noexcept
 
bool process_is_alive (const long long pid) noexcept
 
constexpr std::uint32_t mix_codec_id (const std::uint32_t seed, const std::uint32_t value) noexcept
 
template<typename UInt >
requires (std::is_unsigned_v<UInt>)
void encode_unsigned_le (UInt value, unsigned char *out) noexcept
 
template<typename UInt >
requires (std::is_unsigned_v<UInt>)
UInt decode_unsigned_le (const unsigned char *in) noexcept
 
template<size_t N>
constexpr std::array< char, Ordered_Tree_Snapshot_Magic_Sizeordered_tree_snapshot_magic (const char(&text)[N]) noexcept
 
bool ordered_tree_snapshot_exists (const std::string &file_path)
 
void ensure_ordered_tree_snapshot_parent_dir (const std::string &file_path, const char *kind)
 
template<typename Key >
Key ordered_tree_read_key (std::istream &in, const std::string &file_path, const char *kind, const std::uint64_t index)
 
template<typename Key >
void ordered_tree_write_key (std::ostream &out, const Key &key, const std::string &file_path, const char *kind, const std::uint64_t index)
 
void ordered_tree_validate_header (const Ordered_Tree_Snapshot_Header &header, const std::array< char, Ordered_Tree_Snapshot_Magic_Size > &expected_magic, const std::uint32_t expected_key_size, const std::uint64_t expected_min_degree, const std::string &file_path, const char *kind)
 
template<typename Key >
Array< Key > load_ordered_tree_snapshot (const std::string &file_path, const std::array< char, Ordered_Tree_Snapshot_Magic_Size > &expected_magic, const std::uint64_t expected_min_degree, const char *kind)
 
template<typename Key >
void save_ordered_tree_snapshot (const std::string &file_path, const std::array< char, Ordered_Tree_Snapshot_Magic_Size > &expected_magic, const std::uint64_t expected_min_degree, const Array< Key > &keys, const char *kind)
 

Variables

constexpr size_t tm_epoch_year = 1900u
 
constexpr size_t max_supported_year
 
constexpr time_t seconds_per_day
 
template<typename... Args>
constexpr bool are_stream_insertable_v
 
constexpr size_t SPP_NONE = ~static_cast<size_t>(0)
 
constexpr size_t Ordered_Tree_Snapshot_Magic_Size = 16
 
constexpr std::uint32_t Ordered_Tree_Snapshot_Version = 1
 

Enumeration Type Documentation

◆ Pid_File_Lock_Mode

Enumerator
Shared 
Exclusive 

Definition at line 83 of file tpl_paged_tree_durability.H.

Function Documentation

◆ bplus_equiv()

template<typename Compare , typename Key >
bool Aleph::detail::bplus_equiv ( const Compare &  cmp,
const Key &  lhs,
const Key &  rhs 
)

◆ build_msg_impl() [1/2]

void Aleph::detail::build_msg_impl ( std::ostringstream &  )
inline

Definition at line 56 of file ah-msg.H.

Referenced by build_msg_impl().

◆ build_msg_impl() [2/2]

template<typename T , typename... Args>
void Aleph::detail::build_msg_impl ( std::ostringstream &  stream,
T &&  value,
Args &&...  rest 
)
inline

Definition at line 59 of file ah-msg.H.

References build_msg_impl(), and Aleph::divide_and_conquer_partition_dp().

◆ check_composite()

bool Aleph::detail::check_composite ( uint64_t  n,
uint64_t  a,
uint64_t  d,
int  s 
)
inlinenoexcept

Helper function for Miller-Rabin test.

Checks if 'a' is a composite witness for 'n'.

Parameters
nThe number being tested.
aThe base to test.
dThe odd part of n-1 (n-1 = d * 2^s).
sThe power of 2 dividing n-1.
Returns
true if 'n' is composite, false if 'n' is probably prime.

Definition at line 62 of file primality.H.

References Aleph::divide_and_conquer_partition_dp(), Aleph::mod_exp(), Aleph::mod_mul(), and r.

Referenced by Aleph::miller_rabin().

◆ copy_file_contents()

◆ crc32_add()

template<typename T >
std::uint32_t Aleph::detail::crc32_add ( std::uint32_t  crc,
const T value 
)
inlinenoexcept

Definition at line 230 of file tpl_paged_tree_durability.H.

References crc32_add_bytes(), and Aleph::divide_and_conquer_partition_dp().

Referenced by Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::header_checksum(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::header_checksum(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::header_checksum_v2(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::header_checksum_v2(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::page_checksum(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::page_checksum(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::page_checksum_v3(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::page_checksum_v3(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::page_checksum_v4(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::page_checksum_v4(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::wal_header_checksum(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::wal_header_checksum(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add_v2(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add_v2(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add_v3(), and Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add_v3().

◆ crc32_add_bytes()

std::uint32_t Aleph::detail::crc32_add_bytes ( std::uint32_t  crc,
const void data,
const size_t  size 
)
inlinenoexcept

Definition at line 215 of file tpl_paged_tree_durability.H.

References Aleph::divide_and_conquer_partition_dp(), and Aleph::size().

Referenced by Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::add_native_key_to_crc(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::add_native_key_to_crc(), Aleph::Gen_File_B_Map< Key, Value, Compare, MinDegree, KeyCodec, ValueCodec >::Record_Codec::add_to_crc(), Aleph::Gen_File_BPlus_Map< Key, Value, Compare, MinDegree, KeyCodec, ValueCodec >::Record_Codec::add_to_crc(), Aleph::detail::Paged_Bounded_String_Codec< Capacity, SizeType >::add_to_crc(), Aleph::detail::Paged_Value_Codec< T >::add_to_crc(), crc32_add(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::header_checksum(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::header_checksum(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::header_checksum_v2(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::header_checksum_v2(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::page_checksum(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::page_checksum(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::page_checksum_v3(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::page_checksum_v3(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::page_checksum_v4(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::page_checksum_v4(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::wal_header_checksum(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::wal_header_checksum(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add_v2(), Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add_v2(), Aleph::Gen_File_B_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add_v3(), and Aleph::Gen_File_BPlus_Tree< Key, Compare, MinDegree, Codec >::wal_record_checksum_add_v3().

◆ crc32_begin()

◆ crc32_finish()

std::uint32_t Aleph::detail::crc32_finish ( const std::uint32_t  crc)
inlinenoexcept

◆ current_process_id()

long long Aleph::detail::current_process_id ( )
inlinenoexcept

◆ decode_unsigned_le()

template<typename UInt >
requires (std::is_unsigned_v<UInt>)
UInt Aleph::detail::decode_unsigned_le ( const unsigned char in)
inlinenoexcept

Definition at line 94 of file tpl_paged_value_codec.H.

References Aleph::divide_and_conquer_partition_dp().

◆ encode_unsigned_le()

template<typename UInt >
requires (std::is_unsigned_v<UInt>)
void Aleph::detail::encode_unsigned_le ( UInt  value,
unsigned char out 
)
inlinenoexcept

◆ ensure_ordered_tree_snapshot_parent_dir()

void Aleph::detail::ensure_ordered_tree_snapshot_parent_dir ( const std::string &  file_path,
const char kind 
)
inline

◆ equiv()

template<typename Compare , typename Key >
bool Aleph::detail::equiv ( const Compare &  cmp,
const Key &  lhs,
const Key &  rhs 
)

◆ extract_prime_factors()

void Aleph::detail::extract_prime_factors ( const uint64_t  n,
Array< uint64_t > &  factors 
)
inline

Recursive extraction of all prime factors.

Definition at line 146 of file pollard_rho.H.

References Aleph::divide_and_conquer_partition_dp(), extract_prime_factors(), find_any_factor(), and Aleph::miller_rabin().

Referenced by extract_prime_factors(), and Aleph::pollard_rho().

◆ fallback_all_of()

bool Aleph::detail::fallback_all_of ( const Container c,
Pred &&  pred 
)

Definition at line 794 of file ah-ranges.H.

References pred.

◆ fallback_any_of()

bool Aleph::detail::fallback_any_of ( const Container c,
Pred &&  pred 
)

Definition at line 803 of file ah-ranges.H.

References pred.

Referenced by fallback_none_of().

◆ fallback_none_of()

bool Aleph::detail::fallback_none_of ( const Container c,
Pred &&  pred 
)

Definition at line 812 of file ah-ranges.H.

References fallback_any_of(), and pred.

◆ find_any_factor()

uint64_t Aleph::detail::find_any_factor ( const uint64_t  n)
inline

Helper to repeatedly apply Pollard's rho until a factor is found.

Tries different random seed/constant pairs. Each attempt has a bounded number of iterations, and the total number of attempts is also capped to guarantee termination.

Parameters
nComposite number to find a factor of.
Returns
A non-trivial factor of n.
Exceptions
std::runtime_errorif no factor found after max attempts.

Definition at line 112 of file pollard_rho.H.

References ah_runtime_error, Aleph::divide_and_conquer_partition_dp(), pollard_rho_step(), rng, and seed.

Referenced by extract_prime_factors().

◆ load_ordered_tree_snapshot()

template<typename Key >
Array< Key > Aleph::detail::load_ordered_tree_snapshot ( const std::string &  file_path,
const std::array< char, Ordered_Tree_Snapshot_Magic_Size > &  expected_magic,
const std::uint64_t  expected_min_degree,
const char kind 
)

◆ mix_codec_id()

constexpr std::uint32_t Aleph::detail::mix_codec_id ( const std::uint32_t  seed,
const std::uint32_t  value 
)
constexprnoexcept

Definition at line 77 of file tpl_paged_value_codec.H.

References seed.

◆ ordered_tree_read_key()

template<typename Key >
Key Aleph::detail::ordered_tree_read_key ( std::istream &  in,
const std::string &  file_path,
const char kind,
const std::uint64_t  index 
)

◆ ordered_tree_snapshot_exists()

bool Aleph::detail::ordered_tree_snapshot_exists ( const std::string &  file_path)
inline

Definition at line 87 of file tpl_tree_snapshot.H.

◆ ordered_tree_snapshot_magic()

◆ ordered_tree_validate_header()

◆ ordered_tree_write_key()

template<typename Key >
void Aleph::detail::ordered_tree_write_key ( std::ostream &  out,
const Key &  key,
const std::string &  file_path,
const char kind,
const std::uint64_t  index 
)

◆ pollard_rho_step()

uint64_t Aleph::detail::pollard_rho_step ( const uint64_t  n,
const uint64_t  seed,
const uint64_t  c 
)
inline

Inner function for Pollard's rho algorithm.

Parameters
nThe number to factor.
seedThe seed for the pseudo-random sequence.
cThe constant for the polynomial f(x) = x^2 + c.
Returns
A non-trivial factor of n, or n if it fails to find one.

Definition at line 68 of file pollard_rho.H.

References Aleph::and, Aleph::diff(), Aleph::divide_and_conquer_partition_dp(), Aleph::mod_mul(), seed, and y.

Referenced by find_any_factor().

◆ process_is_alive()

bool Aleph::detail::process_is_alive ( const long long  pid)
inlinenoexcept

◆ ranges_all_of()

bool Aleph::detail::ranges_all_of ( const Container c,
Pred &&  pred 
)

Fallback all_of using range-based for loop.

Definition at line 835 of file ah-ranges.H.

References Aleph::divide_and_conquer_partition_dp(), and pred.

Referenced by Aleph::stl_all().

◆ ranges_any_of()

bool Aleph::detail::ranges_any_of ( const Container c,
Pred &&  pred 
)

Fallback any_of using range-based for loop.

Definition at line 847 of file ah-ranges.H.

References Aleph::divide_and_conquer_partition_dp(), and pred.

Referenced by ranges_none_of(), and Aleph::stl_exists().

◆ ranges_count_if()

auto Aleph::detail::ranges_count_if ( const Container c,
Pred &&  pred 
)

Fallback count_if using range-based for loop.

Definition at line 868 of file ah-ranges.H.

References Aleph::count(), Aleph::divide_and_conquer_partition_dp(), and pred.

◆ ranges_fold_left()

constexpr T Aleph::detail::ranges_fold_left ( Container &&  c,
T  init,
BinaryOp &&  op 
)
constexpr

Fallback fold_left using range-based for loop.

Works with any container that supports range-based for loop. This is the function used by ahFunctional.H when std::ranges is unavailable.

Definition at line 824 of file ah-ranges.H.

References Aleph::divide_and_conquer_partition_dp(), and Aleph::init.

Referenced by Aleph::foldl(), and Aleph::stl_foldl().

◆ ranges_none_of()

bool Aleph::detail::ranges_none_of ( const Container c,
Pred &&  pred 
)

Fallback none_of using range-based for loop.

Definition at line 859 of file ah-ranges.H.

References pred, and ranges_any_of().

◆ remove_file_if_exists()

◆ rename_file_atomic()

◆ save_ordered_tree_snapshot()

◆ shortest_path_portals()

◆ spp_build_tris()

◆ spp_cross()

Geom_Number Aleph::detail::spp_cross ( const Point a,
const Point b,
const Point c 
)
inline

◆ spp_find_index()

size_t Aleph::detail::spp_find_index ( const Array< Point > &  pts,
const Point p 
)
inline

Definition at line 66 of file tikzgeom_algorithms.H.

References Aleph::divide_and_conquer_partition_dp(), and SPP_NONE.

Referenced by spp_build_tris().

◆ spp_find_sleeve()

◆ spp_find_tri()

size_t Aleph::detail::spp_find_tri ( const Array< Point > &  pts,
const Array< SPP_ITri > &  tris,
const Point p 
)
inline

◆ spp_point_in_triangle()

bool Aleph::detail::spp_point_in_triangle ( const Array< Point > &  pts,
const SPP_ITri t,
const Point p 
)
inline

◆ sync_file_by_path()

◆ sync_file_descriptor()

void Aleph::detail::sync_file_descriptor ( const int  fd,
const std::string &  path,
const char kind 
)
inline

◆ sync_parent_directory()

◆ tikz_palette_color()

Variable Documentation

◆ are_stream_insertable_v

template<typename... Args>
constexpr bool Aleph::detail::are_stream_insertable_v
inlineconstexpr
Initial value:
=
(is_stream_insertable<std::decay_t<Args>>::value && ...)

Definition at line 76 of file ah-msg.H.

◆ max_supported_year

constexpr size_t Aleph::detail::max_supported_year
inlineconstexpr
Initial value:
=
static_cast<size_t>(std::numeric_limits<int>::max()) + tm_epoch_year

Definition at line 58 of file ah-date.H.

Referenced by Aleph::to_time_t().

◆ Ordered_Tree_Snapshot_Magic_Size

◆ Ordered_Tree_Snapshot_Version

constexpr std::uint32_t Aleph::detail::Ordered_Tree_Snapshot_Version = 1
inlineconstexpr

Definition at line 60 of file tpl_tree_snapshot.H.

Referenced by ordered_tree_validate_header(), and save_ordered_tree_snapshot().

◆ seconds_per_day

constexpr time_t Aleph::detail::seconds_per_day
inlineconstexpr
Initial value:
=
static_cast<time_t>(24 * 60 * 60)

Definition at line 60 of file ah-date.H.

Referenced by Aleph::to_days().

◆ SPP_NONE

constexpr size_t Aleph::detail::SPP_NONE = ~static_cast<size_t>(0)
constexpr

◆ tm_epoch_year

constexpr size_t Aleph::detail::tm_epoch_year = 1900u
inlineconstexpr

Definition at line 57 of file ah-date.H.

Referenced by Aleph::to_time_t().