cuDDL
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
cuddl::detail::fastx_mapped_file Class Reference

Read-only contiguous file payload for in-memory FASTX parsing. More...

#include <fastx_sequence_file.hpp>

Public Member Functions

 fastx_mapped_file ()=default
 
 fastx_mapped_file (fastx_mapped_file const &)=delete
 
fastx_mapped_file & operator= (fastx_mapped_file const &)=delete
 
 fastx_mapped_file (fastx_mapped_file &&other) noexcept
 
fastx_mapped_file & operator= (fastx_mapped_file &&other) noexcept
 
 ~fastx_mapped_file ()
 
std::string_view data () const noexcept
 Contiguous read-only file bytes.
 
bool empty () const noexcept
 True when the file is empty or load produced no bytes.
 

Static Public Member Functions

static Result< std::unique_ptr< fastx_mapped_file > > load (std::string const &path, bool read=false, bool direct=false)
 Maps or reads a file.
 

Detailed Description

Read-only contiguous file payload for in-memory FASTX parsing.

On Linux a plain file is memory-mapped by default, so FASTA extents reference the mapping with no copy, or read into memory it owns on request. Other platforms always read.

Definition at line 254 of file fastx_sequence_file.hpp.

Constructor & Destructor Documentation

◆ fastx_mapped_file() [1/3]

cuddl::detail::fastx_mapped_file::fastx_mapped_file ( )
default

◆ fastx_mapped_file() [2/3]

cuddl::detail::fastx_mapped_file::fastx_mapped_file ( fastx_mapped_file const &  )
delete

◆ fastx_mapped_file() [3/3]

cuddl::detail::fastx_mapped_file::fastx_mapped_file ( fastx_mapped_file &&  other)
inlinenoexcept

Definition at line 259 of file fastx_sequence_file.hpp.

259 {
260 *this = std::move(other);
261 }

◆ ~fastx_mapped_file()

cuddl::detail::fastx_mapped_file::~fastx_mapped_file ( )
inline

Definition at line 281 of file fastx_sequence_file.hpp.

281 {
282 release();
283 }

Member Function Documentation

◆ data()

std::string_view cuddl::detail::fastx_mapped_file::data ( ) const
inlinenoexcept

Contiguous read-only file bytes.

Definition at line 316 of file fastx_sequence_file.hpp.

316 {
317 return std::string_view{data_, size_};
318 }

◆ empty()

bool cuddl::detail::fastx_mapped_file::empty ( ) const
inlinenoexcept

True when the file is empty or load produced no bytes.

Definition at line 321 of file fastx_sequence_file.hpp.

321 {
322 return size_ == 0;
323 }

◆ load()

static Result< std::unique_ptr< fastx_mapped_file > > cuddl::detail::fastx_mapped_file::load ( std::string const &  path,
bool  read = false,
bool  direct = false 
)
inlinestatic

Maps or reads a file.

Empty files succeed with empty data. Any failure carries the reason; the FASTX loader maps it to its stable "cannot open" error.

Parameters
readRead into owned memory instead of mapping. Unmapping write-locks the address space and shoots down TLBs on every core, which serialises a consumer that frees files loaded by dozens of threads; a single thread mapping ahead of others is better off mapping.
directRead with O_DIRECT, as read_whole_file does.

Definition at line 297 of file fastx_sequence_file.hpp.

297 {
298 auto buffer = std::make_unique<fastx_mapped_file>();
299 auto loaded = buffer->load_from_path(path, read, direct);
300 if (!loaded) return Err(loaded.error());
301 return buffer;
302 }
cuda::std::unexpected< Error > Err(Error error)
Failure return; converts to any Result<T> via cuda::std::unexpected.
Definition error.hpp:176
Here is the call graph for this function:

◆ operator=() [1/2]

fastx_mapped_file & cuddl::detail::fastx_mapped_file::operator= ( fastx_mapped_file &&  other)
inlinenoexcept

Definition at line 263 of file fastx_sequence_file.hpp.

263 {
264 if (this != &other) {
265 release();
266 owned_storage_ = std::move(other.owned_storage_);
267 data_ = other.data_;
268 size_ = other.size_;
269 other.data_ = nullptr;
270 other.size_ = 0;
271#if defined(__linux__)
272 mapped_ = other.mapped_;
273 mapped_size_ = other.mapped_size_;
274 other.mapped_ = nullptr;
275 other.mapped_size_ = 0;
276#endif
277 }
278 return *this;
279 }

◆ operator=() [2/2]

fastx_mapped_file & cuddl::detail::fastx_mapped_file::operator= ( fastx_mapped_file const &  )
delete

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