xgboost
| 公共成员函数 | 静态公共成员函数 | 保护成员函数 | 保护属性 | 所有成员列表
xgboost::DMatrixCache< CacheT > 类模板参考

DMatrix 相关数据的线程感知 FIFO 缓存。更多...

#include <cache.h>

xgboost::DMatrixCache< CacheT > 的协作图
Collaboration graph

结构  哈希
 
结构  项目
 
结构  
 

公共成员函数

 DMatrixCache (std::size_t cache_size)
 
DMatrixCacheoperator= (DMatrixCache &&that)
 
template<typename... Args>
std::shared_ptr< CacheT > CacheItem (std::shared_ptr< DMatrix > m, Args const &... args)
 如果 DMatrix 尚未在缓存中,则缓存新的 DMatrix更多...
 
template<typename... Args>
std::shared_ptr< CacheT > ResetItem (std::shared_ptr< DMatrix > m, Args const &... args)
 重新初始化缓存中的项。更多...
 
decltype(container_) const & Container ()
 获取底层哈希映射的 const 引用。返回前清除已过期的缓存。更多...
 
std::shared_ptr< CacheT > Entry (DMatrix const *m) const
 

静态公共成员函数

static constexpr std::size_t DefaultSize ()
 

保护成员函数

void CheckConsistent () const
 
void ClearExpired ()
 
void ClearExcess ()
 

保护属性

std::unordered_map< Key, Item, Hashcontainer_
 
std::queue< Keyqueue_
 
std::size_t max_size_
 

详细描述

template<typename CacheT>
class xgboost::DMatrixCache< CacheT >

用于 DMatrix 相关数据的线程感知 FIFO 缓存。

模板参数
CacheT需要缓存的类型。

构造函数和析构函数文档

◆ DMatrixCache()

template<typename CacheT >
xgboost::DMatrixCache< CacheT >::DMatrixCache ( std::size_t  cache_size)
内联显式
参数
cache_size缓存的最大大小。

成员函数文档

◆ CacheItem()

template<typename CacheT >
template<typename... Args>
std::shared_ptr<CacheT> xgboost::DMatrixCache< CacheT >::CacheItem ( std::shared_ptr< DMatrix m,
Args const &...  args 
)
inline

如果 DMatrix 尚未在缓存中,则缓存新的 DMatrix

在此处传入一个 shared_ptr 至关重要。首先,创建条目内部的 weak_ptr 需要此共享指针。更重要的是,此缓存的生命周期与共享指针绑定。

参数
m需要缓存的 DMatrix 的共享指针。
args如果需要,用于构造新缓存项的参数。
返回
传入的 DMatrix 的缓存条目,可以是现有缓存,也可以是新创建的缓存。

◆ CheckConsistent()

template<typename CacheT >
void xgboost::DMatrixCache< CacheT >::CheckConsistent ( ) const
inlineprotected

◆ ClearExcess()

template<typename CacheT >
void xgboost::DMatrixCache< CacheT >::ClearExcess ( )
inlineprotected

◆ ClearExpired()

template<typename CacheT >
void xgboost::DMatrixCache< CacheT >::ClearExpired ( )
inlineprotected

◆ Container()

template<typename CacheT >
decltype(container_) const& xgboost::DMatrixCache< CacheT >::Container ( )
inline

获取底层哈希映射的 const 引用。返回前清除已过期的缓存。

◆ DefaultSize()

template<typename CacheT >
static constexpr std::size_t xgboost::DMatrixCache< CacheT >::DefaultSize ( )
inlinestaticconstexpr

◆ Entry()

template<typename CacheT >
std::shared_ptr<CacheT> xgboost::DMatrixCache< CacheT >::Entry ( DMatrix const *  m) const
inline

◆ operator=()

template<typename CacheT >
DMatrixCache& xgboost::DMatrixCache< CacheT >::operator= ( DMatrixCache< CacheT > &&  that)
inline

◆ ResetItem()

template<typename CacheT >
template<typename... Args>
std::shared_ptr<CacheT> xgboost::DMatrixCache< CacheT >::ResetItem ( std::shared_ptr< DMatrix m,
Args const &...  args 
)
inline

重新初始化缓存中的项。

由于 shared_ptr 用于保存项,因此无法从缓存中访问缓存外部存在的任何引用。

我们使用 reset 而不是 erase,以避免为更新单个项遍历整个缓存。(缓存是 FIFO,需要保持顺序)。

成员数据文档

◆ container_

template<typename CacheT >
std::unordered_map<Key, Item, Hash> xgboost::DMatrixCache< CacheT >::container_
protected

◆ max_size_

template<typename CacheT >
std::size_t xgboost::DMatrixCache< CacheT >::max_size_
protected

◆ queue_

template<typename CacheT >
std::queue<Key> xgboost::DMatrixCache< CacheT >::queue_
protected

此类的文档由以下文件生成