Borrow the bytes of a fixed or dynamic BLOB field.
368{
370 if (!field_index || !
has(field_name))
371 return std::nullopt;
373 if (field.type != typeid(std::vector<uint8_t>) && field.type != typeid(detail::CompositeDynamic))
374 return std::nullopt;
375
376 const auto&
rows = std::get<std::vector<uint8_t>>(*m_rows);
379 if (field.type == typeid(detail::CompositeDynamic)) {
380 DynamicCell cell;
381 std::memcpy(&cell, source, sizeof(cell));
382 if (cell.kind != blob_kind)
383 return std::nullopt;
384 slice = { cell.payload, cell.length };
385 } else {
386 std::memcpy(&slice, source, sizeof(slice));
387 }
388 const auto&
blob = std::get<std::vector<uint8_t>>(*m_blob);
390 return std::nullopt;
391 if (
slice.length == 0)
392 return std::span<const uint8_t> {};
393 return std::span<const uint8_t>(
blob.data() +
slice.offset,
static_cast<size_t>(
slice.length));
394}
size_t stride_bytes() const noexcept
Bytes per packed element after finalization.
const std::vector< CompositeField > & fields() const noexcept
Declared fields in element order, with finalized byte offsets.
std::optional< size_t > find_field(std::string_view name) const noexcept
Find a field index by name, or std::nullopt if absent.
const CompositeLayout * m_layout
bool has(std::string_view field_name) const noexcept
Whether a named field exists and is present in this element.
std::optional< std::span< const uint8_t > > blob(std::string_view field_name) const noexcept
Borrow the bytes of a fixed or dynamic BLOB field.
std::vector< double > slice(std::span< const double > data, double start_ratio, double end_ratio)
Extract a contiguous slice by ratio, returning a new vector.