|
A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
|
An in-process value a chunk may carry instead of its encoded bytes. More...
#include <cpp/a11/data/types.h>
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. | |
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.
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.
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.
|
virtualdefault |
|
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 >.
|
pure virtual |
A size estimate that does not encode anything.
Implemented in a11::data::TypedChunkObject< T >.
|
pure virtual |
Encodes the value, for whoever needs bytes after all.
Implemented in a11::data::TypedChunkObject< T >.
|
pure virtual |
The mimetype the value would be encoded as.
Implemented in a11::data::TypedChunkObject< T >.
|
pure virtual |
The serialisation tag of the held type.
Implemented in a11::data::TypedChunkObject< T >.