A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::data::ChunkObject Class Referenceabstract

An in-process value a chunk may carry instead of its encoded bytes. More...

#include <cpp/a11/data/types.h>

Inheritance diagram for a11::data::ChunkObject:
[legend]

Public Member Functions

virtual ~ChunkObject ()=default
 
virtual std::string_view tag () const =0
 The serialisation tag of the held type.
 
virtual std::string_view mimetype () const =0
 The mimetype the value would be encoded as.
 
virtual absl::StatusOr< Bytes > Encode () const =0
 Encodes the value, for whoever needs bytes after all.
 
virtual size_t ApproxBytes () const =0
 A size estimate that does not encode anything.
 
virtual const void *absl_nonnull address () const =0
 The address of the held value.
 

Detailed Description

An in-process value a chunk may carry instead of its encoded bytes.

The thing this exists to remove: a value written to a node and read back in the same process was encoded on the way in and decoded on the way out, and both are pure waste when nobody outside the process ever sees the bytes. Decode is the expensive half – nested-record decode ran at ~130 MiB/s against encode's 2+ GiB/s before ReadBinaryView – so the local path was paying for a wire format it never used.

A chunk carrying one of these has no bytes at all until somebody needs them. Chunk::Materialize() is where they come from, and it is called at every boundary where bytes are genuinely required: a store that persists them, a stream that sends them, or a reader that asked for a chunk rather than a value.

Identity, without RTTI

tag() is the serialisation tag – a11.sdk.AudioBuffer – and it is what a consumer compares before casting. Types are identified by wire tag rather than std::type_info to ensure sound matching across dynamic library boundaries.

Immutability

The held value must not change after insertion because a ChunkStore replays a fragment to current and later readers. Consumers receive independent copies, avoiding an encode and decode for each consumer.

Constructor & Destructor Documentation

◆ ~ChunkObject()

virtual a11::data::ChunkObject::~ChunkObject ( )
virtualdefault

Member Function Documentation

◆ address()

virtual const void *absl_nonnull a11::data::ChunkObject::address ( ) const
pure virtual

The address of the held value.

Do not call this. It is dereferenced in exactly one place – a11::data::TryTakeObject, which compares tag() first – and a cast without that comparison is undefined behaviour with a plausible-looking result.

Implemented in a11::data::TypedChunkObject< T >.

◆ ApproxBytes()

virtual size_t a11::data::ChunkObject::ApproxBytes ( ) const
pure virtual

A size estimate that does not encode anything.

Implemented in a11::data::TypedChunkObject< T >.

◆ Encode()

virtual absl::StatusOr< Bytes > a11::data::ChunkObject::Encode ( ) const
pure virtual

Encodes the value, for whoever needs bytes after all.

Implemented in a11::data::TypedChunkObject< T >.

◆ mimetype()

virtual std::string_view a11::data::ChunkObject::mimetype ( ) const
pure virtual

The mimetype the value would be encoded as.

Implemented in a11::data::TypedChunkObject< T >.

◆ tag()

virtual std::string_view a11::data::ChunkObject::tag ( ) const
pure virtual

The serialisation tag of the held type.

Implemented in a11::data::TypedChunkObject< T >.


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