A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
Loading...
Searching...
No Matches
local_chunk_store.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors.
2
10#ifndef A11_STORES_LOCAL_CHUNK_STORE_H_
11#define A11_STORES_LOCAL_CHUNK_STORE_H_
12
13#include <cstddef>
14#include <cstdint>
15#include <memory>
16#include <optional>
17#include <string>
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"
27
28namespace a11::stores {
29
43 private:
44 struct State;
45
46 struct ConstructorToken {};
47
48 public:
57 static absl::StatusOr<std::shared_ptr<LocalChunkStore>> Create(
58 std::string node_id);
59
60 ~LocalChunkStore() override = default;
61
63 using ChunkStore::Get;
65 using ChunkStore::Next;
66
67 // In-memory implementations of the ChunkStore contract; see chunk_store.h
68 // for the semantics of each method.
69 a11::Future<data::NodeFragment> Get(std::uint32_t seq,
70 absl::Time deadline) override;
72 std::uint64_t arrival_order, absl::Time deadline) override;
74 absl::Time deadline, size_t limit) override;
75
78 std::vector<data::NodeFragment> fragments) override;
79 a11::Future<data::NodeFragment> ClearData(std::uint32_t seq) override;
81 std::uint64_t arrival_order) override;
84 absl::Status status, bool return_status_if_already_closed) override;
85 a11::Future<size_t> Size() override;
86 absl::StatusOr<std::string> GetId() const override;
87
94 explicit LocalChunkStore(ConstructorToken, std::shared_ptr<State> state)
95 : state_(std::move(state)) {}
96
97 private:
98 std::shared_ptr<State> state_;
99};
100
101} // namespace a11::stores
102
103#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: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
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
a11::Future< absl::Status > CloseWritesWithStatus(absl::Status status)
Seal the store against further writes with a terminal status.
Definition chunk_store.h:250
The default in-memory ChunkStore: all reads and writes stay in local process memory.
Definition local_chunk_store.h:42
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:364
a11::Future< std::uint32_t > Put(data::NodeFragment fragment) override
Append a single fragment to the log.
Definition local_chunk_store.cc:339
a11::Future< std::optional< std::uint32_t > > GetFinalSeq() override
Get the sequence number explicitly marked as the final fragment.
Definition local_chunk_store.cc:548
absl::StatusOr< std::string > GetId() const override
Get the store's node identifier.
Definition local_chunk_store.cc:602
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:245
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:532
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:252
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:509
a11::Future< std::vector< std::optional< data::NodeFragment > > > Next()
Get the next logical-sequence fragment, waiting indefinitely.
Definition chunk_store.h:135
LocalChunkStore(ConstructorToken, std::shared_ptr< State > state)
Internal constructor; use Create() instead.
Definition local_chunk_store.h:94
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:257
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:558
a11::Future< size_t > Size() override
Get the number of fragments currently in the store.
Definition local_chunk_store.cc:593
~LocalChunkStore() override=default
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
Definition local_chunk_store.cc:68
A11's core wire value types: chunks, node fragments and messages.