33 static_assert(Ops::supported,
"Everett object streams require supported filesystem operations");
44 :
object_stream(std::move(root), std::move(id), std::move(attempt), kind, 0, ops) {}
68 void append(std::span<std::
byte const> bytes) {
70 constexpr auto maximum = std::uint64_t(std::numeric_limits<std::int64_t>::max()) -
73 throw std::length_error(
"Everett object exceeds supported file offsets");
75 while (!bytes.empty()) {
76 auto part = bytes.first(std::min(bytes.size(), std::size_t{1} << 20));
78 crc_ = crc32c<typename P::architecture>(part,
crc_);
81 bytes = bytes.subspan(part.size());
99 throw std::invalid_argument(
"Everett streamed body metadata mismatch");
102 if ((header.
extent & 7) &&
103 (std::to_integer<unsigned>(last) & ((1u << (8 - (header.
extent & 7))) - 1)))
104 throw std::invalid_argument(
"noncanonical bit-profile tail padding");
111 run_.write_header(encoded);
126 throw std::length_error(
"Everett object prefix exceeds supported file offsets");
131 throw std::invalid_argument(
"unsupported Everett object kind");
136 std::array<std::byte, file_detail::header_bytes> placeholder{};
137 run_.write_all(placeholder);
138 std::array<std::byte, 4096> zero{};
141 auto count = std::min(left, zero.size());
142 append(std::span(zero).first(count));
148 if (
failed_ ||
finished_)
throw std::logic_error(
"Everett object stream is inactive");
void validate_metadata(file_header< P > const &header)
Definition file.h:93
constexpr std::size_t header_bytes
Definition file.h:47
Definition active_engine.h:18
std::uint32_t crc32c_combine(std::uint32_t first, std::uint32_t second, std::uint64_t second_bytes) noexcept
std::array< std::byte, file_detail::header_bytes > encode_file_header(file_header< P > const &header, std::uint32_t body_crc)
Definition file.h:194
file_kind
Definition object_path.h:25
Streams and seals immutable object files without catalog publication.
Definition object_writer.h:39
Definition object_path.h:38
Definition object_writer.h:88
Definition object_stream.h:32
void append(std::span< std::byte const > bytes)
Definition object_stream.h:68
std::uint64_t body_bytes_
Definition object_stream.h:158
object_id id_
Definition object_stream.h:151
std::optional< Ops > owned_ops_
Definition object_stream.h:155
std::byte last_
Definition object_stream.h:161
Ops & ops_
Definition object_stream.h:156
std::uint32_t crc_
Definition object_stream.h:159
bool failed_
Definition object_stream.h:162
std::uint32_t prefix_crc_
Definition object_stream.h:160
object_write_paths const & paths() const &noexcept
Definition object_stream.h:62
object_writer< P, Ops >::operation run_
Definition object_stream.h:157
void open()
Definition object_stream.h:134
object_stream & operator=(object_stream const &)=delete
std::uint64_t body_bytes() const noexcept
Definition object_stream.h:55
object_stream & operator=(object_stream &&)=delete
object_stream(std::filesystem::path root, object_id id, object_attempt_id attempt, file_kind kind, std::size_t prefix_bytes=0)
Definition object_stream.h:36
bool failed() const noexcept
Definition object_stream.h:60
std::uint32_t body_crc32c() const noexcept
Definition object_stream.h:59
std::filesystem::path root_
Definition object_stream.h:150
bool finished_
Definition object_stream.h:163
object_attempt_id attempt_
Definition object_stream.h:152
object_stream(object_stream &&)=delete
void require_active() const
Definition object_stream.h:147
object_seal_receipt finish(file_header< P > const &header, std::span< std::byte const > prefix)
Definition object_stream.h:94
object_stream(std::filesystem::path root, object_id id, object_attempt_id attempt, file_kind kind, std::size_t prefix_bytes, Ops &ops)
Definition object_stream.h:45
file_kind kind_
Definition object_stream.h:153
object_stream(object_stream const &)=delete
bool finished() const noexcept
Definition object_stream.h:61
P policy_type
Definition object_stream.h:34
static std::size_t checked_prefix(std::size_t bytes)
Definition object_stream.h:124
static file_kind checked(file_kind kind)
Definition object_stream.h:129
object_stream(std::filesystem::path root, object_id id, object_attempt_id attempt, file_kind kind, Ops &ops)
Definition object_stream.h:42
object_write_paths const & paths() const &&=delete
object_seal_receipt finish(file_header< P > const &header)
Definition object_stream.h:91
std::size_t prefix_bytes_
Definition object_stream.h:154
Definition object_writer.h:53
Definition object_writer.h:235