Everett
Loading...
Searching...
No Matches
cola_runtime.h
Go to the documentation of this file.
1
12#pragma once
13
14#include <everett/cola_query.h>
15#include <everett/mapped_cola.h>
18
19#include <bit>
20#include <functional>
21#include <limits>
22#include <stdexcept>
23#include <memory>
24#include <optional>
25#include <span>
26#include <unordered_set>
27#include <utility>
28#include <vector>
29
30namespace everett {
31 template <class P> struct cola_runtime_native {
32 using policy_type = P;
33 static std::shared_ptr<cola_runtime_native const> from_owned(profile_array<P> value) {
34 return std::shared_ptr<cola_runtime_native const>(new cola_runtime_native(
35 std::make_shared<profile_array<P> const>(std::move(value))));
36 }
37 static std::shared_ptr<cola_runtime_native const> from_mapped(std::shared_ptr<mapped_native<P> const> value) {
38 if (!value) error_detail::raise<std::invalid_argument>("null mapped runtime native");
39 return std::shared_ptr<cola_runtime_native const>(new cola_runtime_native(std::move(value)));
40 }
41 profile_view<P> view() const { return owned_ ? owned_->view() : mapped_->view(); }
42 std::uint64_t size() const { return view().size(); }
43 std::shared_ptr<profile_array<P> const> owned() const noexcept { return owned_; }
44 std::shared_ptr<mapped_native<P> const> mapped() const noexcept { return mapped_; }
45 private:
46 template <class, class, class, class> friend struct runtime_store;
47 template <class, class, class, class> friend struct runtime_store_detail::graph_sealer;
50 std::shared_ptr<profile_array<P> const> owned_;
51 std::shared_ptr<mapped_native<P> const> mapped_;
52 explicit cola_runtime_native(std::shared_ptr<profile_array<P> const> value) : owned_(std::move(value)) {}
53 explicit cola_runtime_native(std::shared_ptr<mapped_native<P> const> value) : mapped_(std::move(value)) {}
54 };
55
56 // A facade over an existing mapped pair or new owning index. Wrapping a
57 // mapped main chain reads metadata only; payload validation stays explicit.
58 template <class P> struct cola_runtime_node {
59 using policy_type = P;
61 using native_pointer = std::shared_ptr<native_type const>;
62 using pair_type = std::shared_ptr<cola_runtime_node const>;
65 return pair_type(new cola_runtime_node(std::make_shared<built_type const>(std::move(value))));
66 }
67 static pair_type from_mapped(std::shared_ptr<mapped_cola_blob<P> const> head) {
68 if (!head) error_detail::raise<std::invalid_argument>("null mapped runtime root");
69 std::vector<std::shared_ptr<mapped_cola_blob<P> const>> nodes;
70 std::unordered_set<mapped_cola_blob<P> const *> seen;
71 for (auto p = std::move(head); p; p = p->main_target()) {
72 if (!seen.insert(p.get()).second || p->secondary_target())
73 error_detail::raise<std::invalid_argument>("runtime restore requires an acyclic main-only graph");
74 nodes.push_back(p);
75 }
76 pair_type result;
77 for (auto i = nodes.rbegin(); i != nodes.rend(); ++i)
78 result = pair_type(new cola_runtime_node(*i, std::move(result)));
79 return result;
80 }
81 static pair_type from_mapped_parts(std::shared_ptr<mapped_cola_blob<P> const> source,
83 if (!source || !native || native->mapped() != source->native_object() || secondary || source->secondary_target() ||
84 bool(main) != bool(source->main_target()) || (main && main->mapped() != source->main_target()))
85 error_detail::raise<std::invalid_argument>("runtime mapped parts do not retain exact targets");
86 return pair_type(new cola_runtime_node(std::move(source), std::move(native), std::move(main)));
87 }
88 cola_index_view<P> view() const { return built_ ? built_->view() : mapped_->view(); }
89 native_pointer native_owner() const noexcept { return native_; }
90 native_type const & native() const & noexcept { return *native_; }
91 native_type const & native() const && = delete;
92 pair_type main_target() const noexcept { return main_; }
93 native_pointer secondary_target() const noexcept { return {}; }
94 std::uint64_t virtual_size() const { return view().virtual_size(); }
95 std::uint64_t group_count() const { return view().group_count(); }
96 std::uint64_t depth() const noexcept { return depth_; }
97 std::shared_ptr<built_type const> built() const noexcept { return built_; }
98 std::shared_ptr<mapped_cola_blob<P> const> mapped() const noexcept { return mapped_; }
99 bool canonical_mapped() const noexcept { return canonical_mapped_; }
100 private:
101 template <class, class, class, class> friend struct runtime_store;
102 template <class, class, class, class> friend struct runtime_store_detail::graph_sealer;
107 std::shared_ptr<built_type const> built_;
108 std::shared_ptr<mapped_cola_blob<P> const> mapped_;
109 std::uint64_t depth_;
110 bool canonical_mapped_ = false;
111 explicit cola_runtime_node(std::shared_ptr<built_type const> value)
112 : native_(value->native_owner()), main_(value->main_target()), built_(std::move(value)),
113 depth_(profile_detail::add(main_ ? main_->depth() : 0, 1)) {
114 if (built_->secondary_target()) error_detail::raise<std::invalid_argument>("runtime node has a secondary");
115 }
117 : native_(native_type::from_mapped(value->native_object())), main_(std::move(main)), mapped_(std::move(value)),
118 depth_(profile_detail::add(main_ ? main_->depth() : 0, 1)), canonical_mapped_(!main_ || main_->canonical_mapped()) {}
120 : native_(std::move(native)), main_(std::move(main)), mapped_(std::move(value)),
121 depth_(profile_detail::add(main_ ? main_->depth() : 0, 1)),
123 };
124
126 std::uint64_t first = 0, last = 0;
127 std::uint64_t mass() const noexcept { return last - first; }
128 bool operator==(cola_runtime_interval const &) const = default;
129 };
130 template <class P> struct cola_runtime_run {
131 std::uint64_t first = 0, last = 0;
132 std::shared_ptr<cola_runtime_node<P> const> node;
133 std::uint64_t mass() const noexcept { return last - first; }
134 auto native_owner() const noexcept { return node->native_owner(); }
135 };
136 template <class P, class Compose> struct cola_runtime;
137
138 // All owners are immutable. Runs are oldest first, whereas cursor matches
139 // are newest first. Intervals count admissions even when keys coalesce.
140 template <class P> struct cola_runtime_snapshot {
141 using policy_type = P;
146 std::uint64_t admissions() const noexcept { return state_->admissions; }
147 bool settled() const noexcept {
148 auto const & r = state_->runs;
149 return r.size() < 2 || r[r.size() - 2].mass() != r.back().mass();
150 }
151 std::span<run_type const> runs() const & noexcept { return state_->runs; }
152 std::span<run_type const> runs() const && = delete;
153 query_type const & query_root() const & noexcept { return state_->query; }
154 query_type const & query_root() const && = delete;
155 auto cursor(bit_view key) const { return state_->query.cursor(key); }
156 auto cursor_owned(bit_string key) const { return state_->query.cursor_owned(std::move(key)); }
157 bool same_layout(cola_runtime_snapshot const & other) const noexcept { return state_ == other.state_; }
158
159 // Restore the frontier, not a mutable continuation. The supplied mapped or
160 // built graph must already be trusted/admitted. Only metadata is inspected.
161 // Empty routing nodes are omitted from the oldest-first interval list.
162 static cola_runtime_snapshot restore(pair_type head, std::span<cola_runtime_interval const> intervals) {
163 auto query = query_type::adopt_prepared(std::move(head));
164 std::vector<pair_type> sources;
165 for (auto p = query.head(); p; p = p->main_target())
166 if (p->native_owner()->size()) sources.push_back(p);
167 if (sources.size() != intervals.size())
168 error_detail::raise<std::invalid_argument>("runtime interval count differs from query graph");
169 std::vector<run_type> runs;
170 std::uint64_t next = 0, previous = 0;
171 for (std::size_t i = 0; i != intervals.size(); ++i) {
172 auto span = intervals[i];
173 if (span.first != next || span.last <= span.first || !std::has_single_bit(span.mass()) ||
174 (i && span.mass() >= previous && !(i + 1 == intervals.size() && previous == 1 && span.mass() == 1)))
175 error_detail::raise<std::invalid_argument>("invalid runtime admission frontier");
176 auto source = sources[sources.size() - i - 1];
177 if (source->native_owner()->size() > span.mass())
178 error_detail::raise<std::invalid_argument>("runtime native exceeds admission mass");
179 runs.push_back({span.first, span.last, std::move(source)});
180 next = span.last; previous = span.mass();
181 }
182 return make(std::move(query), std::move(runs), next);
183 }
184 private:
185 template <class, class> friend struct cola_runtime;
186 struct state {
188 std::vector<run_type> runs;
189 std::uint64_t admissions;
190 };
191 std::shared_ptr<state const> state_;
192 explicit cola_runtime_snapshot(std::shared_ptr<state const> value) : state_(std::move(value)) {}
193 static cola_runtime_snapshot make(query_type query, std::vector<run_type> runs, std::uint64_t admissions) {
194 return cola_runtime_snapshot(std::make_shared<state const>(state{
195 std::move(query), std::move(runs), admissions}));
196 }
197 };
198
199 // Structural charges are allowances for executed/attempted operations, not
200 // CPU cycles or a byte/latency bound. Counters also report completed records.
202 std::uint64_t charged = 0, granted = 0;
203 std::uint64_t setup = 0, native_allowance = 0;
205 std::uint64_t directory_entries = 0, publication = 0;
207 std::uint64_t native_merges = 0, indexes = 0, carriers = 0, admitted_records = 0;
208 };
209
210 // Low-level ACTIVE encoded executor. Compose is supplied by the active
211 // registry handler; it is not the world's semantic type. Existing FC records
212 // are accepted here, not arbitrary per-sort physical grammars.
213 //
214 // An admission is immediately queryable. One private binary carry chain may
215 // remain. The next admission drains that chain first, providing conservative
216 // backpressure. Extra service changes only equivalent immutable layouts.
217 // Credits pay real operations; finalization requires its whole structural
218 // allowance and executes atomically, so single-call latency is not bounded.
219 // Exceptions during execution poison the executor while retaining its last
220 // published snapshot and private input pins. Invalid input preflight does not.
221 template <class P, class Compose = replace_native_value> struct cola_runtime {
222 using policy_type = P;
230 explicit cola_runtime(Compose compose = {}) : execution_(std::make_unique<execution>(std::move(compose))) {}
231 static cola_runtime from_snapshot(snapshot_type source, Compose compose = {}) {
232 return cola_runtime(std::make_unique<execution>(std::move(source), std::move(compose)));
233 }
234 cola_runtime(cola_runtime const &) = delete;
236 cola_runtime(cola_runtime &&) noexcept = default;
237 cola_runtime & operator=(cola_runtime &&) noexcept = default;
239 bool pending() const noexcept { return execution_ && bool(execution_->job); }
240 bool admission_ready() const noexcept { return execution_ && !execution_->failed && !execution_->job; }
241 std::uint64_t next_service_cost() const { auto const & e = active(); return e.job ? e.price() : 0; }
242 // Metadata-only structural cost of a ready singleton admission, excluding
243 // optional service. This does not bound key bytes, callbacks or latency.
244 std::uint64_t admission_cost() const {
245 auto const & e = active();
246 if (e.job) error_detail::raise<std::logic_error>("runtime admission requires service");
247 auto r = e.published.runs();
248 auto head = e.published.query_root().head();
249 auto borrowed = head->group_count();
250 auto n = execution::add(9, profile_detail::multiply(execution::add(borrowed, 1), P::group_size + 6));
252 n = execution::add(n, execution::add(execution::add(r.size(), head->depth()), 3));
253 if (!r.empty() && r.back().mass() == 1) n = execution::add(n, execution::add(r.size(), 2));
254 return n;
255 }
256 // Refusal is a no-op. Old debt is never silently charged as admission work.
257 std::optional<snapshot_type> try_contribute(profile_record const & record, std::uint64_t service_budget = 0) {
258 auto & e = writable();
259 if (e.job) return std::nullopt;
260 return contribute(record, service_budget);
261 }
262 bool failed() const noexcept { return execution_ && execution_->failed; }
263 cola_runtime_work work() const { return active().work; }
264 std::uint64_t credit() const { return active().credit; }
265 snapshot_type advance(std::uint64_t budget) {
266 auto & e = writable();
267 if (!budget || !e.job) return e.published;
268 try { e.grant(budget); e.serve(); }
269 catch (...) { e.failed = true; throw; }
270 return e.published;
271 }
272 snapshot_type contribute(profile_record const & record, std::uint64_t service_budget = 64) {
273 return contribute(std::span<profile_record const>(&record, 1), service_budget);
274 }
275 // A batch is nondecreasing by encoded key; equal keys are chronological
276 // separate admissions. Preflight precedes any work; a later execution
277 // failure rolls the entire batch's visible state back and poisons this handle.
278 snapshot_type contribute(std::span<profile_record const> records, std::uint64_t service_budget = 64) {
279 auto & e = writable();
280 (void)profile_detail::add(e.published.admissions(), records.size());
281 bit_view previous;
282 for (std::size_t i = 0; i != records.size(); ++i) {
283 auto key = records[i].key.view(), value = records[i].value.view();
284 if ((key.size() & (P::bits_per_unit - 1)) || (value.size() & (P::bits_per_unit - 1)) ||
285 (P::value_width && (value.size() >> P::unit_shift) != *P::value_width) ||
286 (i && compare_bits<typename P::architecture>(previous, key) > 0))
287 error_detail::raise<std::invalid_argument>("invalid encoded runtime contribution");
288 previous = key;
289 }
290 auto before = e.published;
291 try {
292 for (auto const & record : records) {
293 e.drain();
294 e.admit(record);
295 if (service_budget && e.job) { e.grant(service_budget); e.serve(); }
296 }
297 } catch (...) { e.published = std::move(before); e.failed = true; throw; }
298 return e.published;
299 }
300 private:
301 using merge_compose = std::conditional_t<std::is_same_v<Compose, replace_native_value>,
302 Compose, std::reference_wrapper<Compose>>;
307 std::vector<run_type> prefix;
310 std::uint64_t first, last;
312 bool carrier = false;
314 std::unique_ptr<merge_type> merge;
315 std::unique_ptr<index_type> index;
316 explicit continuation(snapshot_type const & source) : prefix(source.runs().begin(), source.runs().end()) {
317 auto newest = prefix.back(); prefix.pop_back();
318 carry = newest.native_owner(); first = newest.first; last = newest.last;
319 older = prefix.back(); prefix.pop_back();
320 target = older.node->main_target();
321 }
322 };
323 struct execution {
324 Compose compose;
327 std::unique_ptr<continuation> job;
329 std::uint64_t credit = 0;
330 bool failed = false;
333 index_type builder(std::move(native));
334 auto node = node_type::from_built(builder.finish());
335 return snapshot_type::make(query_type::adopt_prepared(std::move(node)), {}, 0);
336 }
337 explicit execution(Compose value)
338 : compose(std::move(value)), empty(empty_native()), published(initial(empty)) {
340 }
341 execution(snapshot_type source, Compose value)
342 : compose(std::move(value)), empty(empty_native()), published(std::move(source)) {
344 if (!published.settled()) start_job();
345 }
346 static std::uint64_t add(std::uint64_t a, std::uint64_t b) { return profile_detail::add(a, b); }
347 static std::uint64_t blocks(std::uint64_t n) { return n / P::codec_block_size + (n % P::codec_block_size != 0); }
348 void grant(std::uint64_t amount) {
349 auto next = add(credit, amount), granted = add(work.granted, amount);
350 credit = next; work.granted = granted;
351 }
352 void direct(std::uint64_t amount, std::uint64_t cola_runtime_work::* field) {
353 auto next = work;
354 next.charged = add(next.charged, amount); next.granted = add(next.granted, amount);
355 next.*field = add(next.*field, amount); work = next;
356 }
357 void direct_setup(std::uint64_t n) { direct(n, &cola_runtime_work::setup); }
361 if constexpr (std::is_same_v<Compose, replace_native_value>) return compose;
362 else return std::ref(compose);
363 }
364 // Drop only empty routing ancestors. Never skip an actual native run.
365 static pair_type near(pair_type target, std::uint64_t mass) {
366 auto limit = mass > std::numeric_limits<std::uint64_t>::max() / P::group_size ?
367 std::numeric_limits<std::uint64_t>::max() : mass * P::group_size;
368 while (target && !target->native_owner()->size() && target->main_target() &&
369 target->main_target()->virtual_size() <= limit) target = target->main_target();
370 return target;
371 }
373 auto borrowed = target ? target->group_count() : 0;
374 direct_setup(5);
375 index_type builder(std::move(native), std::move(target));
376 while (!builder.done()) {
380 builder.step(1);
381 }
384 auto result = builder.finish();
386 return node_type::from_built(std::move(result));
387 }
388 void start_job() {
389 direct_setup(add(published.runs().size(), 1));
390 job = std::make_unique<continuation>(published);
391 }
392 void admit(profile_record const & record) {
393 direct_setup(1);
396 writer.append(record);
398 auto native = native_type::from_owned(writer.finish());
401 auto runs = std::vector<run_type>(published.runs().begin(), published.runs().end());
402 auto next = add(published.admissions(), 1);
403 runs.push_back({published.admissions(), next, head});
404 direct_publication(add(add(runs.size(), head->depth()), 1));
405 published = snapshot_type::make(query_type::adopt_prepared(head), std::move(runs), next);
407 if (!published.settled()) start_job();
408 }
409 std::uint64_t price() const {
410 auto const & j = *job;
411 switch (j.stage) {
412 case phase::merge_start: return 3;
413 case phase::merge_step: return 3;
414 case phase::merge_finish: return add(blocks(j.merge->progress().keys), 2);
415 case phase::index_start: return 5;
416 case phase::index_step: return add(P::group_size, 6);
417 case phase::index_finish: return add(blocks(j.target ? j.target->group_count() : 0), 5);
418 case phase::publish: return add(add(j.prefix.size(), j.head->depth()), 2);
419 }
420 error_detail::raise<std::logic_error>("invalid runtime stage");
421 }
422 void charge(std::uint64_t amount) {
423 auto next = work;
424 next.charged = add(next.charged, amount);
425 switch (job->stage) {
426 case phase::merge_start: case phase::index_start: next.setup = add(next.setup, amount); break;
427 case phase::merge_step: next.native_allowance = add(next.native_allowance, amount); break;
428 case phase::merge_finish: next.directory_entries = add(next.directory_entries, amount - 1);
429 next.setup = add(next.setup, 1); break;
431 next.index_occurrences = add(next.index_occurrences, 1);
432 next.target_scan_allowance = add(next.target_scan_allowance, P::group_size);
433 next.navigation_allowance = add(next.navigation_allowance, 5); break;
434 case phase::index_finish: next.directory_entries = add(next.directory_entries, amount - 3);
435 next.navigation_allowance = add(next.navigation_allowance, 3); break;
436 case phase::publish: next.publication = add(next.publication, amount); break;
437 }
438 work = next; credit -= amount;
439 }
440 void perform() {
441 auto & j = *job;
442 switch (j.stage) {
444 j.merge = std::make_unique<merge_type>(j.older.native_owner(), j.carry, merger());
445 j.stage = j.merge->done() ? phase::merge_finish : phase::merge_step;
446 break;
447 case phase::merge_step: {
448 auto done = j.merge->step(1);
451 if (j.merge->done()) j.stage = phase::merge_finish;
452 break;
453 }
455 j.carry = native_type::from_owned(j.merge->finish()); j.merge.reset();
457 j.first = j.older.first;
458 if (!j.prefix.empty() && j.prefix.back().mass() == j.last - j.first) {
459 j.older = j.prefix.back(); j.prefix.pop_back(); j.target = j.older.node->main_target();
460 j.stage = phase::merge_start;
461 } else {
462 j.target = near(std::move(j.target), j.last - j.first);
463 j.stage = phase::index_start;
464 }
465 break;
467 j.index = std::make_unique<index_type>(j.carrier ? empty : j.carry, j.target);
468 j.stage = j.index->done() ? phase::index_finish : phase::index_step;
469 break;
471 j.index->step(1);
472 if (j.index->done()) j.stage = phase::index_finish;
473 break;
475 j.head = node_type::from_built(j.index->finish()); j.index.reset();
477 if (j.carrier) work.carriers = add(work.carriers, 1);
478 else j.result_node = j.head;
479 if (j.head->virtual_size() > P::group_size) {
480 j.target = j.head; j.carrier = true; j.stage = phase::index_start;
481 } else j.stage = phase::publish;
482 break;
483 case phase::publish: {
484 j.prefix.push_back({j.first, j.last, j.result_node});
485 auto result = snapshot_type::make(query_type::adopt_prepared(j.head), std::move(j.prefix), j.last);
486 published = std::move(result); job.reset(); credit = 0;
487 break;
488 }
489 }
490 }
491 void serve() {
492 while (job) {
493 auto amount = price();
494 if (amount > credit) break;
495 charge(amount); perform();
496 }
497 }
498 void drain() {
499 while (job) {
500 auto amount = price();
501 if (credit < amount) grant(amount - credit);
502 serve();
503 }
504 }
505 };
506 std::unique_ptr<execution> execution_;
507 explicit cola_runtime(std::unique_ptr<execution> value) : execution_(std::move(value)) {}
508 execution const & active() const {
509 if (!execution_) error_detail::raise<std::logic_error>("moved-from COLA runtime");
510 return *execution_;
511 }
513 (void)active();
514 if (execution_->failed) error_detail::raise<std::logic_error>("failed COLA runtime");
515 return *execution_;
516 }
517 };
518
526}
Enumerates native matches along a COLA main chain and its terminal secondaries.
Binds mapped COLA main and secondary targets with exact immutable pins.
std::uint64_t add(std::uint64_t a, std::uint64_t b)
Definition profile.h:39
std::uint64_t multiply(std::uint64_t a, std::uint64_t b)
Definition profile.h:44
Definition active_engine.h:18
Merges ordered native streams incrementally with policy-specific value composition.
Describes completed native and index objects retained by runtime owners.
Definition cola_runtime.h:519
P policy_type
Definition cola_runtime.h:520
Definition profile.h:166
bit_view view() const &
Definition profile.h:178
Definition profile.h:56
Definition catalog_bindings.h:25
Definition cola_index.h:496
auto finish()
Definition cola_index.h:581
bool done() const noexcept
Definition cola_index.h:520
std::uint64_t step(std::uint64_t budget)
Definition cola_index.h:529
Definition cola_index.h:114
Definition cola_index.h:315
static cola_query_root adopt_prepared(pair_type source)
Definition cola_query.h:47
pair_type head() const noexcept
Definition cola_query.h:63
cola_query_cursor< P, Blob > cursor(bit_view query) const
Definition cola_query.h:64
Definition cola_runtime.h:306
pair_type head
Definition cola_runtime.h:311
std::vector< run_type > prefix
Definition cola_runtime.h:307
pair_type result_node
Definition cola_runtime.h:311
phase stage
Definition cola_runtime.h:313
std::unique_ptr< index_type > index
Definition cola_runtime.h:315
native_pointer carry
Definition cola_runtime.h:309
bool carrier
Definition cola_runtime.h:312
pair_type target
Definition cola_runtime.h:311
std::uint64_t first
Definition cola_runtime.h:310
std::uint64_t last
Definition cola_runtime.h:310
std::unique_ptr< merge_type > merge
Definition cola_runtime.h:314
continuation(snapshot_type const &source)
Definition cola_runtime.h:316
run_type older
Definition cola_runtime.h:308
Definition cola_runtime.h:323
void charge(std::uint64_t amount)
Definition cola_runtime.h:422
static pair_type near(pair_type target, std::uint64_t mass)
Definition cola_runtime.h:365
void grant(std::uint64_t amount)
Definition cola_runtime.h:348
execution(snapshot_type source, Compose value)
Definition cola_runtime.h:341
void direct_setup(std::uint64_t n)
Definition cola_runtime.h:357
static std::uint64_t blocks(std::uint64_t n)
Definition cola_runtime.h:347
void direct_publication(std::uint64_t n)
Definition cola_runtime.h:359
execution(Compose value)
Definition cola_runtime.h:337
void admit(profile_record const &record)
Definition cola_runtime.h:392
void serve()
Definition cola_runtime.h:491
snapshot_type published
Definition cola_runtime.h:326
std::uint64_t price() const
Definition cola_runtime.h:409
cola_runtime_work work
Definition cola_runtime.h:328
native_pointer empty
Definition cola_runtime.h:325
std::uint64_t credit
Definition cola_runtime.h:329
void perform()
Definition cola_runtime.h:440
void direct(std::uint64_t amount, std::uint64_t cola_runtime_work::*field)
Definition cola_runtime.h:352
std::unique_ptr< continuation > job
Definition cola_runtime.h:327
static native_pointer empty_native()
Definition cola_runtime.h:331
pair_type immediate_index(native_pointer native, pair_type target)
Definition cola_runtime.h:372
void direct_directory(std::uint64_t n)
Definition cola_runtime.h:358
merge_compose merger()
Definition cola_runtime.h:360
void drain()
Definition cola_runtime.h:498
static std::uint64_t add(std::uint64_t a, std::uint64_t b)
Definition cola_runtime.h:346
void start_job()
Definition cola_runtime.h:388
static snapshot_type initial(native_pointer native)
Definition cola_runtime.h:332
Compose compose
Definition cola_runtime.h:324
bool failed
Definition cola_runtime.h:330
Definition cola_runtime.h:125
std::uint64_t mass() const noexcept
Definition cola_runtime.h:127
std::uint64_t last
Definition cola_runtime.h:126
bool operator==(cola_runtime_interval const &) const =default
std::uint64_t first
Definition cola_runtime.h:126
Definition cola_runtime.h:31
std::shared_ptr< mapped_native< P > const > mapped() const noexcept
Definition cola_runtime.h:44
profile_view< P > view() const
Definition cola_runtime.h:41
cola_runtime_native(std::shared_ptr< mapped_native< P > const > value)
Definition cola_runtime.h:53
std::shared_ptr< profile_array< P > const > owned_
Definition cola_runtime.h:50
catalog_bindings< native_binding< mapped_native< P > > > bindings_
Definition cola_runtime.h:48
std::shared_ptr< mapped_native< P > const > mapped_
Definition cola_runtime.h:51
static std::shared_ptr< cola_runtime_native const > from_owned(profile_array< P > value)
Definition cola_runtime.h:33
catalog_bindings< cola_runtime_native > mapped_owners_
Definition cola_runtime.h:49
cola_runtime_native(std::shared_ptr< profile_array< P > const > value)
Definition cola_runtime.h:52
std::uint64_t size() const
Definition cola_runtime.h:42
std::shared_ptr< profile_array< P > const > owned() const noexcept
Definition cola_runtime.h:43
P policy_type
Definition cola_runtime.h:32
static std::shared_ptr< cola_runtime_native const > from_mapped(std::shared_ptr< mapped_native< P > const > value)
Definition cola_runtime.h:37
Definition cola_runtime.h:58
cola_index_view< P > view() const
Definition cola_runtime.h:88
std::uint64_t virtual_size() const
Definition cola_runtime.h:94
static pair_type from_built(built_type value)
Definition cola_runtime.h:64
cola_runtime_node(std::shared_ptr< built_type const > value)
Definition cola_runtime.h:111
bool canonical_mapped() const noexcept
Definition cola_runtime.h:99
catalog_bindings< cola_runtime_node > mapped_owners_
Definition cola_runtime.h:104
catalog_bindings< pair_binding< mapped_cola_blob< P > > > bindings_
Definition cola_runtime.h:103
native_type const & native() const &noexcept
Definition cola_runtime.h:90
bool canonical_mapped_
Definition cola_runtime.h:110
std::shared_ptr< mapped_cola_blob< P > const > mapped_
Definition cola_runtime.h:108
std::shared_ptr< mapped_cola_blob< P > const > mapped() const noexcept
Definition cola_runtime.h:98
static pair_type from_mapped(std::shared_ptr< mapped_cola_blob< P > const > head)
Definition cola_runtime.h:67
pair_type main_
Definition cola_runtime.h:106
cola_runtime_node(std::shared_ptr< mapped_cola_blob< P > const > value, native_pointer native, pair_type main)
Definition cola_runtime.h:119
native_type const & native() const &&=delete
P policy_type
Definition cola_runtime.h:59
native_pointer native_owner() const noexcept
Definition cola_runtime.h:89
std::shared_ptr< built_type const > built() const noexcept
Definition cola_runtime.h:97
std::shared_ptr< built_type const > built_
Definition cola_runtime.h:107
std::uint64_t depth_
Definition cola_runtime.h:109
native_pointer native_
Definition cola_runtime.h:105
pair_type main_target() const noexcept
Definition cola_runtime.h:92
std::uint64_t group_count() const
Definition cola_runtime.h:95
cola_runtime_node(std::shared_ptr< mapped_cola_blob< P > const > value, pair_type main)
Definition cola_runtime.h:116
std::shared_ptr< cola_runtime_node const > pair_type
Definition cola_runtime.h:62
static pair_type from_mapped_parts(std::shared_ptr< mapped_cola_blob< P > const > source, native_pointer native, pair_type main, native_pointer secondary={})
Definition cola_runtime.h:81
native_pointer secondary_target() const noexcept
Definition cola_runtime.h:93
std::shared_ptr< native_type const > native_pointer
Definition cola_runtime.h:61
std::uint64_t depth() const noexcept
Definition cola_runtime.h:96
Definition cola_runtime.h:130
std::uint64_t last
Definition cola_runtime.h:131
std::uint64_t first
Definition cola_runtime.h:131
std::shared_ptr< cola_runtime_node< P > const > node
Definition cola_runtime.h:132
std::uint64_t mass() const noexcept
Definition cola_runtime.h:133
auto native_owner() const noexcept
Definition cola_runtime.h:134
Definition cola_runtime.h:186
std::vector< run_type > runs
Definition cola_runtime.h:188
std::uint64_t admissions
Definition cola_runtime.h:189
query_type query
Definition cola_runtime.h:187
Definition cola_runtime.h:140
static cola_runtime_snapshot restore(pair_type head, std::span< cola_runtime_interval const > intervals)
Definition cola_runtime.h:162
bool settled() const noexcept
Definition cola_runtime.h:147
bool same_layout(cola_runtime_snapshot const &other) const noexcept
Definition cola_runtime.h:157
std::shared_ptr< state const > state_
Definition cola_runtime.h:191
cola_query_root< P, node_type > query_type
Definition cola_runtime.h:144
std::span< run_type const > runs() const &noexcept
Definition cola_runtime.h:151
std::span< run_type const > runs() const &&=delete
auto cursor(bit_view key) const
Definition cola_runtime.h:155
query_type const & query_root() const &&=delete
static cola_runtime_snapshot make(query_type query, std::vector< run_type > runs, std::uint64_t admissions)
Definition cola_runtime.h:193
P policy_type
Definition cola_runtime.h:141
query_type const & query_root() const &noexcept
Definition cola_runtime.h:153
cola_runtime_snapshot(std::shared_ptr< state const > value)
Definition cola_runtime.h:192
std::uint64_t admissions() const noexcept
Definition cola_runtime.h:146
auto cursor_owned(bit_string key) const
Definition cola_runtime.h:156
typename node_type::pair_type pair_type
Definition cola_runtime.h:143
Definition cola_runtime.h:201
std::uint64_t granted
Definition cola_runtime.h:202
std::uint64_t charged
Definition cola_runtime.h:202
std::uint64_t publication
Definition cola_runtime.h:205
std::uint64_t target_scan_allowance
Definition cola_runtime.h:204
std::uint64_t index_occurrences
Definition cola_runtime.h:204
std::uint64_t native_input_records
Definition cola_runtime.h:206
std::uint64_t directory_entries
Definition cola_runtime.h:205
std::uint64_t admitted_records
Definition cola_runtime.h:207
std::uint64_t navigation_allowance
Definition cola_runtime.h:204
std::uint64_t carriers
Definition cola_runtime.h:207
std::uint64_t indexes
Definition cola_runtime.h:207
std::uint64_t native_merges
Definition cola_runtime.h:207
std::uint64_t native_output_records
Definition cola_runtime.h:206
std::uint64_t native_allowance
Definition cola_runtime.h:203
std::uint64_t setup
Definition cola_runtime.h:203
Definition cola_runtime.h:221
cola_runtime(cola_runtime const &)=delete
std::uint64_t admission_cost() const
Definition cola_runtime.h:244
typename node_type::native_pointer native_pointer
Definition cola_runtime.h:226
snapshot_type contribute(std::span< profile_record const > records, std::uint64_t service_budget=64)
Definition cola_runtime.h:278
bool failed() const noexcept
Definition cola_runtime.h:262
execution const & active() const
Definition cola_runtime.h:508
typename node_type::pair_type pair_type
Definition cola_runtime.h:227
cola_runtime & operator=(cola_runtime const &)=delete
snapshot_type contribute(profile_record const &record, std::uint64_t service_budget=64)
Definition cola_runtime.h:272
phase
Definition cola_runtime.h:305
bool admission_ready() const noexcept
Definition cola_runtime.h:240
std::uint64_t next_service_cost() const
Definition cola_runtime.h:241
cola_runtime(Compose compose={})
Definition cola_runtime.h:230
cola_runtime_work work() const
Definition cola_runtime.h:263
std::optional< snapshot_type > try_contribute(profile_record const &record, std::uint64_t service_budget=0)
Definition cola_runtime.h:257
static cola_runtime from_snapshot(snapshot_type source, Compose compose={})
Definition cola_runtime.h:231
typename snapshot_type::query_type query_type
Definition cola_runtime.h:229
execution & writable()
Definition cola_runtime.h:512
bool pending() const noexcept
Definition cola_runtime.h:239
cola_runtime(std::unique_ptr< execution > value)
Definition cola_runtime.h:507
std::unique_ptr< execution > execution_
Definition cola_runtime.h:506
cola_runtime(cola_runtime &&) noexcept=default
P policy_type
Definition cola_runtime.h:222
std::uint64_t credit() const
Definition cola_runtime.h:264
snapshot_type advance(std::uint64_t budget)
Definition cola_runtime.h:265
snapshot_type snapshot() const
Definition cola_runtime.h:238
std::conditional_t< std::is_same_v< Compose, replace_native_value >, Compose, std::reference_wrapper< Compose > > merge_compose
Definition cola_runtime.h:302
Definition mapped_cola.h:33
Definition sections.h:442
Definition native_merge.h:174
Definition profile.h:1168
Definition native_writer.h:158
void append(bit_view key, bit_view value, std::optional< std::uint64_t > retained_limit_bits={})
Definition native_writer.h:181
profile_array< P > finish()
Definition native_writer.h:208
Definition profile.h:294
Definition profile.h:695
Definition query.h:51
Definition runtime_graph_sealer.h:22
Definition runtime_store.h:58