Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions
xgboost::common::AlignedResourceReadStream Class Reference

Wrap resource into a dmlc stream. More...

#include <io.h>

Inheritance diagram for xgboost::common::AlignedResourceReadStream:
xgboost::common::PrivateMmapConstStream

Public Member Functions

 AlignedResourceReadStream (std::shared_ptr< ResourceHandler > resource)
 
std::shared_ptr< ResourceHandlerShare () noexcept(true)
 
auto Consume (std::size_t n_bytes) noexcept(true)
 Consume n_bytes of data, no copying is performed.
 
template<typename T >
auto Consume (T *out) noexcept(false) -> std::enable_if_t< std::is_pod_v< T >, bool >
 
virtual std::size_t Tell () noexcept(true)
 
std::size_t Read (void *ptr, std::size_t n_bytes) noexcept(true)
 Read n_bytes of data, output is copied into ptr.
 
template<typename T >
auto Read (T *out) noexcept(false) -> std::enable_if_t< std::is_pod_v< T >, bool >
 Read a primitive type.
 
template<typename T >
bool Read (std::vector< T > *out) noexcept(true)
 Read a vector.
 

Detailed Description

Wrap resource into a dmlc stream.

This class is to facilitate the use of mmap. Caller can optionally use the Read() method or the Consume() method. The former copies data into output, while the latter makes copy only if it's a primitive type.

Input is required to be aligned to IOAlignment().

Member Function Documentation

◆ Consume()

auto xgboost::common::AlignedResourceReadStream::Consume ( std::size_t  n_bytes)
inlinenoexcept

Consume n_bytes of data, no copying is performed.

Returns
A pair with the beginning pointer and the number of available bytes, which may be smaller than requested.

◆ Read() [1/2]

template<typename T >
bool xgboost::common::AlignedResourceReadStream::Read ( std::vector< T > *  out)
inlinenoexcept

Read a vector.

Returns
Whether the read is successful.

◆ Read() [2/2]

template<typename T >
auto xgboost::common::AlignedResourceReadStream::Read ( T *  out) -> std::enable_if_t<std::is_pod_v<T>, bool>
inline

Read a primitive type.

Returns
Whether the read is successful.

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