A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
local_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_LOCAL_CHUNK_STORE_H_
25#define A11_STORES_LOCAL_CHUNK_STORE_H_
26
27#include <cstddef>
28#include <cstdint>
29#include <memory>
30#include <optional>
31#include <string>
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"
41
42namespace a11::stores {
43
56class LocalChunkStore final : public ChunkStore {
57 private:
58 struct State;
59
60 struct ConstructorToken {};
61
62 public:
71 static absl::StatusOr<std::shared_ptr<LocalChunkStore>> Create(
72 std::string node_id);
73
74 ~LocalChunkStore() override = default;
75
77 using ChunkStore::Get;
79 using ChunkStore::Next;
80
84 [[nodiscard]] bool HoldsObjects() const override { return true; }
85
86 // In-memory implementations of the ChunkStore contract; see chunk_store.h
87 // for the semantics of each method.
89 absl::Time deadline) override;
91 std::uint64_t arrival_order, absl::Time deadline) override;
93 absl::Time deadline, size_t limit) override;
94
97 std::vector<data::NodeFragment> fragments) override;
98 a11::Future<data::NodeFragment> ClearData(std::uint32_t seq) override;
100 std::uint64_t arrival_order) override;
103 absl::Status status, bool return_status_if_already_closed) override;
104 a11::Future<size_t> Size() override;
105 absl::StatusOr<std::string> GetId() const override;
106
113 explicit LocalChunkStore(ConstructorToken, std::shared_ptr<State> state)
114 : state_(std::move(state)) {}
115
116 private:
117 std::shared_ptr<State> state_;
118};
119
120} // namespace a11::stores
121
122#endif // A11_STORES_LOCAL_CHUNK_STORE_H_
A11's pluggable storage interface for streamed node data: an ordered, appendable log of fragments key...
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
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
a11::Future< absl::Status > CloseWritesWithStatus(absl::Status status)
Seal the store against further writes with a terminal status.
Definition chunk_store.h:268
The default in-memory ChunkStore: all reads and writes stay in local process memory.
Definition local_chunk_store.h:56
a11::Future< std::vector< std::uint32_t > > PutMany(std::vector< data::NodeFragment > fragments) override
Append several fragments in one batch.
Definition local_chunk_store.cc:386
bool HoldsObjects() const override
Yes: this store hands back what it was given, in the same process, so a value never has to become byt...
Definition local_chunk_store.h:84
a11::Future< std::uint32_t > Put(data::NodeFragment fragment) override
Append one fragment to the log.
Definition local_chunk_store.cc:378
a11::Future< std::optional< std::uint32_t > > GetFinalSeq() override
Get the sequence number explicitly marked as the final fragment.
Definition local_chunk_store.cc:569
absl::StatusOr< std::string > GetId() const override
Get the store's node identifier.
Definition local_chunk_store.cc:623
static absl::StatusOr< std::shared_ptr< LocalChunkStore > > Create(std::string node_id)
Create an in-memory store identified by node_id.
Definition local_chunk_store.cc:309
a11::Future< std::uint32_t > GetSeqForArrivalOrder(std::uint64_t arrival_order) override
Translate an arrival order into the sequence number of that fragment.
Definition local_chunk_store.cc:553
a11::Future< data::NodeFragment > Get(std::uint32_t seq, absl::Time deadline) override
Get the fragment stored at a sequence number.
Definition local_chunk_store.cc:316
a11::Future< data::NodeFragment > ClearData(std::uint32_t seq) override
Erase the payload of the fragment at a sequence number while keeping its slot.
Definition local_chunk_store.cc:530
a11::Future< std::vector< std::optional< data::NodeFragment > > > Next()
Get the next logical-sequence fragment, waiting indefinitely.
Definition chunk_store.h:149
LocalChunkStore(ConstructorToken, std::shared_ptr< State > state)
Internal constructor; use Create() instead.
Definition local_chunk_store.h:113
a11::Future< data::NodeFragment > GetByArrivalOrder(std::uint64_t arrival_order, absl::Time deadline) override
Get the fragment identified by the order in which it arrived, rather than by its sequence number.
Definition local_chunk_store.cc:321
a11::Future< absl::Status > CloseWritesWithStatus(absl::Status status, bool return_status_if_already_closed) override
Seal the store against further writes with a terminal status.
Definition local_chunk_store.cc:579
a11::Future< size_t > Size() override
Get the number of fragments currently in the store.
Definition local_chunk_store.cc:614
~LocalChunkStore() override=default
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
Definition local_chunk_store.cc:59
A11's core wire value types: chunks, node fragments and messages.