RPNX::QueryGraph
Typed, memoized, concurrent query evaluation for C++23
Loading...
Searching...
No Matches
querygraph.hpp File Reference

Primary QueryGraph API: specifications, handlers, execution, and errors. More...

#include "rpnx/querygraph/byte_format.hpp"
#include "rpnx/result.hpp"
#include "rpnx/typelist.hpp"
#include <algorithm>
#include <any>
#include <array>
#include <atomic>
#include <cassert>
#include <chrono>
#include <condition_variable>
#include <concepts>
#include <coroutine>
#include <cstddef>
#include <deque>
#include <exception>
#include <filesystem>
#include <format>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <print>
#include <set>
#include <shared_mutex>
#include <source_location>
#include <stdexcept>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <variant>
#include <vector>
#include "rpnx/querygraph/graphdata.hpp"
#include "rpnx/querygraph/hasher.hpp"
#include "rpnx/serialization4.hpp"

Go to the source code of this file.

Classes

struct  rpnx::querygraph::query_handler_produced_subquery_traits< T >
 Supplies an empty produced-subquery list when a handler omits it. More...
 
struct  rpnx::querygraph::query_handler_produced_subquery_traits< T >
 Reads the explicit produced_subqueries declaration from T. More...
 
struct  rpnx::querygraph::query_handler_traits< T >
 Trait specialization that exposes a structural handler spec. More...
 
struct  rpnx::querygraph::is_query_handler_spec< T >
 Boolean trait equivalent of query_handler_spec_c. More...
 
struct  rpnx::querygraph::binary_traits< T >
 Binary serialization customization point for dumpable values. More...
 
struct  rpnx::querygraph::binary_traits< std::monostate >
 Empty binary representation used for std::monostate. More...
 
struct  rpnx::querygraph::debug_traits< T >
 Human-readable formatting customization point for query values. More...
 
struct  rpnx::querygraph::debug_traits< std::string >
 Debug formatter that quotes and escapes a string. More...
 
struct  rpnx::querygraph::debug_traits< std::monostate >
 Debug formatter for the unique monostate value. More...
 
struct  rpnx::querygraph::debug_message
 A diagnostic emitted by a running query handler. More...
 
struct  rpnx::querygraph::canonical_error_storage
 Type-erased, copyable storage for a registered exception value. More...
 
class  rpnx::querygraph::error_result
 Discriminated error state used by query and subquery results. More...
 
class  rpnx::querygraph::result< T >
 Internal value-or-error state shared by query awaitables and dumps. More...
 
class  rpnx::querygraph::result< void >
 Pending/value/error state specialization for operations returning no value. More...
 
struct  rpnx::querygraph::debug_abi::request< QuerySpec >
 Awaitable request for a memoized query value. More...
 
struct  rpnx::querygraph::debug_abi::dependency< QuerySpec >
 Coroutine yield value that schedules a dependency without waiting. More...
 
struct  rpnx::querygraph::debug_abi::subquery_request< SubquerySpec >
 Awaitable request for a subquery value produced by a parent node. More...
 
struct  rpnx::querygraph::debug_abi::subquery_result< SubquerySpec >
 Coroutine yield value that publishes one subquery result. More...
 
class  rpnx::querygraph::debug_abi::subquery_does_not_exist
 Canonical error for a requested subquery the parent did not produce. More...
 
class  rpnx::querygraph::debug_abi::subquery_parent_failed
 Canonical wrapper indicating that a subquery's parent failed. More...
 
class  rpnx::querygraph::debug_abi::recursive_dependency_error
 Indicates that graph execution quiesced before a request completed. More...
 
class  rpnx::querygraph::debug_abi::bad_continuation
 Indicates that a handler completed without a continuation outcome. More...
 
class  rpnx::querygraph::debug_abi::graph
 Owns handler registrations, memoized nodes, and query execution. More...
 
struct  rpnx::querygraph::debug_abi::coroutine< HandlerSpec >
 Owning coroutine return object for a registered query handler. More...
 

Concepts

concept  rpnx::querygraph::query_spec_c
 Identifies a type that describes a memoized query.
 
concept  rpnx::querygraph::subquery_spec_c
 Identifies a result class produced within a parent query node.
 
concept  rpnx::querygraph::query_handler_spec_struct_c
 Identifies the required structural portion of a handler spec.
 
concept  rpnx::querygraph::query_handler_produced_subqueries_struct_c
 Identifies handler specs that explicitly list produced subqueries.
 
concept  rpnx::querygraph::query_handler_spec_c
 Identifies a complete query handler specification.
 
concept  rpnx::querygraph::type_with_to_debug_string
 Detects a value-provided to_debug_string() operation.
 

Typedefs

using rpnx::querygraph::shared_mutex = std::shared_mutex
 Shared mutex type used by query result awaitables.
 
using rpnx::querygraph::fast_mutex = std::mutex
 Platform-selected mutex used by scheduler queues.
 
using rpnx::querygraph::fast_cv = std::condition_variable
 Condition variable compatible with fast_mutex.
 
