Pixie
Loading...
Searching...
No Matches
pixie::AlignedStorage Class Reference

Owning storage with a logical byte size and 64-byte-aligned backing. More...

#include <aligned.h>

Inheritance diagram for pixie::AlignedStorage:
pixie::StorageBase< AlignedStorage > pixie::SerializationBase< AlignedStorage >

Public Member Functions

 AlignedStorage (std::size_t size_bits)
 Construct storage for at least size_bits bits.
 
 AlignedStorage (std::span< const std::uint64_t > words)
 Copy complete 64-bit words into aligned owning storage.
 
std::size_t size_bytes_impl () const
 Return the logical number of exposed bytes.
 
position_type begin_position_impl () const
 Return the first logical byte position.
 
position_type end_position_impl () const
 Return the position one past the final logical byte.
 
std::size_t logical_size_bytes () const
 Return the logical number of exposed bytes.
 
std::size_t padded_size_bytes () const
 Return the cache-line-rounded backing size in bytes.
 
ReadOnlyStorageView padded_view () const
 Return a non-owning view of the complete cache-line backing.
 
std::span< const std::byte > as_bytes_impl () const
 Return the logical bytes as a read-only span.
 
SplitSpan< const std::byte > segments_impl (std::size_t offset_bytes, std::size_t count_bytes) const
 Return a checked logical byte range as one physical segment.
 
SplitSpan< std::byte > segments_impl (std::size_t offset_bytes, std::size_t count_bytes)
 Return a checked logical byte range as one writable segment.
 
ReadOnlyStorageView view_impl (std::size_t offset_bytes, std::size_t count_bytes) const
 Return a checked read-only byte subrange.
 
void resize_impl (std::size_t size_bits)
 Resize to hold at least size_bits bits.
 
std::span< std::byte > writable_bytes_impl ()
 Return writable logical bytes.
 
std::span< std::uint16_t > writable_words16_impl ()
 Return writable logical storage as 16-bit words.
 
std::span< std::uint64_t > writable_words64_impl ()
 Return writable logical storage as 64-bit words.
 
std::size_t allocated_bytes_impl () const
 Return bytes reserved by the underlying vector.
 
void shrink_to_fit_impl ()
 Request release of unused vector capacity.
 
std::span< CacheLineas_lines ()
 Return mutable cache-line blocks.
 
std::span< const CacheLineas_lines () const
 Return read-only cache-line blocks.
 
- Public Member Functions inherited from pixie::StorageBase< AlignedStorage >
std::size_t size_bytes () const
 Return the logical exposed storage size in bytes.
 
std::size_t size_bits () const
 Return the exposed storage size in bits.
 
bool empty () const
 Check whether the storage is empty.
 
position_type begin_position () const
 Return the first logical byte position currently exposed.
 
position_type end_position () const
 Return the position one past the last logical byte exposed.
 
bool contains (position_type position, std::size_t count_bytes) const
 Return whether a complete logical range is currently exposed.
 
std::span< const std::byte > as_bytes () const
 Return a contiguous read-only view of all logical exposed bytes.
 
SplitSpan< std::byte > segments ()
 Return all logical bytes as one or two writable physical spans.
 
SplitSpan< const std::byte > segments () const
 Return all logical bytes as one or two physical spans.
 
SplitSpan< std::byte > segments (position_type position, std::size_t count_bytes)
 Return a checked writable logical byte range as one or two spans.
 
SplitSpan< const std::byte > segments (position_type position, std::size_t count_bytes) const
 Return a checked logical byte range as one or two physical spans.
 
std::span< const std::uint16_t > as_words16 () const
 Return a read-only view as 16-bit words.
 
std::span< const std::uint64_t > as_words64 () const
 Return a read-only view as 64-bit words.
 
auto view () const
 Return a non-owning read-only view of all exposed bytes.
 
auto view (std::size_t offset_bytes, std::size_t count_bytes) const
 Return a non-owning read-only byte subrange.
 
void serialize_impl (BinaryWriter &writer) const
 Serialize the exposed bytes with a 64-bit little-endian size prefix.
 
void resize (std::size_t size_bits)
 Resize mutable storage to hold at least size_bits bits.
 
auto writable_bytes ()
 Return writable storage bytes.
 
auto writable_words16 ()
 Return writable storage as 16-bit words.
 
auto writable_words64 ()
 Return writable storage as 64-bit words.
 
std::size_t allocated_bytes () const
 Return bytes reserved by an owning storage implementation.
 
void shrink_to_fit ()
 Request release of unused reserved storage.
 
- Public Member Functions inherited from pixie::SerializationBase< AlignedStorage >
void serialize (BinaryWriter &writer) const
 Serialize this value through its concrete implementation.
 

Static Public Member Functions

static AlignedStorage deserialize_impl (BinaryReader &reader)
 Restore an owning copy of one size-prefixed byte sequence.
 
- Static Public Member Functions inherited from pixie::SerializationBase< AlignedStorage >
static AlignedStorage deserialize (BinaryReader &reader, Context &&... context)
 Restore exactly Derived and advance reader on success.
 
static AlignedStorage deserialize (std::span< const std::byte > &data, Context &&... context)
 Restore exactly Derived and advance a mutable byte span.
 

Additional Inherited Members

- Public Types inherited from pixie::StorageBase< AlignedStorage >
using position_type
 Monotonic logical byte position used to address storage ranges.
 

Detailed Description

Owning storage with a logical byte size and 64-byte-aligned backing.

Construction and resize accept a logical bit count. Exposed byte and word views cover ceil(size_bits / 8) logical bytes, while the backing allocation remains rounded up to complete cache lines. Resizing or destroying this object invalidates its read-only views.

Member Function Documentation

◆ padded_view()

ReadOnlyStorageView pixie::AlignedStorage::padded_view ( ) const
inline

Return a non-owning view of the complete cache-line backing.

This view includes allocation padding and is intended for word-oriented indexes that require a complete final word. Serialization and ordinary storage views continue to expose only logical bytes.


The documentation for this class was generated from the following file: