23#include <unordered_set>
31 std::shared_ptr<mapped_native<P>
const>
source;
47 template <
class P,
class Ops = posix_
object_ops>
73 if (this->
failed_) error_detail::raise<std::logic_error>(
"file index pipeline has failed");
74 if (!this->
done()) error_detail::raise<std::logic_error>(
"file index pipeline still has input");
78 auto count = i ? this->
stages_[i - 1]->size() : this->
target_->virtual_size();
88 std::span<object_seal_receipt const>
finish() & {
92 std::span<object_seal_receipt const>
finish() && =
delete;
100 if (stage >= this->
stages_.size())
101 error_detail::raise<std::out_of_range>(
"file index pipeline stage is out of range");
102 return this->
stages_[stage]->paths();
113 static std::vector<blob_identity>
identities(std::span<stage_type const> stages) {
114 std::vector<blob_identity> result;
115 result.reserve(stages.size());
116 for (
auto const & stage : stages) result.push_back(stage.identity);
119 template <
bool ExternalOps>
120 static std::vector<std::unique_ptr<builder_type>>
make_stages(std::filesystem::path
const & root,
121 pair_type const & target, std::span<stage_type const> stages, Ops * ops) {
122 if (!target) error_detail::raise<std::invalid_argument>(
"null file index pipeline target");
123 std::unordered_set<std::string> ids;
124 ids.insert(target->identity().index.hex());
125 for (
auto const & stage : stages) {
126 if (!stage.source || stage.identity.native.hex().size() != 32 ||
127 stage.identity.index.hex().size() != 32 || stage.attempt.hex().size() != 32)
128 error_detail::raise<std::invalid_argument>(
"invalid file index pipeline stage");
129 if (!ids.insert(stage.identity.index.hex()).second)
130 error_detail::raise<std::invalid_argument>(
"file index pipeline reuses an index identity");
132 std::vector<std::unique_ptr<builder_type>> result;
133 result.reserve(stages.size());
134 auto downstream = target->identity();
135 for (
auto const & stage : stages) {
136 if constexpr (ExternalOps) result.push_back(std::make_unique<builder_type>(root, stage.identity.index, stage.attempt,
137 stage.source, stage.identity.native, downstream, *ops));
138 else result.push_back(std::make_unique<builder_type>(root, stage.identity.index, stage.attempt,
139 stage.source, stage.identity.native, downstream));
140 downstream = stage.identity;
Builds fractional indexes over pinned native storage into immutable files.
Shares bounded front-coded sample handoff between index pipelines.
Binds immutable mapped blobs to exact dependency chains and validates their samples.
Definition active_engine.h:18
Definition file_index_builder.h:87
Definition file_index_pipeline.h:49
blob_identity const & planned_head() const &&=delete
object_write_paths const & paths(std::size_t) const &&=delete
std::span< object_seal_receipt const > finish() &
Definition file_index_pipeline.h:88
file_index_pipeline(std::filesystem::path root, pair_type target, std::vector< stage_type > stages)
Definition file_index_pipeline.h:55
static std::vector< std::unique_ptr< builder_type > > make_stages(std::filesystem::path const &root, pair_type const &target, std::span< stage_type const > stages, Ops *ops)
Definition file_index_pipeline.h:120
object_write_paths const & paths(std::size_t stage) const &
Definition file_index_pipeline.h:99
bool seal_next()
Definition file_index_pipeline.h:72
file_index_pipeline & operator=(file_index_pipeline const &)=delete
std::span< object_seal_receipt const > completed_receipts() const &noexcept
Definition file_index_pipeline.h:93
static std::vector< blob_identity > identities(std::span< stage_type const > stages)
Definition file_index_pipeline.h:113
file_index_pipeline(file_index_pipeline const &)=delete
file_index_pipeline & operator=(file_index_pipeline &&)=delete
P policy_type
Definition file_index_pipeline.h:50
blob_identity head_
Definition file_index_pipeline.h:110
std::vector< blob_identity > identities_
Definition file_index_pipeline.h:109
file_index_pipeline(file_index_pipeline &&)=delete
std::vector< object_seal_receipt > receipts_
Definition file_index_pipeline.h:111
blob_identity const & planned_head() const &noexcept
Definition file_index_pipeline.h:97
std::span< object_seal_receipt const > finish() &&=delete
std::shared_ptr< blob_type const > pair_type
Definition file_index_pipeline.h:52
std::span< blob_identity const > stage_identities() const &&=delete
file_index_pipeline(std::filesystem::path root, pair_type target, std::vector< stage_type > stages, Ops &ops)
Definition file_index_pipeline.h:60
std::span< object_seal_receipt const > completed_receipts() const &&=delete
std::span< blob_identity const > stage_identities() const &noexcept
Definition file_index_pipeline.h:95
Definition file_index_pipeline.h:30
blob_identity identity
Definition file_index_pipeline.h:32
std::shared_ptr< mapped_native< P > const > source
Definition file_index_pipeline.h:31
object_attempt_id attempt
Definition file_index_pipeline.h:33
Definition index_pipeline_detail.h:39
std::vector< std::unique_ptr< Stage > > stages_
Definition index_pipeline_detail.h:93
bool finished_
Definition index_pipeline_detail.h:98
pair_type target_
Definition index_pipeline_detail.h:90
bool done() const noexcept
Definition index_pipeline_detail.h:57
bool failed_
Definition index_pipeline_detail.h:99
Definition mapped_blob.h:31
Definition object_writer.h:39
Definition object_writer.h:53