A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
Loading...
Searching...
No Matches
chunk_store.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors.
2
10#ifndef A11_STORES_CHUNK_STORE_H_
11#define A11_STORES_CHUNK_STORE_H_
12
13#include <cstddef>
14#include <cstdint>
15#include <optional>
16#include <string>
17#include <utility>
18#include <vector>
19
20#include <absl/status/status.h>
21#include <absl/status/statusor.h>
22#include <absl/time/time.h>
23
25#include "a11/data/types.h"
26
27namespace a11::stores {
28
54 public:
55 virtual ~ChunkStore() = default;
56
69 return Get(seq, absl::InfiniteFuture());
70 }
71
88 virtual a11::Future<data::NodeFragment> Get(std::uint32_t seq,
89 absl::Time deadline) = 0;
90
103 std::uint64_t arrival_order) {
104 return GetByArrivalOrder(arrival_order, absl::InfiniteFuture());
105 }
106
123 std::uint64_t arrival_order, absl::Time deadline) = 0;
124
136 return Next(absl::InfiniteFuture(), 1);
137 }
138
151 absl::Time deadline) {
152 return Next(deadline, 1);
153 }
154
173 absl::Time deadline, size_t limit) = 0;
174
185
199 std::vector<data::NodeFragment> fragments) = 0;
200
213 virtual a11::Future<data::NodeFragment> ClearData(std::uint32_t seq) = 0;
214
224 std::uint64_t arrival_order) = 0;
225
238
251 return CloseWritesWithStatus(std::move(status), false);
252 }
253
269 absl::Status status, bool return_status_if_already_closed) = 0;
270
278
285 virtual absl::StatusOr<std::string> GetId() const = 0;
286};
287
288} // namespace a11::stores
289
290#endif // A11_STORES_CHUNK_STORE_H_
Shared handle to one asynchronous result.
Definition future.h:110
Abstract, pluggable backing store for the data of a node: an ordered, appendable log of fragments.
Definition chunk_store.h:53
a11::Future< data::NodeFragment > GetByArrivalOrder(std::uint64_t arrival_order)
Get a fragment by arrival order, waiting indefinitely.
Definition chunk_store.h:102
virtual a11::Future< std::uint32_t > GetSeqForArrivalOrder(std::uint64_t arrival_order)=0
Translate an arrival order into the sequence number of that fragment.
virtual a11::Future< absl::Status > CloseWritesWithStatus(absl::Status status, bool return_status_if_already_closed)=0
Seal the store against further writes with a terminal status.
virtual absl::StatusOr< std::string > GetId() const =0
Get the store's node identifier.
virtual a11::Future< data::NodeFragment > Get(std::uint32_t seq, absl::Time deadline)=0
Get the fragment stored at a sequence number.
virtual a11::Future< std::vector< std::uint32_t > > PutMany(std::vector< data::NodeFragment > fragments)=0
Append several fragments in one batch.
virtual a11::Future< size_t > Size()=0
Get the number of fragments currently in the store.
virtual a11::Future< std::uint32_t > Put(data::NodeFragment fragment)=0
Append a single fragment to the log.
a11::Future< std::vector< std::optional< data::NodeFragment > > > Next(absl::Time deadline)
Get the next logical-sequence fragment before a deadline.
Definition chunk_store.h:150
a11::Future< data::NodeFragment > Get(std::uint32_t seq)
Get the fragment at a sequence number, waiting indefinitely.
Definition chunk_store.h:68
a11::Future< std::vector< std::optional< data::NodeFragment > > > Next()
Get the next logical-sequence fragment, waiting indefinitely.
Definition chunk_store.h:135
virtual a11::Future< std::optional< std::uint32_t > > GetFinalSeq()=0
Get the sequence number explicitly marked as the final fragment.
virtual a11::Future< data::NodeFragment > ClearData(std::uint32_t seq)=0
Erase the payload of the fragment at a sequence number while keeping its slot.
virtual ~ChunkStore()=default
a11::Future< absl::Status > CloseWritesWithStatus(absl::Status status)
Seal the store against further writes with a terminal status.
Definition chunk_store.h:250
virtual a11::Future< data::NodeFragment > GetByArrivalOrder(std::uint64_t arrival_order, absl::Time deadline)=0
Get the fragment identified by the order in which it arrived, rather than by its sequence number.
virtual a11::Future< std::vector< std::optional< data::NodeFragment > > > Next(absl::Time deadline, size_t limit)=0
Get up to limit fragments from the shared logical-sequence cursor.
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
std::vector< std::optional< data::NodeFragment > > fragments
Definition redis_chunk_store.cc:235
One piece of a node's stream: an inline chunk or a node reference.
Definition types.h:167
A11's core wire value types: chunks, node fragments and messages.