A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::nodes::NodeMap Class Reference

A thread-safe registry of AsyncNodes keyed by id. More...

#include <cpp/a11/nodes/node_map.h>

Inheritance diagram for a11::nodes::NodeMap:
[legend]

Public Member Functions

 ~NodeMap ()=default
 
absl::StatusOr< std::shared_ptr< AsyncNode > > Get (std::string node_id)
 Return the node for an id, creating it if it does not exist.
 
absl::StatusOr< std::shared_ptr< AsyncNode > > GetIfExists (std::string_view node_id) const
 Return the node for an id without creating it.
 
absl::Status RegisterStorage (std::string storage_id, std::shared_ptr< NodeMap > storage)
 Configure a host-accessible namespace and its backend node map.
 
const std::optional< data::StorageIdentity > & Storage () const
 Identity of this map's backend, or absent for session-local storage.
 
absl::Status SetStorageResolver (StorageResolver resolver, std::vector< std::string > accessible_ids={})
 Adopt host connection policy; advertised ids must be directly accessible.
 
std::vector< std::string > StorageIds () const
 Storage identities directly accessible through this host's resolver.
 
void SetAllowLazyReadResolution (bool allowed)
 Permit read resolution to open uncached nodes through this map's factory.
 
bool AllowsLazyReadResolution () const
 
absl::StatusOr< std::shared_ptr< AsyncNode > > Resolve (const data::NodeRef &reference)
 Resolve a whole-node reference; windows require a fragment-window reader.
 
absl::StatusOr< std::shared_ptr< AsyncNode > > ResolveForRead (const data::NodeRef &reference)
 Resolve an existing local target for a value read.
 
absl::StatusOr< std::shared_ptr< AsyncNode > > ImportReference (const data::NodeRef &reference, const std::shared_ptr< NodeMap > &source)
 Share a referenced node from another scope, preserving its identity.
 
absl::StatusOr< std::shared_ptr< AsyncNode > > Discard (std::string_view node_id, const std::shared_ptr< AsyncNode > &expected=nullptr)
 Remove the node for an id.
 
bool Contains (std::string_view node_id) const
 Report whether a node with the given id exists.
 
size_t Size () const
 Return the number of nodes currently in the map.
 
std::vector< std::string > Ids () const
 Return the id of every node the map holds, sorted.
 

Static Public Member Functions

static absl::StatusOr< std::shared_ptr< NodeMap > > Create (ChunkStoreFactory factory={}, std::optional< data::StorageIdentity > storage={})
 Create a node map.
 

Detailed Description

A thread-safe registry of AsyncNodes keyed by id.

Nodes are created lazily on first access via the map's ChunkStoreFactory. Instances are heap-allocated and shared via Create.

Constructor & Destructor Documentation

◆ ~NodeMap()

a11::nodes::NodeMap::~NodeMap ( )
default

Member Function Documentation

◆ AllowsLazyReadResolution()

bool a11::nodes::NodeMap::AllowsLazyReadResolution ( ) const

◆ Contains()

bool a11::nodes::NodeMap::Contains ( std::string_view  node_id) const

Report whether a node with the given id exists.

Parameters
node_idThe node identifier.
Returns
True if the map holds a node under that id.

◆ Create()

absl::StatusOr< std::shared_ptr< NodeMap > > a11::nodes::NodeMap::Create ( ChunkStoreFactory  factory = {},
std::optional< data::StorageIdentity >  storage = {} 
)
static

Create a node map.

Parameters
factoryFactory invoked to build the backing store for each new node; a default store is used when omitted.
Returns
The new map, or an error status on failure.

◆ Discard()

absl::StatusOr< std::shared_ptr< AsyncNode > > a11::nodes::NodeMap::Discard ( std::string_view  node_id,
const std::shared_ptr< AsyncNode > &  expected = nullptr 
)

Remove the node for an id.

Parameters
node_idThe node identifier.
expectedIf non-null, only remove when the stored node matches this one (compare-and-remove).
Returns
The removed node, or an error status on failure.

◆ Get()

absl::StatusOr< std::shared_ptr< AsyncNode > > a11::nodes::NodeMap::Get ( std::string  node_id)

Return the node for an id, creating it if it does not exist.

Parameters
node_idThe node identifier.
Returns
The node, or an error status on failure.

Return the node for an id, creating it if it does not exist.

Parameters
node_idThe node identifier.
Returns
The node, or an error status on failure.

◆ GetIfExists()

absl::StatusOr< std::shared_ptr< AsyncNode > > a11::nodes::NodeMap::GetIfExists ( std::string_view  node_id) const

Return the node for an id without creating it.

Parameters
node_idThe node identifier.
Returns
The node, or nullptr if it does not exist (or an error status).

◆ Ids()

std::vector< std::string > a11::nodes::NodeMap::Ids ( ) const

Return the id of every node the map holds, sorted.

A snapshot: nodes are created on demand, so the answer is what was there when it was asked for. Sorted rather than in hash order so a caller comparing two snapshots – a test, a diagnostic dump – sees a stable list.

Returns
The ids.

◆ ImportReference()

absl::StatusOr< std::shared_ptr< AsyncNode > > a11::nodes::NodeMap::ImportReference ( const data::NodeRef &  reference,
const std::shared_ptr< NodeMap > &  source 
)

Share a referenced node from another scope, preserving its identity.

◆ RegisterStorage()

absl::Status a11::nodes::NodeMap::RegisterStorage ( std::string  storage_id,
std::shared_ptr< NodeMap >  storage 
)

Configure a host-accessible namespace and its backend node map.

◆ Resolve()

absl::StatusOr< std::shared_ptr< AsyncNode > > a11::nodes::NodeMap::Resolve ( const data::NodeRef &  reference)

Resolve a whole-node reference; windows require a fragment-window reader.

◆ ResolveForRead()

absl::StatusOr< std::shared_ptr< AsyncNode > > a11::nodes::NodeMap::ResolveForRead ( const data::NodeRef &  reference)

Resolve an existing local target for a value read.

◆ SetAllowLazyReadResolution()

void a11::nodes::NodeMap::SetAllowLazyReadResolution ( bool  allowed)

Permit read resolution to open uncached nodes through this map's factory.

◆ SetStorageResolver()

absl::Status a11::nodes::NodeMap::SetStorageResolver ( StorageResolver  resolver,
std::vector< std::string >  accessible_ids = {} 
)

Adopt host connection policy; advertised ids must be directly accessible.

◆ Size()

size_t a11::nodes::NodeMap::Size ( ) const

Return the number of nodes currently in the map.

Returns
The node count.

◆ Storage()

const std::optional< data::StorageIdentity > & a11::nodes::NodeMap::Storage ( ) const
inline

Identity of this map's backend, or absent for session-local storage.

◆ StorageIds()

std::vector< std::string > a11::nodes::NodeMap::StorageIds ( ) const

Storage identities directly accessible through this host's resolver.


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