template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_query_t = typename query_handler_traits< HandlerSpec >::query
 Normalized query type implemented by HandlerSpec.
 
template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_dependencies_t = typename query_handler_traits< HandlerSpec >::dependencies
 Declared query and subquery dependencies of HandlerSpec.
 
template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_produced_subqueries_t = typename query_handler_traits< HandlerSpec >::produced_subqueries
 Subquery result classes that HandlerSpec may yield.
 
template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_input_t = typename query_handler_query_t< HandlerSpec >::input_type
 Input type of the query implemented by HandlerSpec.
 
template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_output_t = typename query_handler_query_t< HandlerSpec >::output_type
 Output type of the query implemented by HandlerSpec.
 

Enumerations

enum class  rpnx::querygraph::memory_class : std::uint8_t {
  unknown , tiny , small , medium ,
  large , huge
}
 Coarse estimate of a query node's peak memory requirement. More...
 

Functions

std::string rpnx::querygraph::format_debug_message_with_source (debug_message const &msg)
 Prefix a diagnostic message with its source file and line.
 
template<typename Error>
canonical_error_storage rpnx::querygraph::make_canonical_error_storage (Error const &error)
 Capture a concrete exception in canonical type-erased storage.
 

Detailed Description

Primary QueryGraph API: specifications, handlers, execution, and errors.

Include this header to define typed query and subquery specifications, implement coroutine handlers, register them with a graph, and evaluate memoized requests.

Definition in file querygraph.hpp.

Typedef Documentation

◆ fast_cv

using rpnx::querygraph::fast_cv = std::condition_variable

Condition variable compatible with fast_mutex.

Definition at line 120 of file querygraph.hpp.

◆ fast_mutex

using rpnx::querygraph::fast_mutex = std::mutex

Platform-selected mutex used by scheduler queues.

Definition at line 118 of file querygraph.hpp.

◆ query_handler_dependencies_t

template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_dependencies_t = typename query_handler_traits< HandlerSpec >::dependencies

Declared query and subquery dependencies of HandlerSpec.

Definition at line 234 of file querygraph.hpp.

◆ query_handler_input_t

template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_input_t = typename query_handler_query_t< HandlerSpec >::input_type

Input type of the query implemented by HandlerSpec.

Definition at line 242 of file querygraph.hpp.

◆ query_handler_output_t

template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_output_t = typename query_handler_query_t< HandlerSpec >::output_type

Output type of the query implemented by HandlerSpec.

Definition at line 246 of file querygraph.hpp.

◆ query_handler_produced_subqueries_t

template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_produced_subqueries_t = typename query_handler_traits< HandlerSpec >::produced_subqueries

Subquery result classes that HandlerSpec may yield.

Definition at line 238 of file querygraph.hpp.

◆ query_handler_query_t

template<query_handler_spec_c HandlerSpec>
using rpnx::querygraph::query_handler_query_t = typename query_handler_traits< HandlerSpec >::query

Normalized query type implemented by HandlerSpec.

Definition at line 230 of file querygraph.hpp.

◆ shared_mutex

using rpnx::querygraph::shared_mutex = std::shared_mutex

Shared mutex type used by query result awaitables.

Definition at line 105 of file querygraph.hpp.

Enumeration Type Documentation

◆ memory_class

enum class rpnx::querygraph::memory_class : std::uint8_t
strong

Coarse estimate of a query node's peak memory requirement.

This enumeration reserves the vocabulary for planned memory-aware scheduling. Handler specifications do not yet expose the estimate.

  • unknown: no useful memory estimate is available.
  • tiny: expected to consume no more than approximately 8 KiB.
  • small: expected to consume a small amount of memory.
  • medium: expected to consume a moderate amount of memory.
  • large: expected to consume a large amount of memory.
  • huge: expected to consume enough memory to require special scheduling care.

Definition at line 83 of file querygraph.hpp.

Function Documentation

◆ format_debug_message_with_source()

std::string rpnx::querygraph::format_debug_message_with_source ( debug_message const & msg)

Prefix a diagnostic message with its source file and line.

Parameters
msgMessage and optional source location to format.
Returns
file:line - message when a location is available, or the bare message otherwise.

◆ make_canonical_error_storage()

template<typename Error>
canonical_error_storage rpnx::querygraph::make_canonical_error_storage ( Error const & error)

Capture a concrete exception in canonical type-erased storage.

Template Parameters
ErrorCopy-constructible type derived from std::exception.
Parameters
errorException value to copy.
Returns
Storage capable of rethrowing, formatting, and serializing it.

Definition at line 429 of file querygraph.hpp.

References rpnx::querygraph::canonical_error_storage::m_error_typesig, rpnx::querygraph::canonical_error_storage::m_error_value, rpnx::querygraph::canonical_error_storage::m_message, rpnx::querygraph::canonical_error_storage::m_serialize, rpnx::querygraph::canonical_error_storage::m_throw_copy, and rpnx::querygraph::binary_traits< T >::serialize_to_binary().