18 namespace profile_detail {
19 template <
class P,
class Ops = posix_
object_ops>
32 std::optional<std::uint64_t> common = P::value_width)
33 :
output_(std::move(root), std::move(id), std::move(attempt), common) {}
35 std::optional<std::uint64_t> common, Ops & ops)
36 :
output_(std::move(root), std::move(id), std::move(attempt), common, ops) {}
41 std::uint64_t
size() const noexcept {
return output_.size(); }
50 if ((key.size() & (P::bits_per_unit - 1)) || (value.size() & (P::bits_per_unit - 1)))
51 error_detail::raise<std::invalid_argument>(
"native file record disagrees with policy units");
52 auto common =
output_.common_value_width();
53 if (common && (value.size() >> P::unit_shift) != *common)
54 error_detail::raise<std::invalid_argument>(
"native file value disagrees with common width");
55 auto comparison = compare_common_bits<typename P::architecture>(
previous_.
view(), key);
56 if (
size() && comparison.order >= 0)
57 error_detail::raise<std::invalid_argument>(
"native file keys must be strictly increasing");
58 auto retained = std::min(comparison.common_bits, retained_limit_bits.value_or(comparison.common_bits)) >> P::unit_shift;
59 auto retained_bits = retained << P::unit_shift;
60 if (key.size() > std::numeric_limits<std::uint64_t>::max() - 7)
61 error_detail::raise<std::length_error>(
"native file key is too large");
64 error_detail::raise<std::length_error>(
"native file key is too large");
67 auto grown = capacity > maximum / 2 ? maximum : 2 * capacity;
68 previous_.
bytes.reserve(std::max(
static_cast<std::size_t
>(bytes), grown));
70 auto literal = key.subview(retained_bits, key.size() - retained_bits);
71 output_.append(retained, literal, value);
std::uint64_t byte_count(std::uint64_t bits) noexcept
Definition profile.h:50
void resize(bit_string &value, std::uint64_t bits)
Definition profile.h:465
void copy_into(bit_string &target, std::uint64_t first, bit_view source)
Definition profile.h:474
Definition active_engine.h:18
Streams native and borrowed profile sections with bounded payload buffering.
std::vector< std::byte > bytes
Definition profile.h:167
bit_view view() const &
Definition profile.h:178
Definition native_file_writer.h:29
native_file_writer(std::filesystem::path root, object_id id, object_attempt_id attempt, std::optional< std::uint64_t > common, Ops &ops)
Definition native_file_writer.h:34
profile_detail::native_file_output< P, Ops > output_
Definition native_file_writer.h:80
object_write_paths const & paths() const &&=delete
bool finished() const noexcept
Definition native_file_writer.h:43
object_write_paths const & paths() const &noexcept
Definition native_file_writer.h:45
object_seal_receipt finish()
Definition native_file_writer.h:76
bool failed() const noexcept
Definition native_file_writer.h:42
void append(profile_record const &record)
Definition native_file_writer.h:75
native_file_writer & operator=(native_file_writer const &)=delete
native_file_writer(native_file_writer const &)=delete
native_file_writer(std::filesystem::path root, object_id id, object_attempt_id attempt, std::optional< std::uint64_t > common=P::value_width)
Definition native_file_writer.h:31
native_file_writer(native_file_writer &&)=delete
bit_string previous_
Definition native_file_writer.h:81
std::uint64_t size() const noexcept
Definition native_file_writer.h:41
std::optional< std::uint64_t > common_value_width() const noexcept
Definition native_file_writer.h:44
P policy_type
Definition native_file_writer.h:30
native_file_writer & operator=(native_file_writer &&)=delete
void append(bit_view key, bit_view value, std::optional< std::uint64_t > retained_limit_bits={})
Definition native_file_writer.h:48
Definition object_writer.h:39
Definition object_path.h:38
Definition object_writer.h:88
Definition object_writer.h:53
Definition profile_file_output.h:44
std::optional< std::uint64_t > retained_limit_bits
Definition profile.h:299
bit_string key
Definition profile.h:295
bit_string value
Definition profile.h:296