A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
Loading...
Searching...
No Matches
chunk_store_reader.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors.
2
10#ifndef A11_STORES_CHUNK_STORE_READER_H_
11#define A11_STORES_CHUNK_STORE_READER_H_
12
13#include <cstddef>
14#include <cstdint>
15#include <memory>
16#include <optional>
17
18#include <absl/status/status.h>
19#include <absl/status/statusor.h>
20#include <absl/time/time.h>
21
23#include "a11/data/types.h"
25
26namespace a11::stores {
27
39 bool ordered = true;
41 bool pop_chunks = false;
43 std::uint64_t num_chunks_to_buffer = 32;
45 std::uint32_t offset = 0;
47 std::optional<std::uint64_t> max_chunks_to_read;
49 bool sticky_mimetype = false;
50
57 absl::Status Validate() const;
58};
59
71 public:
84 static absl::StatusOr<std::shared_ptr<ChunkStoreReader>> Create(
85 std::shared_ptr<ChunkStore> store, ChunkStoreReaderOptions options = {});
86
87 ~ChunkStoreReader() = default;
88
95 void EnsureStarted();
96
103 void Cancel();
104
112 absl::Status GetStatus() const;
113
121 a11::Task Done() const;
122
133 absl::Duration timeout = absl::InfiniteDuration());
134
136 [[nodiscard]] std::shared_ptr<ChunkStore> store() const;
140 [[nodiscard]] size_t buffer_size() const;
141
142 private:
143 struct State;
144
145 explicit ChunkStoreReader(std::shared_ptr<State> state)
146 : state_(std::move(state)) {}
147
148 std::shared_ptr<State> state_;
149};
150
151} // namespace a11::stores
152
153#endif // A11_STORES_CHUNK_STORE_READER_H_
A11's pluggable storage interface for streamed node data: an ordered, appendable log of fragments key...
An ordered, buffered read cursor over a ChunkStore.
Definition chunk_store_reader.h:70
ChunkStoreReaderOptions options() const
Definition chunk_store_reader.cc:553
size_t buffer_size() const
Definition chunk_store_reader.cc:557
void EnsureStarted()
Start the background read pump if it is not already running.
Definition chunk_store_reader.cc:523
a11::Task Done() const
Await completion of the background read pump.
Definition chunk_store_reader.cc:536
a11::Future< std::optional< data::NodeFragment > > Next(absl::Duration timeout=absl::InfiniteDuration())
Get the next fragment from the store.
Definition chunk_store_reader.cc:540
std::shared_ptr< ChunkStore > store() const
Definition chunk_store_reader.cc:549
static absl::StatusOr< std::shared_ptr< ChunkStoreReader > > Create(std::shared_ptr< ChunkStore > store, ChunkStoreReaderOptions options={})
Create a reader over store.
Definition chunk_store_reader.cc:501
absl::Status GetStatus() const
Get the reader's current status.
Definition chunk_store_reader.cc:531
void Cancel()
Stop the background read pump.
Definition chunk_store_reader.cc:527
Completion values used by every asynchronous A11 operation.
Definition node_map.h:30
Future< T > SubmitWithCancellationHook(absl::AnyInvocable< absl::StatusOr< T >() && > work, std::function< void()> cancellation_hook, thread::TreeOptions tree_options)
Run work on A11's fiber pool with application-specific cancellation.
Definition executor.h:30
Tunables controlling how a ChunkStoreReader delivers and buffers fragments.
Definition chunk_store_reader.h:37
bool ordered
Whether fragments are delivered strictly in sequence order.
Definition chunk_store_reader.h:39
std::uint32_t offset
Sequence number at which reading begins.
Definition chunk_store_reader.h:45
bool pop_chunks
Whether fragments are removed from the store as they are read.
Definition chunk_store_reader.h:41
std::optional< std::uint64_t > max_chunks_to_read
Optional cap on the total number of fragments to read.
Definition chunk_store_reader.h:47
absl::Status Validate() const
Validate that the options are internally consistent.
Definition chunk_store_reader.cc:32
std::uint64_t num_chunks_to_buffer
Maximum number of fragments to prefetch into the buffer.
Definition chunk_store_reader.h:43
bool sticky_mimetype
Whether ordered reads inherit the last explicitly set chunk mimetype.
Definition chunk_store_reader.h:49
Definition chunk_store_reader.cc:44
A11's core wire value types: chunks, node fragments and messages.