A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
chunk_store.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 The A11 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
24#ifndef A11_STORES_CHUNK_STORE_H_
25#define A11_STORES_CHUNK_STORE_H_
26
27#include <cstddef>
28#include <cstdint>
29#include <optional>
30#include <string>
31#include <utility>
32#include <vector>
33
34#include <absl/status/status.h>
35#include <absl/status/statusor.h>
36#include <absl/time/time.h>
37
39#include "a11/data/types.h"
40
41namespace a11::stores {
42
68 public:
69 virtual ~ChunkStore() = default;
70
83 return Get(seq, absl::InfiniteFuture());
84 }
85
103 absl::Time deadline) = 0;
104
117 std::uint64_t arrival_order) {
118 return GetByArrivalOrder(arrival_order, absl::InfiniteFuture());
119 }
120
137 std::uint64_t arrival_order, absl::Time deadline) = 0;
138
150 return Next(absl::InfiniteFuture(), 1);
151 }
152
165 absl::Time deadline) {
166 return Next(deadline, 1);
167 }
168
187 absl::Time deadline, size_t limit) = 0;
188
195 [[nodiscard]] virtual bool HoldsObjects() const { return false; }
196
203
217 std::vector<data::NodeFragment> fragments) = 0;
218
232
242 std::uint64_t arrival_order) = 0;
243
256
269 return CloseWritesWithStatus(std::move(status), false);
270 }
271
287 absl::Status status, bool return_status_if_already_closed) = 0;
288
296
303 virtual absl::StatusOr<std::string> GetId() const = 0;
304};
305
306} // namespace a11::stores
307
308#endif // A11_STORES_CHUNK_STORE_H_
Shared handle to one asynchronous result.
Definition future.h:126
Abstract, pluggable backing store for the data of a node: an ordered, appendable log of fragments.
Definition chunk_store.h:67
a11::Future< data::NodeFragment > GetByArrivalOrder(std::uint64_t arrival_order)
Get a fragment by arrival order, waiting indefinitely.
Definition chunk_store.h:116
virtual bool HoldsObjects() const
Whether this store can hold a chunk that carries a value.
Definition chunk_store.h:195
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 one 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:164
a11::Future< data::NodeFragment > Get(std::uint32_t seq)
Get the fragment at a sequence number, waiting indefinitely.
Definition chunk_store.h:82
a11::Future< std::vector< std::optional< data::NodeFragment > > > Next()
Get the next logical-sequence fragment, waiting indefinitely.
Definition chunk_store.h:149
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:268
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:45
std::vector< std::optional< data::NodeFragment > > fragments
Definition redis_chunk_store.cc:240
std::uint32_t seq
Definition sqlite_chunk_store.cc:186
std::uint64_t arrival_order
Definition sqlite_chunk_store.cc:187
One piece of a node's stream: an inline chunk or a node reference.
Definition types.h:335
A11's core wire value types: chunks, node fragments and messages.